How to Configure DHCP on Cisco Router

DHCP (Dynamic Host Configuration Protocol) is a service that allows you to allocate the TCP/IP settings such as IP address and subnet mask to the clients (PC, laptop, and printer, etc.) automatically. Typically, the DHCP server is configured on a dedicated server for better performance. The dedicated server can be either a Windows-based server such as Windows Server 2016 or a Linux-based server such as Ubuntu or RHEL 7. Apart from configuring DHCP on a dedicated server, it can also be configured on a Cisco router or switch. However, some advanced functionalities may not be supported by the DHCP server configured on a Cisco router or switch. In this article, we will explain how to configure DHCP on Cisco routers.

Steps to Configure DHCP on Cisco Router

To configure the DHCP server on a Cisco router or switch, we will use the following topology.
Configure DHCP Topology

  1. On Router1, execute the following commands to configure an IPv4 address.
    Router(config)#int fa0/0
    Router(config-if)#ip add 10.0.0.1 255.0.0.0
    Router(config-if)#no shut
  2. Next, create a DHCP pool named DhcpPool1. We will use 10.0.0.1 IPv4 address as the default gateway and DNS server and 10.0.0.0 255.0.0.0 as network ID.
    Router(config)#ip dhcp pool DhcpPool1
    Router(dhcp-config)#default-router 10.0.0.1
    Router(dhcp-config)#dns-server 10.0.0.1
    Router(dhcp-config)#network 10.0.0.0 255.0.0.0
    Router(dhcp-config)#exit

    Note: By default the DHCP server will start to assign IP addresses from the first IP address of the configured network ID and it will be 10.0.0.1/8. However, we have already configured few IP addresses manually. To avoid the confliction between DHCP assigned and manually configured IP addresses, you can exclude one or more specific IP addresses or IP ranges from the DHCP pool. The DHCP server will not distribute these IP addresses to any of the DHCP clients.

  3. The following command will exclude 10.0.0.0.1 to 10.0.0.100 IP addresses that will not be distributed by DHCP server.
    Router(config)#ip dhcp excluded-address 10.0.0.1 10.0.0.100
    Router(config)#exit

    Configure DHCP Server

Obtain an IP Address from DHCP

Once you have configured the DHCP server on Router1, move on to Router2. On Router2, we will assign an IPv4 address on its Fa0/0 interface through the DHCP server.

  1. To do this, execute the following commands.
    Router(config)#int fa0/0
    Router(config-if)#ip add dhcp 
    Router(config-if)#no shut
  2. Wait for a few seconds and then execute the following command to view the IP address on Router2
Router2#show ip int brief 
or 
Router2(config)#do show ip int brief

Configure an IP Address using DHCP on Router

Configure DHCP Client

Once you configured an IP address on Router2, switch on to PC1, and try to obtain the TCP/IP settings from the DHCP server.

  1. To do so, open the console of PC1, select the Desktop tab. On the available options, click IP Configuration and then select the DHCP radio button.
  2. After a few seconds, DHCP server will assign an IP address from the configured DHCP pool along with the default gateway and DNS server IP addresses.Obtain an IP Address from DHCP
  3. In the preceding figure, you can see that 10.0.0.102 IP address has been assigned by the DHCP server configured on Router1.
  4. Now you can verify the connectivity between PC1 and Router1 by using the ping utility. To do so, execute the following command at the Command Prompt window.
    Ping 10.0.0.1
  5. You should be able to ping successfully, as shown in the following figure.

Verify Connectivity

Since all the devices belong to the same network (10.0.0.0/8), we do not need to configure any of the routing methods. The same steps can be used to configure DHCP on a Cisco switch.

In this post, we have learned how to configure DHCP on Cisco routers or switches. We would love to hear you for your queries and suggestions.

Posted in CCNA, Cisco Tagged with: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*