How to Configure DHCP Server on Cisco Routers

This tutorial explains how to configure and verify a DHCP server on Cisco routers in detail through a packet tracer example. Learn how to use a Cisco router as a DHCP server.

For this tutorial, I assume that you know what DHCP is and how it works. To learn basic concepts and configurations of DHCP, please check the previous parts of this tutorial.

Packet Tracer LAB Setup for the practice of DHCP Server

Either download the following pre-created LAB or create a packet tracer lab as shown in the following image.

Pre-created practice lab for the practice of DHCP server

practice lab configure dhcp server on cisco router

In this lab, there are two networks: Left_network and Right_Network. Both networks are connected to the router's Fast Ethernet 0/0 and 0/1 interfaces, respectively. Now our objective is to configure the following IP configuration on both networks.

Configuration Left_Network Right_Network
IP addresses 192.168.1.0 to 192.168.1.255 192.168.2.0 to 192.168.2.255
Available IP addresses for hosts 192168.1.10 to 192.168.1.254 192.168.2.10 to 192.168.2.254
Subnet mask 255.255.255.0 255.255.255.0
Default Gateway 192.168.1.1 192.168.2.1
DNS Server 192.168.1.2 192.168.2.2
TFTP Server 192.168.1.3 192.168.2.3
Reserved 192.168.1.4 to 192.168.1.10 192.168.2.4 to 192.168.2.10

Configuring IP configuration on the router

A router connects different networks. If a router is connected to a network, hosts of the network use the router as the default gateway to reach the host of other networks.

In our example, since the Left_Network and Right_Network are respectively connected to the Fast Ethernet 0/0 and 0/1 interfaces of the router, both networks will use the IP addresses of their respective interfaces as the default gateway IPs.

In simple terms, Fast Ethernet 0/0 and Fast Ethernet 0/1 of the router are the default gateways of the Left_Network and Right_Network respectively. Before configuring the router to act as a DHCP server, we have to configure and enable these interfaces.

To configure and enable these interfaces, access the command prompt of the router, and execute the following commands.

Router>enable
Router# configure terminal
Router(config)# interface FastEthernet  0/0
Router(config-if)# ip address 192.168.1.1 255.255.255.0
Router(config-if)# no shutdown
Router(config-if)#exit
Router(config)# interface FastEthernet  0/1
Router(config-if)# ip address 192.168.2.1 255.255.255.0
Router(config-if)# no shutdown
Router(config-if)#exit

The following image shows the above commands on the packet tracer.

assign IP address to router's interfaces

Configuring DHCP server on the router

For each network that will obtain IP configuration from the DHCP server, we have to create and configure a DHCP pool on the router. In our example, we have two networks, so we have to create two DHCP pools, one for each network.

Use the following commands to create and configure a DHCP pool for the Left_Network.

Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ip dhcp excluded-address 192.168.1.0 192.168.1.10
Router(config)#ip dhcp pool Left_Network
Router(dhcp-config)#default-router 192.168.1.1
Router(dhcp-config)#dns-server 192.168.1.2
Router(dhcp-config)#option 150 ip 192.168.1.3
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)#exit

The following table describes the above commands.

Command Description
ip dhcp excluded-address 192.168.1.0 192.168.1.10 This command tells the DHCP server not to assign the addresses from 192.168.1.0 to 192.168.1.10 to DHCP clients.
ip dhcp pool Left_Network This command creates a DHCP pool named, Left_Network and changes command mode to DHCP pool configuration mode.
default-router 192.168.1.1 This command assigns the default gateway to clients of this DHCP pool.
dns-server 192.168.1.2 This command sets a primary DNS server for the clients.
option 150 ip 192.168.1.3 This command provides the IP address of the TFTP server to the clients.
network 192.168.1.0 255.255.255.0 This command specifies the range of IP addresses for the pool.
exit This command exits DHCP pool configuration mode.

Create and configure a DHCP pool for the Right_Network using the same commands as shown below.

Router(config)#ip dhcp excluded-address 192.168.2.0 192.168.2.10
Router(config)#ip dhcp pool Right_Network
Router(dhcp-config)#default-router 192.168.2.1
Router(dhcp-config)#dns-server 192.168.2.2
Router(dhcp-config)#option 150 ip 192.168.2.3
Router(dhcp-config)#network 192.168.2.0 255.255.255.0
Router(dhcp-config)#exit
Router(config)#

The following image shows how to execute the above commands on the router.

configure dhcp pool on router

Configuring DHCP clients

To configure a device as a DHCP client, change its IP configuration option to DHCP. To do this, click the device. In opened Windows, click the IP configuration option from the Desktop menu and set the IP configuration option to DHCP.

The following image shows the above procedure.

configure dhcp client

Verifying DHCP clients

To verify that the client has obtained IP configuration from the DHCP server, you can check the IP configuration option of the client again. For example, the following image shows how to verify this on a host of the Left_Network.

verfiy client obtain IP address from the dhcp server

The following image shows how to verify this on a host of the Right_Network.

dhcp server verification

Verifying the DHCP Server

To verify that the DHCP server is working properly and to see the IP addresses that are provided by the DHCP server, run the following command in privileged-exec mode.

#ip dhcp binding

The following image shows the output of this command.

ip dhcp binding command

To view detailed information about a specific DHCP pool, use the following command.

#show ip dhcp pool [pool-name]

For example, the following commands list the detailed information about the DHCP pools: Left_Network and Right_Network, respectively.

#show ip dhcp pool Left_Network
#show ip dhcp pool Right_Network

The following image shows the output of the above commands.

show ip dhcp pool

Configured LAB of the example

The following download link provides the configured LAB of this example.

Configured practice LAB of the DHCP server

That's all for this part. In the next part of this tutorial, we will understand what a DHCP relay agent is and how to configure it on Cisco routers. If you like this tutorial, please don't forget to share it with friends through your favorite social channel.

ComputerNetworkingNotes CCNA Study Guide How to Configure DHCP Server on Cisco Routers