How to Configure DHCP Server on Cisco Routers

DHCP service manages IP configurations on all DHCP clients. Cisco routers include this service. If you have a Cisco router in your network, you can use it as a DHCP server. This tutorial explains how to configure, test, and verify the DHCP service on a Cisco router.

Lab setup

Set up a practice lab as shown in the following example. You can use real devices or a network simulator software to set up this lab. This tutorial uses Packet Tracer. Packet Tracer is a network simulator software. It allows you to simulate all essential devices in a virtual environment.

Lab without configuration

dhcp server practice lab

This lab is optional. You need it only if you want to practice this topic. If you need only the commands and configurations, you can skip it.

Objective

This lab network consists of two local networks (Left_Network and Right_Network) connected via the router. PCs in both networks have no IP configuration. Configure the router's DHCP service to provide IP addresses to all PCs in 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 IP addresses 192.168.1.4 to 192.168.1.10 192.168.2.4 to 192.168.2.10

Default gateway configuration

A router provides connectivity between different IP subnets. Each router interface works in a different IP subnet. It works as the default gateway for the connected network. Assign the gateway IP addresses to the interfaces connected to the local networks.

Router>enableEnter Privilege Exec mode.
Router#configure terminalEnter Global configuration mode.
Router(config)#interface FastEthernet 0/0Enter interface configuration mode for FastEthernet 0/0.
Router(config-if)#ip address 192.168.1.1 255.255.255.0Assign the ip address 192.168.1.1 to FastEthernet 0/0.
Router(config-if)#no shutdownEnable the interface.
Router(config-if)#exitExit interface configuration mode.
Router(config)#interface FastEthernet 0/1Enter interface configuration mode for FastEthernet 0/1.
Router(config-if)#ip address 192.168.2.1 255.255.255.0Assign the ip address 192.168.2.1 to FastEthernet 0/1.
Router(config-if)#no shutdownEnable the interface.
Router(config-if)#exitExit interface configuration mode.

Assigning IP address to router's interfaces

DHCP server configuration on the router

To configure DHCP on the router, create a separate DHCP pool for each network. A DHCP pool is a range of IP addresses you want to assign to DHCP clients. Each pool belongs to and is assigned to a separate IP subnet. For example, if you want to configure the DHCP server for a single IP subnet, you need to create one pool. Or if you want to configure it for four IP subnets, you need four pools. This network has two IP subnets. For these, you need to configure two pools.

Enter Global configuration mode, then define the IP addresses you want to exclude from allocation. Then, create a pool and enter pool configuration mode. In pool configuration mode, define a range of IP addresses you want to provide to clients. Then, specify the default gateway and DNS server IP addresses. After defining the first pool, create the second pool for the second subnet and define its IP range, excluded IP addresses, default gateway, and DNS server IP. A router’s interface works as the gateway device for a subnet. The router automatically maps the pool to the subnet using the gateway IP address you configured in pool configuration mode.

Router(config)#ip dhcp excluded-address 192.168.1.0 192.168.1.10Define the IP address or a range of IP addresses you do not want to assign to DHCP clients.
Router(config)#ip dhcp pool Left_NetworkCreate the DHCP pool Left_Network and enter pool configuration mode.
Router(dhcp-config)#default-router 192.168.1.1Define the gateway IP address.
Router(dhcp-config)#dns-server 192.168.1.2Specify the DNS server IP address.
Router(dhcp-config)#option 150 ip 192.168.1.3Specify the TFTP server IP address.
Router(dhcp-config)#network 192.168.1.0 255.255.255.0Define the IP range for this pool.
Router(dhcp-config)#exitExit pool configuration mode.
Router(config)#ip dhcp excluded-address 192.168.2.0 192.168.2.10Define the excluded IP addresses.
Router(config)#ip dhcp pool Right_NetworkCreate the DHCP pool Right_Network and enter pool configuration mode.
Router(dhcp-config)#default-router 192.168.2.1Define the gateway IP address.
Router(dhcp-config)#dns-server 192.168.2.2Specify the DNS server IP address.
Router(dhcp-config)#option 150 ip 192.168.2.3Specify the TFTP server IP address.
Router(dhcp-config)#network 192.168.2.0 255.255.255.0Define the IP range for this pool.
Router(dhcp-config)#exitExit pool configuration mode.
Router(config)#DHCP client configuration

configure dhcp pool on router

configure dhcp client

To configure a device as a DHCP client, change its IP configuration option to DHCP.

configure dhcp client

Verifying DHCP clients

To verify DHCP clients, check their IP configurations. The following image shows the IP configuration on a host in the Left_Network.

verfiy client obtain IP address from the dhcp server

The following image shows the IP configuration on a host in the Right_Network.

dhcp server verification

Viewing DHCP statistics

To view IP address allocation and other statistics, run the show ip dhcp binding command in Privilege Exec mode.

#show ip dhcp binding

ip dhcp binding command

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

#show ip dhcp pool [pool-name]

show ip dhcp pool

The following link provides this lab with the above configuration.

LAB with the DHCP configuration

This tutorial is part of the tutorial series "DHCP (Dynamic Host Configuration Protocol) basic concepts, configurations, functions, and options explained". Other parts of this series are the following.
Chapter 1  What DHCP is and Types of DHCP Explained
Chapter 2  How DHCP works explained with examples
Chapter 3  DHCP Configuration Parameters and Settings Explained
Chapter 4  How to Configure DHCP Server on Cisco Switches
Chapter 5  Configure DHCP Server for multiple VLANs on the Switch
Chapter 6  How to Configure DHCP Server on Cisco Routers
Chapter 7  How DHCP Relay Agents work Explained
Chapter 8  How to Configure DHCP Relay Agent on Cisco Routers
Chapter 9  How DHCP Snooping works Explained
Chapter 10  Configure DHCP Snooping on Cisco Switches

Conclusion

This tutorial explained the commands and configurations you need to configure, test, and verify the DHCP service on a Cisco router. It also included Instructions for configuring PCs as DHCP clients and verifying their IP assignments. Finally, it covered how to check DHCP bindings and pool statistics on the router using specific show commands.

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

We do not accept any kind of Guest Post. Except Guest post submission, for any other query (such as adverting opportunity, product advertisement, feedback, suggestion, error reporting and technical issue) or simply just say to hello mail us ComputerNetworkingNotes@gmail.com