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:

  1. The client send a DHCPDISCOVER in broadcast to find a DHCP server.
  2. The server sends a DHCPOFFER to the client in unicast. In this phase the DHCP server sends a proposed configuration to the DHCP client.
  3. 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.
  4. The server sends a DHCPACK unicast to the client
    1. If the client detects that the ip is already in use it sends a DHCPDECLINE
    2. If the client receives a DHCPNAK from the server, it restart the process
    3. If there is no conflict with the ip address, the client can ‘autoconfigure’ the NIC.

To configure a DHCP server on your cisco router:

  1. 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]
  2. Define a pool for your DHCP pool configuration: Ciscozine(config)# ip dhcp pool [name of your pool]
  3. Define the features of your pool:
    1. Define the network and subnet that the clients must belong. Ciscozine(config-dhcp)# network [Network number] [Network mask or prefix length]
    2. 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)
    3. 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)
    4. 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
ip dhcp excluded-address
ip dhcp excluded-address
!My dhcp pool named Ciscozine_LAN
ip dhcp pool Ciscozine_LAN

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