Now we describe how to configure basic Dynamic Host Configuration Protocol (DHCP) on Cisco Router and switch. DHCP (Dynamic Host Configuration Protocol) is the protocol used by network devices (such as PCs, network printers, etc) to automatically obtain correct network parameters so they can access network and Internet resources such as IP Address, Default Gateway, Domain Name, DNS Servers and more. The above Network devices which are getting network parameters from DHCP server also called as DHCP clients.
The Cisco IOS DHCP Server feature is a full DHCP server implementation that assigns and manages IP addresses from specified address pools within the router to DHCP clients. If the Cisco IOS DHCP Server cannot satisfy a DHCP request from its own database, it can forward the request to one or more secondary DHCP servers defined by the network administrator. A DHCP Server is most necessary in today’s networks. You usally found Windows servers, routers and layer 3 switches to run DHCP services.
DHCP Server Configuration Steps on Cisco Router or Layer 3 Switch
To configure Cisco IOS DHCP Server, follow below steps, which include sample commands:
To Enable the DHCP service in the Cisco Router or Switch, execute “service dhcp” command in global configuration mode.
To disable the DHCP service in the Cisco Router or Switch, execute “no service dhcp” command in global configuration mode.
Router(config)#no service dhcp
Note: DHCP service is enabled by default on Cisco router.
1. Configure an IP address on the router’s Ethernet or Fast Ethernet port for LAN, and bring up the interface by using no shut command.
Router(config)# interface Fastethernet 1/1
Router(config-if)#ip address 10.4.0.1 255.255.252.0
Router(config-if)# no shutdown
2. Configure a DHCP Pool Name for your LAN IP network you want to use.
Router(config)# ip dhcp pool DHCP-Pool-Name
3. Add network and subnet to the DHCP Pool.
Router(dhcp-config)# network 10.4.0.0 255.255.252.0
4. Add Default gateway to the DHCP clients.
5. Specify the domain name for the DHCP clients.
6. Specify the primary and secondary DNS servers for the DHCP clients.
Router(dhcp-config)#dns-server 10.4.0.50 184.108.40.206
7. Set the lease duration for the addresses getting from the DHCP pool.
8. Exit from DHCP Configuration Mode.
Exclude IP addresses from the DHCP pool
9. To avoid the conflicts caused by the DHCP with which we statically configured IP addresses in the same range of the DHCP pool. Use below command to exclude a single address or range of IP addresses from DHCP pool.
Router(config)# ip dhcp excluded-address 10.4.0.50
Router(config)# ip dhcp excluded-address 10.4.0.1 10.4.0.50
This takes you back to global configuration prompt and you can exclude any address from DHCP pool.
Configure DHCP Reservation Feature
If your network configuration doesn’t change very often you can allocate the same IP address to a DHCP client for indefinite time. Cisco offers the DHCP reservation feature which allows you to manually bind an IP address to a MAC address and thus a device will always receive the same IP address. To configure a manual binding, you need to create a host pool first, then specify the IP address and hardware address of the client or client identifier. Use the following sequence of commands beginning in global configuration mode:
Router(config)#ip dhcp pool Server1
Router(dhcp-config)#host 10.4.1.50 255.255.252.0
Here the ‘host‘ statetement specifies the IP address (10.4.1.50) and subnet mask of the client (255.255.252.0). The subnet mask can also be specified using a prefix length (/22). The client identifier is the unique identification of the client in hexadecimal and is composed from a MAC address and the media type. Here the MAC address is 002C.4EF1.7641 and the media type is 01 meaning Ethernet. Optionally you can specify a client name to be assigned to the device (Server1 in my case).
Note!: You must perform these steps and allocate a separate DHCP pool for each static client you want to configure.
Configure the DHCP client on Router Interface
Use the following commands to configure DHCP client on Router FastEthernet 0/1 interface.
Router# configure terminal
Router(config)# interface fastethernet 0/1
Router(config-if)# ip address dhcp
Router(config-if)# no shutdown
Troubleshooting DHCP Statistics on Cisco Router
Use the following commands to check the DHCP operation on the Cisco Router:
Router#sh ip dhcp ?
binding DHCP address bindings
conflict DHCP address conflicts
database DHCP database agents
import Show Imported Parameters
pool DHCP pools information
relay Miscellaneous DHCP relay information
server Miscellaneous DHCP server information
Below command shows the current bindings of addresses given to DHCP clients
Router#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
10.4.3.100 0100.1e37.184d.1c Sep 06 2012 12:59 PM Automatic
10.4.3.105 01ec.55f9.4c03.9b Sep 06 2012 07:52 PM Automatic
10.4.3.106 015c.ac4c.30db.a0 Sep 06 2012 02:58 PM Automatic
10.4.3.107 01ec.55f9.4c90.74 Sep 06 2012 01:01 PM Automatic
10.4.3.109 0100.1e37.184d.0c Sep 06 2012 09:56 AM Automatic
10.4.3.110 015c.ac4c.3165.cc Sep 06 2012 06:57 PM Automatic
10.4.3.113 0110.78d2.4d50.fc Sep 06 2012 11:51 AM Automatic
10.4.3.117 0100.1e37.1855.d3 Sep 06 2012 05:23 PM Automatic
10.4.3.120 01c8.0aa9.ce71.11 Sep 06 2012 05:15 PM Automatic
Below command show the DHCP server statistics.
Router#show ip dhcp server statistics
Memory usage 21269
Address pools 1
Database agents 0
Automatic bindings 39
Manual bindings 0
Expired bindings 840
Malformed messages 172
Secure arp entries 0
Below command used to get DHCP pool details.
Router#sh ip dhcp pool
Pool DHCP-Pool-Name :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 1022
Leased addresses : 39
Pending event : none
1 subnet is currently in the pool :
Current index IP address range Leased addresses
10.4.3.180 10.4.0.1 – 10.4.3.254 39
13. Below debug command is used to troubleshoot DHCP issues.
Router#debug ip dhcp server
Video – DHCP Server Configuration on Cisco Router or L3 Switch
This video covers the DHCP service configuration on Cisco Router or L3 Switch.
Filed Under: DHCP
About the Author: