Table of Contents
Overview
You can use a Cisco router as a DHCP server to distribute IP addresses to DHCP clients.This section describes the configuration and verification commands to make a Cisco router (Cisco IOS) act as a DHCP server.
Cisco IOS DHCP Server Configuration Commands
DHCP Server Configuration Flow
The basic flow for making a Cisco router act as a DHCP server is as follows
- Enable DHCP server
- DHCP Pool Configuration
- Configure Excluded Addresses
Enable DHCP server
To configure a Cisco router as a DHCP server, enter the following command in global configuration mode
Enable DHCP server
(config)#service dhcp
This command is enabled by default, so there is no need to enter it again.
DHCP Pool Configuration
Create a DHCP pool and define the TCP/IP configurations to be distributed to DHCP clients; the DHCP pool is configured in global configuration mode as follows
DHCP Pool Configuration
(config)#ip dhcp pool <pool-name>
(dhcp-config)#network <network> [ <mask> | / <prefix-length> ]
(dhcp-config)#default-router <address>
(dhcp-config)#domain-name <domain>
(dhcp-config)#dns-server <address>
(dhcp-config)#lease { <days> [<hours>] [<minutes>] | infinite}
<pool-name> : DHCP pool name
<network> : Network address to be distributed to DHCP clients
default-router <address> : Default gateway IP address
<domain> : Domain name
dns-server <address> : DNS server IP address
lease { <days> [<hours>] [<minutes>] | infinite} : Lease period for TCP/IP configurations to be distributed
Distributes IP addresses of the network addresses specified <network> in to DHCP clients. IP addresses in the range <network> are distributed in the order of available IP addresses. To distribute only a specific range of addresses, configure the excluded address as well. Also, <default-router> is the IP address of the default gateway. <domain> and <address> configure the domain name and DNS server IP address to be distributed. “lease” is the lease period. The default is 1 day; infinite means no expiration.
Configure Excluded Addresses
IP addresses that you do not want to distribute to DHCP clients are configured as excluded addresses as follows
Configure Excluded Addresses
(config)#ip dhcp excluded-address <low-ip-address> [<high-ip-address>]
With this configuration, IP addresses in the range <low-ip-address> to <high-ip-addres> are not distributed to DHCP clients. Use the ip dhcp excluded-address command to configure as many excluded addresses as necessary.
Inheritance of DNS server/domain name configuration
To distribute configurations with DHCP to DHCP clients on multiple networks, multiple DHCP pools are configured. Within each pool, DNS servers and domain names are also configured, but they are often the same, not different for each pool. Common configurations such as DNS servers and domain names can be combined into one pool, rather than one pool for each.
Create a pool of aggregated network addresses and configure DNS servers and domain names. The DNS server/domain name configuration will then be inherited by the pool of s within the aggregation. For example, create a DHCP pool in the 192.168.0.0/16 range and specify the DNS server/domain name. Then create DHCP pools for 192.168.1.0/24 and 192.168.2.0/24. These individual pools will inherit the DNS server/domain name and can be distributed to clients.
Cisco IOS DHCP Server Verification Commands
After configuring a Cisco router as a DHCP server, the main commands to verify its operation are as follows
Commands | Overview |
---|---|
On DHCP server | |
#show ip dhcp pool | Displays the address range of the DHCP pool. |
#show ip dhcp bindings | Displays IP addresses assigned to DHCP clients. |
On DHCP client | |
#show ip interface [brief] | Verify the IP address assigned to the interface. |
#show dhcp lease #show dhcp server | Verify the information assigned by DHCP. |
show ip dhcp pool
The show ip dhcp pool command displays the address range of the configured DHCP pool.
show ip dhcp pool
R1#show ip dhcp pool Pool 192.168.3.0 : 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.3.2 192.168.3.1 - 192.168.3.254 1 Pool HOST1 : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 1 Leased addresses : 1 Pending event : none 0 subnet is currently in the pool : Current index IP address range Leased addresses 192.168.3.101 192.168.3.101 - 192.168.3.101 1 Pool R2 : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 1 Leased addresses : 1 Pending event : none 0 subnet is currently in the pool : Current index IP address range Leased addresses 192.168.12.2 192.168.12.2 - 192.168.12.2 1 Pool DNS_DOMAIN : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 65534 Leased addresses : 0 Pending event : none 1 subnet is currently in the pool : Current index IP address range Leased addresses 192.168.0.1 192.168.0.1 - 192.168.255.254 0
show ip dhcp bindings
Use the show ip dhcp bindings command to verify the IP addresses assigned to DHCP clients as a DHCP server.
show ip dhcp bindings
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.3.1 0063.6973.636f.2d63. Mar 02 2002 12:01 AM Automatic 6330.352e.3564.6230. 2e30.3030.302d.4574. 302f.30 192.168.3.101 0100.0000.0011.11 Infinite Manual 192.168.12.2 0100.0000.0022.22 Infinite Manual
show ip interface [brief]
If you have a Cisco router as a DHCP client, you can check the IP address assigned by DHCP with the show ip interface command.
show ip interface [brief]
HOST1#show ip interface brief Interface IP-Address OK? Method Status Protocol Ethernet0/0 192.168.3.101 YES DHCP up up Ethernet0/1 unassigned YES NVRAM administratively down down Ethernet0/2 unassigned YES NVRAM administratively down down Ethernet0/3 unassigned YES NVRAM administratively down down HOST1#show ip interface Ethernet 0/0 Ethernet0/0 is up, line protocol is up Internet address is 192.168.3.101/24 Broadcast address is 255.255.255.255 Address determined by DHCP MTU is 1500 bytes Helper address is not set -- omitted --
show dhcp lease/show dhcp server
The show dhcp lease/show dhcp server command is used to verify the configuration information distributed by the DHCP server.
show dhcp lease/show dhcp server
HOST1#show dhcp lease Temp IP addr: 192.168.3.101 for peer on Interface: Ethernet0/0 Temp sub net mask: 255.255.255.0 DHCP Lease server: 192.168.13.1, state: 3 Bound DHCP transaction id: CC Lease: 86400 secs, Renewal: 43200 secs, Rebind: 75600 secs Temp default-gateway addr: 192.168.3.3 Next timer fires after: 11:54:09 Retry count: 0 Client-ID: 0000.0000.1111 Client-ID hex dump: 000000001111 Hostname: HOST1 HOST1#show dhcp server DHCP server: ANY (255.255.255.255) Leases: 1 Offers: 1 Requests: 1 Acks : 1 Naks: 0 Declines: 0 Releases: 0 Query: 0 Bad: 0 DNS0: 1.1.1.1, DNS1: 0.0.0.0 Subnet: 255.255.255.0 DNS Domain: n-study.com
Summary
Points
- The basic configuration flow for a Cisco router (Cisco IOS) to act as a DHCP server is as follows
- Enable DHCP server
(config)#service dhcp - DHCP Pool Configuration
(config)#ip dhcp pool - Configure Excluded Addresses
(config)#ip dhcp excluded-address
- Enable DHCP server
- DNS server and domain name information configured for an aggregated network address pool can be inherited by the pool of network addresses within the scope of the aggregation.
Related articles
The following article is a specific configuration example of a Cisco router as a DHCP server.
The following article is summary of how to place a DHCP server.
TCP/IP
- IP(Internet Protocol) : The Most Important Data Transfer Protocol
- Ping “Will the data be transfered properly?”
- Ping command on Windows OS
- Traceroute : Which router does the data go through?
- ICMP Redirect
- Where’s the Trouble? Ping and Traceroute
- ARP(Address Resolution Protocol)
- ARP Format
- Gratuitous ARP(GARP)
- nslookup command : Verifying DNS name resolution
- DHCP : Automatically Assign IP Address
- Cisco IOS DHCP Server Configuration and Verification Commands
- Cisco Router DHCP Server Configuration Example
- DHCP Relay Agent
- DHCP Relay Agent Configuration Example [Cisco]
- Summary of DHCP Server Placement
- TCP/IP Configuration Summary
- ipconfig command : To verify TCP/IP configurations on Windows OS
- Commands to Verify TCP/IP Configuration On Linux (Ubuntu)
- Web Proxy Server
- FTP : Representative File Transfer Protocol
- TFTP(Trivial File Transfer Protocol)
- TFTP Client on Windows10/11