How a DHCP server works and how to configure it on a Cisco router
The Cisco DHCP server feature is a full implementation that assigns and manages IP addresses from specified address pools to DHCP clients. After a DHCP client has booted, the client begins sending packets to its default router. The IP address of the default router should be on the same subnet as the client.
The DHCP discovery follow four steps:
- The client send a DHCPDISCOVER in broadcast to find a DHCP server.
- The server sends a DHCPOFFER to the client in unicast. In this phase the DHCP server sends a proposed configuration to the DHCP client.
- The clients sends a DHCPREQUEST in broadcast, if the clients finds the offer agreeable. Why in broadcast? Because the DHCPDISCOVER sended by the client might have reached more than one DHCP server.
- The server sends a DHCPACK unicast to the client
- If the client detects that the ip is already in use it sends a DHCPDECLINE
- If the client receives a DHCPNAK from the server, it restart the process
- If there is no conflict with the ip address, the client can ‘autoconfigure’ the NIC.
To configure a DHCP server on your cisco router:
- Define the IP range that must be excluded from being offered by the router’s DHCP service: Ciscozine(config)# ip dhcp excluded-address [low ip address] [high ip address]
- Define a pool for your DHCP pool configuration: Ciscozine(config)# ip dhcp pool [name of your pool]
- Define the features of your pool:
- Define the network and subnet that the clients must belong. Ciscozine(config-dhcp)# network [Network number] [Network mask or prefix length]
- Define the default router for the DHCP client: Ciscozine(config-dhcp)# default-router [ip of your default router] (You can configure more than one default gateway)
- Define the DNS server used by the DHCP client: Ciscozine(config-dhcp)# dns-server [dns server ip] (You can configure more than one dns server)
- You could configure others features like domain-name, netbios-name, lease, …
Example of configuration:
!The ip address that could not be used by the dhcp server process ip dhcp excluded-address 172.16.0.1 ip dhcp excluded-address 172.16.0.2 ip dhcp excluded-address 172.16.0.3 !My dhcp pool named Ciscozine_LAN ip dhcp pool Ciscozine_LAN network 172.16.0.0 255.255.255.0 default-router 172.16.0.253 dns-server 18.104.22.168 22.214.171.124 126.96.36.199
Useful command to verify DHCP Operations are:
- show ip binding: DHCP address bindings
- show ip conflict: DHCP address conflicts
- show ip database: DHCP database agents
- show ip server statistics: Miscellaneous DHCP server information
Helpful command for troubleshooting DHCP configurations and operations are:
- debug ip dhcp events: Report address assignments, lease expirations, etc.
- debug ip dhcp linkage: Show database linkage
- debug ip dhcp packet: Decode message receptions and transmissions
Enter your email address to receive notifications of new posts.