We all know the pain of static IP address assignment on large networks. The majority of us would probably configure DHCP services onto a server or host like Windows or a *nix platform. This guide is going to show you how to configure DHCP in IOS. You have to be clear on this however, Cisco devices whether a switch or router are NOT really meant to be a DHCP server. The function of your network device is pushing traffic around ;-) If you really really really must do this then take it in the context it is meant. DHCP on a Cisco device is only ever going to be a best effort service. It'll work and it'll work well but don't expect too much in terms of lease visibility.

So lets begin with a little overview of the DHCP protocol. Way way back in the early to mid 90's we had BOOTP (RFC 951). This protocol was often used for disk-less hosts using a BOOTPROM. The BPROM would broadcast out it's MAC address onto the LAN and the BOOTP server would send back an IP address plus the BOOT server and BOOT image required by the disk-less server to boot its operating system. BOOTP worked well for single networks but didn't include a things like IP gateways so the host didn't know how to get out.

Along comes DHCP. With this reworking of BOOTP we now have included options like default gateway, DNS servers, WINS servers and all manner of extra IP host configuration parameters to aid the modern client.

The DHCP 'lease' process whereby the client is provided with a unique IP address follows a 4 way process:

i) Client comes online and will broadcast a DISCOVER message onto the network
ii) DHCP server hears the DISCOVER and sends OFFER message in response
iii) The client sends a REQUEST message back to the server saying 'sounds good to me man, I'll take it'
iv) The SERVER sends an ACKNOWLEDGE message to the client saying 'You're welcome'

So thats the process, how do we setup the cisco router or layer 3 switch to do DHCP leasing. WE'll configure our router to lease IP addresses from the 172.16.1.0 255.255.255.0 subnet. Set the netmask, default gateway, dns-servers and domain name. The only REQUIRED part is the 'network' statement, all of the others are optional.

R1# configure term
R1(config)# ip dhcp pool TEST
R1(dhcp-config)# network 172.16.0.0 /16
R1(dhcp-config)# default-router 172.16.1.1
R1(dhcp-config)# dns-server 172.16.1.5 172.16.1.6
R1(dhcp-config)# domain-name mynetwork.com


So what if we've got some static addresses in the network which have been set statically? For example, above we have two DNS servers 172.16.1.5 and 172.16.1.6. What about the default gateway which was 172.16.1.1? We don't want the DHCP server leasing those addresses. You should note that most modern DHCP servers including the Windows DHCP server perform an initial ping on the LEASE address before the OFFER is sent. This way any already live addresses will be noticed and made invalid for lease to avoid duplicate addresses.

Anyway - lets ask the router to NOT lease addresses between 172.16.1.1 and 172.16.1.10 so we can use those addresses statically and be assured it won't OFFER them.

R1#(config) ip dhcp excluded-adresses 172.16.1.1 172.16.1.10
R1#(config) end


So thats it! Pop a client onto the LAN to check it out.

Don't forget to enable the dhcp service or to check leasing using:

R1(config)# service dhcp


R1# show ip dhcp server statistics
BOOTREQUEST          0
DHCPDISCOVER         63
DHCPREQUEST          203
DHCPDECLINE          1
DHCPRELEASE          27
DHCPINFORM           19
View Comments
© 2011 defaultrouteuk.com

Cisco, IOS, CCNA, CCNP, CCIE are trademarks of Cisco Systems Inc.
JunOS, JNCIA, JNCIP, JNCIE are registered trademark of Juniper Networks Inc.