Basic DHCP on Cisco Router
Basic DHCP on Cisco Router
Configuring DHCP IOS DHCP server
- Client sends a broadcast DHCPDISCOVER message to the server
- The DHCP server replies with a DHCPOFFER message containing the IP address, subnet mask , gateway and other parameters.
- The client sends a broadcast DHCPREQUEST message to the server, requesting the offered address.
- The DHCP server replies with a broadcast DHCPACK packet to the client.
DHCP server was designed to work within the same broadcast domain as the clients.
If DHCP server is behind another router , that router must become a DHCP Relay Agent. The DHCP relay will intercept the broadcast DHCP messages from the client and will forward them to the server as unicast messages. See at the end of this post a setup based on this scenario.
The configuration I use for the DHCP server in the above setup:
ip dhcp excluded-address 10.10.10.254
ip dhcp excluded-address 10.10.10.1
ip dhcp pool LAN_POOL
network 10.10.10.0 255.255.255.0
default-router 10.10.10.254
dns-server 8.8.8.8
!
interface FastEthernet0/1
ip address 10.10.10.254 255.255.255.0
duplex auto
speed auto
Enabling debug mode to see in real-time information about DHCP address assignment and database updates.
LAN_ROUTER#debug ip dhcp server events
LAN_ROUTER#
*Aug 26 19:19:48.487: DHCPD: Sending notification of DISCOVER:
*Aug 26 19:19:48.491: DHCPD: htype 1 chaddr 88ae.1dd8.796e
*Aug 26 19:19:48.491: DHCPD: remote id 020a00000a0a0afe01000000
*Aug 26 19:19:48.491: DHCPD: circuit id 00000000
*Aug 26 19:19:48.491: DHCPD: Seeing if there is an internally specified pool class:
*Aug 26 19:19:48.491: DHCPD: htype 1 chaddr 88ae.1dd8.796e
*Aug 26 19:19:48.491: DHCPD: remote id 020a00000a0a0afe01000000
*Aug 26 19:19:48.495: DHCPD: circuit id 00000000
LAN_ROUTER#
*Aug 26 19:19:50.495: DHCPD: client requests 10.10.10.4.
*Aug 26 19:19:50.495: DHCPD: Adding binding to radix tree (10.10.10.4)
*Aug 26 19:19:50.495: DHCPD: Adding binding to hash tree
*Aug 26 19:19:50.495: DHCPD: assigned IP address 10.10.10.4 to client 88ae.1dd8.796e.
*Aug 26 19:19:50.519: DHCPD: Sending notification of ASSIGNMENT:
*Aug 26 19:19:50.519: DHCPD: address 10.10.10.4 mask 255.255.255.0
*Aug 26 19:19:50.519: DHCPD: htype 1 chaddr 88ae.1dd8.796e
*Aug 26 19:19:50.519: DHCPD: lease time remaining (secs) = 86400
LAN_ROUTER#
LAN_ROUTER#
LAN_ROUTER#sh ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
10.10.10.4 88ae.1dd8.796e Aug 27 2012 07:19 PM Automatic
Below a screenshot from the computer client showing the IP address it acquired.
Below a screenshot from the computer client showing the IP address it acquired.
Then releasing the IP address from the client site we see the following DHCP events happening.
LAN_ROUTER#
*Aug 26 19:20:07.055: DHCPD: Sending notification of TERMINATION:
*Aug 26 19:20:07.055: DHCPD: address 10.10.10.4 mask 255.255.255.0
*Aug 26 19:20:07.059: DHCPD: reason flags: RELEASE d
*Aug 26 19:20:07.059: DHCPD: htype 1 chaddr 88ae.1dd8.796e
*Aug 26 19:20:07.059: DHCPD: lease time remaining (secs) = 86383
*Aug 26 19:20:07.059: DHCPD: returned 10.10.10.4 to address pool LAN_POOL.
Checking to see if indeed the IP address was released.
LAN_ROUTER#sh ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
Then using another debug mode to see in real-time the decoded DHCP packets, the sequence mentioned at the beginning are shown in detail.
LAN_ROUTER#debug ip dhcp server packet
LAN_ROUTER#
*Aug 26 19:21:27.295: DHCPD: DHCPDISCOVER received from client 88ae.1dd8.796e on interface FastEthernet0/1.
LAN_ROUTER#
*Aug 26 19:21:29.299: DHCPD: Sending DHCPOFFER to client 88ae.1dd8.796e (10.10.10.4).
*Aug 26 19:21:29.299: DHCPD: creating ARP entry (10.10.10.4, 88ae.1dd8.796e).
*Aug 26 19:21:29.299: DHCPD: unicasting BOOTREPLY to client 88ae.1dd8.796e (10.10.10.4).
*Aug 26 19:21:29.315: DHCPD: DHCPREQUEST received from client 88ae.1dd8.796e.
*Aug 26 19:21:29.315: DHCPD: Appending default domain from pool
*Aug 26 19:21:29.315: DHCPD: Using hostname 'notebook.primehome.com.' for dynamic update (from hostname option)
*Aug 26 19:21:29.315: DHCPD: Sending DHCPACK to client 88ae.1dd8.796e (10.10.10.4).
*Aug 26 19:21:29.315: DHCPD: creating ARP entry (10.10.10.4, 88ae.1dd8.796e).
LAN_ROUTER#
*Aug 26 19:21:29.315: DHCPD: unicasting BOOTREPLY to client 88ae.1dd8.796e (10.10.10.4).
LAN_ROUTER#
LAN_ROUTER#sh ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
10.10.10.4 88ae.1dd8.796e Aug 27 2012 07:21 PM Automatic
Releasing the IP address from the client we see the release message
LAN_ROUTER#
*Aug 26 19:21:39.955: DHCPD: DHCPRELEASE message received from client 88ae.1dd8.796e (10.10.10.4).
LAN_ROUTER#sh ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
From the other PC client , shown in the setup, we request also an IP address. Showing the DHCP bindings we see the IP addresses for both the clients.
LAN_ROUTER#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
10.10.10.4 88ae.1dd8.796e Aug 27 2012 11:00 PM Automatic
10.10.10.9 0063.6973.636f.2d63. Aug 27 2012 11:04 PM Automatic
6130.302e.3331.6563.
2e30.3030.382d.4661.
302f.30
Below the output from the PC client , showing that it received the proper IP address. (I used a Cisco Router acting as a PC).
Finally we use the proper command to clear the IP address assignments to the clients.
LAN_ROUTER#clear ip dhcp binding *
LAN_ROUTER#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
Configuring DHCP IOS DHCP client
interface FastEthernet0/0
ip address dhcp
duplex auto
speed auto
When interface comes up it gets an ip address.
LAN_ROUTER#
*Aug 26 23:30:35.894: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Aug 26 23:30:35.894: %ENTITY_ALARM-6-INFO: CLEAR INFO Fa0/0 Physical Port Administrative State Down
LAN_ROUTER#
*Aug 26 23:30:36.274: %SYS-5-CONFIG_I: Configured from console by console
*Aug 26 23:30:36.894: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
LAN_ROUTER#
*Aug 26 23:30:38.186: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 192.168.2.17, mask 255.255.255.0, hostname LAN_ROUTER
Configuring DHCP Relay Agent
In a situation where the clients are on another domain as the DHCP server the router must become a DHCP Relay Agent (using the command ip helper-address ip-address) and enable the DHCP server.
By default, the DHCP server feature is enabled, but you can star it again to make sure that it is running.
LAN_ROUTER(config)#service dhcp
Disabling the service the DHCP server will stop.
LAN_ROUTER(config)#no service dhcp
*Aug 27 11:45:35.067: DHCPD: receive process caught signal 15.
*Aug 27 11:45:35.067: DHCPD: shutting down.
*Aug 27 11:45:35.075: DHCPD: database process caught signal 15.
*Aug 27 11:45:35.079: DHCPD: database process is dead.
LAN_ROUTER(config)#
*Aug 27 11:45:36.071: DHCPD: timer process is dead.
*Aug 27 11:45:36.075: DHCPD: receive process is dead.
LAN_ROUTER(config)#
LAN_ROUTER(config)#service dhcp
Below the new configuration on the LAN_ROUTER.
LAN_ROUTER#show run int fastEthernet 0/1
interface FastEthernet0/1
description ==To LAN==
ip address 10.10.10.254 255.255.255.0
ip helper-address 172.16.10.2
duplex auto
speed auto
end
After, both clients acquired an IP address we confirm by checking the DHCP bindings on the server.
DHCP_SERVER#sh ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
10.10.10.3 88ae.1dd8.796e Aug 28 2012 11:46 AM Automatic
10.10.10.4 0063.6973.636f.2d63. Aug 28 2012 11:43 AM Automatic
6130.302e.3066.3439.
2e30.3030.382d.4661.
302f.30
Comments