Configuring a DHCP Server on a Cisco router is a very common task on SOHO enviroments. In small companies with a small number of hosts, there is no need of a separate DHCP Server, taking advantage of the DHCP Service avaliable on routers.
Verify the service is running:
This service is enabled by the default, but can be disabled for security or if we are leveraging on a third device. We can check the service is running using this command:
R1#sh udpProto Remote Port Local Port In Out Stat TTY OutputIF17 0.0.0.0 0 18.104.22.168 67 0 0 2211 0
As we can see, the router is listening at DHCP Server’s port UDP 67.
Disabling the service:
R1(config)#no service dhcpR1(config)#do sh udpProto Remote Port Local Port In Out Stat TTY OutputIF
Procedure for configuring DHCP:
We are going to use R4 as DHCP server and R5 as DHCP client:
First step is specify the pool, together with the excluded addresses:
R4(config)#ip dhcp excluded-address 22.214.171.124 126.96.36.199R4(config)#ip dhcp pool LANR4(dhcp-config)#network 188.8.131.52 255.255.255.0R4(dhcp-config)#default-router 184.108.40.206R4(dhcp-config)#dns-server 220.127.116.11
For our example, I have excluded the first 4 addresses, to avoid duplicated address issues with R1 and R4.
Verify the correct function:
Check that R5 gets an ip:
R5(config)#int fa0/0R5(config-if)#ip add dhcpR5(config-if)#do sh ip*Mar 1 00:02:17.651: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 18.104.22.168, mask 255.255.255.0, hostname R5
See the corresponding binding at R4:
R4(config)#do sh ip dhcp bindBindings from all pools not associated with VRF:IP address Client-ID/ Lease expiration TypeHardware address/User name22.214.171.124 0063.6973.636f.2d63. Mar 02 2002 12:02 AM Automatic3230.382e.3066.6330.2e30.3030.302d.4661.302f.30R4#sh ip dhcp server statMemory usage 23799Address pools 1Database agents 0Automatic bindings 1Manual bindings 0Expired bindings 0Malformed messages 0Secure arp entries 0Message ReceivedBOOTREQUEST 0DHCPDISCOVER 1DHCPREQUEST 1DHCPDECLINE 0DHCPRELEASE 0DHCPINFORM 0Message SentBOOTREPLY 0DHCPOFFER 1DHCPACK 1DHCPNAK 0R4#sh ip dhcp poolPool LAN :Utilization mark (high/low) : 100 / 0Subnet size (first/next) : 0 / 0Total addresses : 254Leased addresses : 1Pending event : none1 subnet is currently in the pool :Current index IP address range Leased addresses126.96.36.199 188.8.131.52 - 184.108.40.206 1