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 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 212.216.172.62 208.67.222.222 212.216.112.112

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

4 COMMENTS

  1. It will turn into a unicast if it get passed by a router with a helper address to a specific dhcp server. And the DHCPACK is a tcp ack towards the server not a broadcast on to the network.

  2. DHCPACK

    After the DHCP server receives the DHCPREQUEST, it acknowledges the request with a DHCPACK message, thus completing the initialization process. The DHCPACK message has a source IP address of the DHCP server, and the destination address is once again a broadcast and contains all the parameters that the client requested in the DHCPREQUEST message. When the client receives the DHCPACK, it enters into the Bound state, and is now free to use the IP address to communicate on the network. Meanwhile, the DHCP server stores the lease in its database and uniquely identifies it using the client identifier or chaddr, and the associated IP address. Both the client and server will use this combination of identifiers to refer to the lease. The client identifier is the Mac address of the device plus the media type.

    Before the DHCP client begins using the new address, the DHCP client must calculate the time parameters associated with a leased address, which are Lease Time (LT), Renewal Time (T1), and Rebind Time (T2). The typical default LT is 72 hours. You can use shorter lease times to conserve addresses, if needed.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.