Configuring DHCP
1. Introduction
Configuring DHCP is a crucial step when setting up a network. Most people rely on Windows or Linux servers for DHCP, but did you know your Cisco router can also handle this role?
Imagine the convenience of having your router automatically assign IP addresses and other network details to devices—no need for additional servers.
In this guide, you’ll learn step-by-step how to configure a Cisco router as a DHCP server !
2. DHCP Configuration on Cisco Devices
To configure a Cisco router as a DHCP server, there are multiple steps we need to go through to ensure everything works properly. Let’s break it down step by step.
This will be our topology scenario for this configuration !
Reserved IP Addresses
The first step is to exclude a range of IP addresses that won’t be assigned to DHCP clients. These reserved addresses are meant for important devices like servers, routers, or printers that always need static IPs.
The command is : ip dhcp excluded-address <start-IP> <end-IP>
R1(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
This command ensures that the IP addresses from 192.168.1.1
to 192.168.1.10
are excluded from the DHCP pool. This avoids conflicts between dynamically assigned IP addresses by the DHCP server and the statically assigned IP addresses for critical devices.
DHCP Pool
To dynamically assign IP addresses to clients, you need to create a DHCP pool.
What is a DHCP pool?
A DHCP pool is a named configuration that defines the settings for DHCP clients. It acts as a container where you specify the range of IP addresses that can be assigned, along with other parameters like the default gateway and DNS servers.
To create a DHCP pool, use the following command: ip dhcp pool <pool-name>
R1(config)# ip dhcp pool MY_DHCP_POOL
This command creates a DHCP pool named MY_DHCP_POOL
and enters DHCP configuration mode, where you can define the network settings for DHCP clients.
IP Address Range
Once the DHCP pool is created, you need to specify the network range from which IP addresses will be assigned. This tells the router which subnet is available for DHCP clients.
To create a DHCP pool, use the following command: network <network-IP> <subnet-mask>
R1(dhcp-config)# network 192.168.1.0 255.255.255.0
or using CIDR notation:
R1(dhcp-config)# network 192.168.1.0 /24
This means the router can allocate IPs from 192.168.1.1 to 192.168.1.254, except for excluded addresses.
Default Gateway
The default gateway is the IP address that devices use to send traffic outside their local network.
Configuring the default gateway ensures that DHCP clients can communicate with external networks.
R1(dhcp-config)# default-router 192.168.1.1
In this example, the router’s IP address (192.168.1.1
) is set as the default gateway for DHCP clients, allowing them to reach other networks.
DNS Server
The DNS server resolves domain names into IP addresses, allowing devices to access websites and network resources using names like google.com.
R1(dhcp-config)# dns-server 8.8.8.8
In this example, Google’s public DNS server (8.8.8.8
) is used. You can also specify an internal DNS server if needed.
Domain Name
You can configure a domain name for your network to give it a professional identity and make communication between devices easier.
R1(dhcp-config)# domain-name pingmynetwork.com
Here, we set the domain name to pingmynetwork.com
.
Lease Duration
The lease duration defines how long a DHCP client can keep an assigned IP before needing to renew it. By default, IP leases are temporary to ensure efficient use of addresses.
The command is like : explain (put the syntax of the command)
R1(dhcp-config)# lease 2 4 0
Here, the lease duration is set to 2 days, 4 hours, and 0 minutes.
Note: Avoid infinite leases, as they can lead to inefficient IP usage. Shorter leases help recycle unused IPs, keeping the network optimized.
3. Verifying DHCP Configuration
Now that your router is fully configured, let’s explore how you can verify the DHCP setup and observe the client’s interaction with the DHCP server. This process will ensure everything is functioning as expected.
DHCP Configuration on the Router
To begin, you can verify your DHCP configuration by running the command: show running-config | section dhcp
Take a look at the output above to see how the DHCP pool is configured on the router !
DHCP Client Request
Imagine this scenario: you connect a PC to your network by plugging in the interface cable. What happens next?
The moment the connection is established, the DHCP process begins. Your PC sends a request to the DHCP server which assigns an IP address and other necessary configurations like the subnet mask, default gateway, and DNS server.
By the end of this process, your PC will have the necessary IP configuration to communicate within the network and beyond.
Client IP Configuration
Once the DHCP process is complete, you can check directly on the client device to see the configuration it received. Run the following command on the client:
This command provides a detailed overview of the DHCP-assigned settings, such as:
- IP Address: The IP assigned to the client.
- Subnet Mask: Defines the network range.
- Default Gateway: The router the client will use to access external networks.
- DNS Server: The server resolving domain names to IPs.
- Lease Duration: The validity period of the assigned IP address.
DHCP Leases on the Router
As a network administrator, you have the added ability to check directly on the router to verify that IP addresses are being assigned correctly.
Use the command show ip dhcp binding
:
R1#show ip dhcp binding Bindings from all pools not associated with VRF: IP address Client-ID/ Lease expiration Type Hardware address/ User name 192.168.1.11 0100.5079.6668.7e Jan 29 2025 10:00 AM Automatic
Here’s what the output shows:
- IP Address: The router assigned
192.168.1.11
to the client. - Client-ID/Hardware Address: The MAC address of the client is
0100.5079.6668.7e
. - Lease Expiration: The IP lease is valid until January 29, 2025, at 10:00 AM.
- Type: Indicates the IP was assigned automatically.
By using this command, you can quickly verify which devices have received an IP address from the DHCP server and ensure that everything is working as expected. If an expected device is missing, it may indicate the client hasn’t requested an IP or there’s a configuration issue to investigate.
DHCP Pool Details
You can also check the status of the DHCP pool directly on the router to see the available and leased IP addresses.
Use the following command show ip dhcp binding
:
R1(dhcp-config)# show ip dhcp pool Pool MY_DHCP_POOL : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 254 Leased addresses : 1 Pending event : none 1 subnet is currently in the pool : Current index IP address range Leased addresses 192.168.1.12 192.168.1.1 - 192.168.1.254 1
Here’s what this output tells us:
- Pool Name: The DHCP pool is named
MY_DHCP_POOL
. - Total Addresses: The pool has 254 IPs, but 192.168.1.1 to 192.168.1.10 are reserved for devices like routers or switches.
- Leased Addresses: Only 1 IP (
192.168.1.11
) has been assigned to a client. - IP Address Range: Assignable addresses start from
192.168.1.11
.
This command helps verify the DHCP pool configuration and ensure enough addresses are available for clients. Combine it with show ip dhcp binding
for a full overview of assigned IPs!
4. Conclusion
We’ve seen how to configure a DHCP server on a Cisco router, enabling it to dynamically assign IP addresses and essential network settings. Key takeaways include:
- Excluding reserved addresses for critical devices.
- Creating a DHCP pool to allocate dynamic IPs.
- Defining essential settings like the default gateway, DNS server, and lease duration.
- Verifying and troubleshooting using commands like
show ip dhcp binding
andshow ip dhcp pool
.
Next, we’ll explore DHCP Relay—a solution for extending DHCP services across multiple networks.