Configuring DHCP on a Cisco router

Configuring DHCP on a Cisco router

Introduction

DHCP (Dynamic Host Configuration Protocol) is a network protocol that automatically assigns IP addresses and other network configuration parameters to devices on a network. Instead of manually configuring each device with a static IP address, DHCP allows devices to request and receive network settings automatically.

In this tutorial, we'll learn how to configure DHCP on a Cisco router to automatically assign IP addresses to devices on your network.

Basic DHCP Configuration

To configure DHCP on a Cisco router, we need to create a DHCP pool and define the network parameters. Here's the basic configuration:

Router(config)# ip dhcp pool POOL_NAME
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 8.8.8.8 8.8.4.4
Router(dhcp-config)# lease 7

Let's break down each command:

  • ip dhcp pool POOL_NAME - Creates a DHCP pool with a specified name
  • network 192.168.1.0 255.255.255.0 - Defines the network and subnet mask for IP assignment
  • default-router 192.168.1.1 - Specifies the default gateway
  • dns-server 8.8.8.8 8.8.4.4 - Configures DNS servers
  • lease 7 - Sets the lease duration to 7 days

Excluding IP Addresses

You may want to exclude certain IP addresses from being assigned by DHCP (such as static server addresses or the router's own IP). Use the following command:

Router(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10

This excludes IP addresses from 192.168.1.1 to 192.168.1.10 from the DHCP pool.

Complete DHCP Configuration Example

Here's a complete example of configuring DHCP on a Cisco router:

Router(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
Router(config)# ip dhcp pool LAN_POOL
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 8.8.8.8 8.8.4.4
Router(dhcp-config)# lease 7
Router(dhcp-config)# exit
Router(config)# service dhcp

The service dhcp command enables the DHCP service on the router (it's enabled by default, but it's good practice to include it).

Verifying DHCP Configuration

After configuring DHCP, you can verify the configuration and monitor DHCP activity using these commands:

Router# show ip dhcp pool
Router# show ip dhcp binding
Router# show ip dhcp conflict
  • show ip dhcp pool - Displays DHCP pool information
  • show ip dhcp binding - Shows current DHCP bindings (assigned IP addresses)
  • show ip dhcp conflict - Displays any IP address conflicts

Troubleshooting DHCP

If devices aren't receiving IP addresses from DHCP, check the following:

  1. Ensure the DHCP service is enabled with service dhcp
  2. Verify the DHCP pool configuration with show ip dhcp pool
  3. Check if there are available IP addresses in the pool
  4. Ensure the router interface connected to the client network has an IP address configured
  5. Verify that DHCP requests are reaching the router

Conclusion

Configuring DHCP on a Cisco router simplifies network administration by automatically assigning IP addresses to devices. This reduces the chance of IP conflicts and makes it easier to manage large networks. Remember to exclude static IP addresses from your DHCP pool and monitor the DHCP bindings to ensure everything is working correctly.