DHCP – Switches CAN do it better than servers!

Dynamic Host Configuration Protocol

For most environments we configure DHCP as a role on our servers. Windows 2008 R2 DHCP role, *nix service with sudo apt-get install dhcp or something like that. Well your switches can do it too and if bandwidth and broadcasts are a concern look no further. Your vlan can issue DHCP addresses and cut the need for DHCP broadcasts to flood the network across multiple layers to reach a server.

Wow. Exciting. What do I need to know about DHCP?

Well, DHCP is a fundamental network protocol that assigns IP addresses to devices en masse. Sure static is cool. It’s also seriously uncool with 20,000 devices and the like. How about statically configuring 200 new 1262 WAP’s and inputing an IP to match a mac-address into a WLC. No thanks. Set a scope, define it’s options and voila. Happy end-users.

The DHCP process is rather simple but knowing what happens at each stage is important. Here we go into another blog!

DHCP Process

Client sends out a DHCPDISCOVER broadcast. DHCP server returns with a DHCPOFFER unicast which contains parameters such as IP, MAC Address and a lease. Client returns an request for this offer in the form of a DHCPREQUEST broadcast. The DHCP sever will then issue a DHCPACK unicast to confirm.

A client can broadcast to many DHCP servers and many DHCP servers will reply but the first server generally distributes the lease.

Configurations and scope options

A Layer 3 switch can only issue addresses to vlans in which it has an IP in the subnet.

3750(config)# ip dhcp excluded-address
3750(config)# ip dhcp pool IP_CAMERAS
3750(config-dhcp)# network
3750(config-dhcp)# default-router
3750(config-dhcp)# option 150
3750(config-dhcp)# lease 0 8 0
3750(config-dhcp)# ! 0 days 8 hours 0 minutes
3750(config)# interface vlan 32
3750(config-if)# ip address

Here the above configuration sets up a DHCP scope for the IP Camera vlan. Once we assign a port and plug the cameras in, IOS will assign them an IP address with the parameters configured above.

I want to use a Windows DHCP server in a different Vlan!

My setup is mixed. I have IOS DHCP assigned for my IP cameras. Yet for my desktop/laptop fleet and the Cisco IP handsets I want to use Windows 2008 R2 server with the DHCP role.

What issue would arise using a DHCP server in a different vlan?

If you answered, DHCP requests are broadcast and vlan’s are broadcast domains so the switch will not forward my requests on and I will be assigned an APIPA address, then you are correct! We overcome this by a simple feature on the SVI interface. This command forwards the DHCP udp packets as well as TFTP, DNS, NTP, NetBIOS, name server and BOOTP packets. Handy!

Simple commands

3750(config)# interface vlan 40
3750(config)# ip address
3750(config-if)# ip helper-address

Nice and easy. I have forgotten myself some times. PXE boot or WDS – fails to hit the load PE and I know the first thing after a network re-jig or new VLAN is to check ip helper-address.

Some deliciously informative commands to check on leases are

3750# show ip dhcp binding

Bindings from all pools not associated with VRF:
IP address          Client-ID/              Lease expiration        Type
                    Hardware address/
                    User name      0063.6973.636f.2d64.    Oct 29 2011 04:36 AM    Automatic

Nice and easy today. Simple and effective. I believe the IOS built in DHCP server can be handy if well versed for a few reason. They are as follows and are based on my experiences

  • Mass DHCP requests can avoid traversing access layer to distribution and maybe core to reach DHCP server. 8am clock on time, hundreds and or thousands of machines starting and and flooding away.
  • Server infrastructure may be located else where or you may have a lack there of
  • Can issue pools on a per switch basis. Useful if R&D are segregated or have an island network.

1 thought on “DHCP – Switches CAN do it better than servers!”

Leave a Reply

Your email address will not be published. Required fields are marked *