Thursday, July 19, 2012

Cisco Switch: How To Forward DHCP Requests To A Server On Another Vlan (Network)

I run into this a lot.  If you only have one DHCP server, and have devices on multiple vlans, how do you get traffic to forward to that DHCP server.  DHCP broadcasts do not traverse vlans, unless you 'help' it.  That is where the 'ip helper-address' comes into play.  See below the topology:

When a computer or an IP phone is on a separate vlan (2 and 3 above), and the DHCP server is in Vlan 1, here is the config you would need to do:

interface vlan 1
ip address 10.10.1.1 255.255.255.0

interface vlan 2
ip address 10.10.2.1 255.255.255.0 
ip helper-address 10.10.1.2   <---- IP of the DHCP server

interface vlan 3
ip address 10.10.3.1 255.255.255.0 
ip helper-address 10.10.1.2   <---- IP of the DHCP server

The 'ip helper-address' command forwards traffic over to the DHCP server.  Since the packet comes from the interface of vlan 2 for the computer (vlan 3 for the ip phone), the DHCP server matches the ip address of that vlan interface with a scope programmed in the DHCP server.  The server responds appropriately, and the switch hands the fulfilled request back to the device that broadcasted out the request.  Simple as that.