The DHCP protocol is used to automatically assign IP addresses on IP networks. You can deploy a DHCP server on a separate Windows Server or Linux host. Such a server will assign and manage IPv4/IPv6 addresses for DHCP clients. Also, most network routers support the DHCP server mode. In this article, we will show you how to configure a DHCP server on a Cisco router running the Cisco IOS operating system.
The Cisco router is configured from the Cisco IOS command line. Connect to your Cisco router via telnet/SSH and go to the configuration mode.
Router #configure terminal
The DHCP server service is enabled by default in Cisco IOS. If it is disabled, you can enable it with the command:
Router(config)# service dhcp
Next, you must create DHCP pools from which you need to distribute IP addresses to clients. Let’s say you want your router to assign IP addresses in the 192.168.1.0/24 network starting from IP address 192.168.1.11.
Create a new DHCP pool:
Router(config)# ip dhcp pool LAN1
Next, you need to specify the IP subnet, gateway address and DNS server addresses:
Router(dhcp-config)# network 192.168.1.0 255.255.255.0 Router(dhcp-config)# default-router 192.168.1.1 Router(dhcp-config)# dns-server 192.168.1.10
You can additionally configure various DHCP pool options, for example:
- Set a domain name: Router (dhcp-config)#domain-name my-domain.com
- DHCP lease time (the default lease time is 1 day): Router(dhcp-config)# lease 2
- NetBIOS WINS server address (for Microsoft networks): Router(dhcp-config)# netbios-name-server 192.168.1.10
To finish configuring the DHCP pool, run:
Tip. Note that the DHCP service on a Cisco router is not bound to a specific interface.
To exclude a specific range from the DHCP pool, run the command:
Router(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.10 Router(config)#ip dhcp excluded-address 192.168.1.254
These commands prevent the router from assigning these IP addresses to clients.
You can create DHCP reservations. The MAC address of the device specified in the reservation will always be assigned the same IP address, which cannot be assigned to another device.
Router(config)# ip dhcp pool LAN1 Router(config-pool)#host 192.168.1.100 255.255.255.0 Router(config-pool)#client-identifier 0100.0636.1263.ba Router(config-pool)#client-name iis-server
The unique MAC address of the device is specified as the client-identifier argument.
Hint. Please note that for Windows clients of networks 01 is specified before the MAC address, and 00 for Linux/Unix networks.
If you don’t know the client type of customer, you can create a reservation like this:
Router(config)# ip dhcp pool LAN1 Router(config-pool)#host 192.168.1.100 255.255.255.0 Router(config-pool)#hardware-address 00.0636.1263.ba Router(config-pool)#client-name apache-server
Now you need to get an address lease from a DHCP client. In Windows, to update the IP address, use the ipconfig command:
ipconfig /release ipconfig /renew
You can view the assigned IP address using the command:
The screenshot shows that the Windows client has been assigned an IP address 192.168.1.30 from the DHCP server 192.168.1.1.
On a Cisco router, you can list all IP addresses and associated MAC addresses that were issued by the DHCP server:
router#show ip dhcp binding IP address Client-ID/ Lease expiration Type
192.168.1.30 0050.2CA5.F573 Jul 19 2020 12:25 AM Automatic
You can reset the assigned IP address to the client:
Router# clear ip dhcp binding 192.168.1.30
Or completely clear the table of correspondence between physical addresses and IP addresses issued from the DHCP server pool:
Router#clear ip dhcp binding
To view DHCP server statistics, use the command:
Router# show ip dhcp server statistics