Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document.
Note: Even the most advanced machine translation cannot match the quality of professional translators.
Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
Applicability
This example applies to all versions and AR routers.
Networking Requirements
The router functions as the DHCP server to dynamically allocate IP addresses to the clients on the network segment 10.10.1.0/24. This network segment consists of two subnet segments: 10.10.1.0/25 and 10.10.1.128/25. The IP addresses of GE0/0/0 and GE0/0/1 on the router are 10.10.1.1/25 and 10.10.1.129/25, respectively. On the network segment 10.10.1.0/25, the IP address lease is 10 days and 12 hours, the domain name is huawei.com, the DNS server address is 10.10.1.2, the NetBIOS server address is 10.10.1.4, and the egress gateway address is 10.10.1.1. It is required that the fixed IP address 10.10.1.5 be assigned to the office PC (PC_AD) to meet service requirements. On the network segment 10.10.1.128/25, the IP address lease is 5 days, the domain name is huawei.com, the DNS server address is 10.10.1.2, no NetBIOS server address is configured, and the egress gateway address is 10.10.1.129. Figure 8-1 Networking diagram for configuring DHCP server
Procedure
- Configure the router.
# sysname Router # dhcp enable //Enable the DHCP function. # ip pool ip-pool1 gateway-list 10.10.1.1 //Configure a gateway address. network 10.10.1.0 mask 255.255.255.128 //Specify the range of IP addresses that can be dynamically allocated from the global IP address pool. excluded-ip-address 10.10.1.2 //Specify the IP address (10.10.1.2) that cannot be automatically allocated from an IP address pool. excluded-ip-address 10.10.1.4 //Specify the IP address (10.10.1.4) that cannot be automatically allocated from an IP address pool. dns-list 10.10.1.2 //Configure a DNS server address for the DHCP client. nbns-list 10.10.1.4 //Configure a NetBIOS server address for the DHCP client. lease day 10 hour 12 minute 0 //Set the lease of IP addresses to 10 days and 12 hours. domain-name huawei.com //Set the domain name to huawei.com. static-bind ip-address 10.10.1.5 mac-address 00e0-fc67-ce34 //Assign a fixed IP address to PC_AD. # ip pool ip-pool2 gateway-list 10.10.1.129 //Configure a gateway address. network 10.10.1.128 mask 255.255.255.128 //Specify the range of IP addresses that can be dynamically allocated from the global IP address pool. dns-list 10.10.1.2 //Configure a DNS server address for the DHCP client. lease day 5 hour 0 minute 0 //Set the lease of IP addresses to 5 days. domain-name huawei.com //Set the domain name to huawei.com. # interface GigabitEthernet0/0/0 ip address 10.10.1.1 255.255.255.128 dhcp select global //Configure the interface to use the global IP address pool. # interface GigabitEthernet0/0/1 ip address 10.10.1.129 255.255.255.128 dhcp select global //Configure the interface to use the global IP address pool. #
- Verify the configuration.# Run the display ip pool command on the router to view the IP address pool configuration.
Updated: 2022-10-25 Document ID: EDOC1100130782 Views: 235668 Downloads: 1794 Average rating: This Document Applies to these Products
Digital Signature File
Configure DHCP server on Cisco devices
DHCP is widely used in LAN environments to dynamically assign host IP addresses from a centralized server, which significantly reduces the overhead of administration of IP addresses. DHCP also helps conserve the limited IP address space because IP addresses no longer need to be permanently assigned to hosts; only those hosts that are connected to the network consume IP addresses. The DHCP server assigns IP addresses from specified address pools on a router or router to DHCP clients and manages them. In this article, you will learn how to configure Cisco Router as DHCP server using CLI and to update it on multiple devices simultaneously in NCM application using configlets. If you don’t have NCM installed, please click here to download and install the application.
Steps to configure DHCP server through CLI.
-
- Login to the device using SSH / TELNET and go to enable mode.
-
- Go into the config mode.
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#
- Go into the config mode.
-
- Exclude IP addresses from being assigned by DHCP by using the ip dhcp excluded-address FIRST_IP LAST_IP
Router(config)#ip dhcp excluded-address 192.168.0.1 192.168.0.50
Router(config)#
- Exclude IP addresses from being assigned by DHCP by using the ip dhcp excluded-address FIRST_IP LAST_IP
-
- Create a new DHCP pool with the ip dhcp pool NAME command
Router(config)#ip dhcp pool Floor1DHCP
Router(dhcp-config)#
- Create a new DHCP pool with the ip dhcp pool NAME command
-
- Define a subnet that will be used to assign IP addresses to hosts with the network SUBNET SUBNET_MASK command.
Router(dhcp-config)#network 192.168.0.0 255.255.255.0
Router(dhcp-config)#
- Define a subnet that will be used to assign IP addresses to hosts with the network SUBNET SUBNET_MASK command.
-
- Define the default gateway with the default-router IP command
Router(dhcp-config)#default-router 192.168.0.1
Router(dhcp-config)#
- Define the default gateway with the default-router IP command
-
- Define the DNS server with the dns-server IP address command.
Router(dhcp-config)#dns-server 192.168.0.1
Router(dhcp-config)#
- Define the DNS server with the dns-server IP address command.
-
- Return to privilege config mode
Router(dhcp-config)#exit
Router(config)#
- Return to privilege config mode
-
- Enable DHCP server on the interface using service dhcp interface-type number command
Router(config)#service dhcp vlan1
Router(config)#
- Enable DHCP server on the interface using service dhcp interface-type number command
-
- Exit config mode
Router(config)#exit
Router#
- Exit config mode
-
- To view information about the currently leased addresses, you can use the show ip dhcp binding command
Router#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.0.51 0060.5C2B.3DCC — AutomaticIn the output above you can see that there is a single DHCP client that was assigned the IP address of 192.168.0.51. Since we’ve excluded the IP addresses from the 192.168.0.1 – 192.168.0.50 range, the device got the first address available – 192.168.0.51.
- To view information about the currently leased addresses, you can use the show ip dhcp binding command
-
- To display information about the configured DHCP pools, you can use the show ip dhcp pool command
Router#show ip dhcp pool
Pool Floor1DHCP :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 254
Leased addresses : 1
Excluded addresses : 1
Pending event : none1 subnet is currently in the pool
Current index IP address range Leased/Excluded/Total
192.168.0.1 192.168.0.1 — 192.168.0.254 1 / 1 / 254This command displays some important information about the DHCP pool(s) configured on the device – the pool name, total number of IP addresses, the number of leased and excluded addresses, subnet’s IP range, etc.
- To display information about the configured DHCP pools, you can use the show ip dhcp pool command
- Copy the running configuration into startup configuration using below command
Router#write memory
Building configuration… [OK]
Router#
Corresponding configlet can be created in NCM application as shown in below screenshot. Also you can click the below button to download the Configlet as XML and import it into NCM application using file import option.
Configlet Name | Configure DHCP Server Cisco |
---|---|
Description | Script execution mode |
Execution Mode | This article is about how to configure Cisco Router as DHCP server using CLI and how to update on multiple devices simultaneously in NCM application using configlets. |
Configlet Content | configure terminal ip dhcp excluded-address $EXCLUDE_FIRST_IP $EXCLUDE_LAST_IP ip dhcp pool $MY_POOL_NAME network $SUBNET $SUBNET_MASK default-router $DEFAULT_ROUTER_IP dns-server $DNS_SERVER_IP exit service dhcp $INTERFACE_TYPE_NUMBER exit show ip dhcp binding show ip dhcp pool write memory |
Dynamic Host Configuration Protocol (DHCP) is an application layer protocol used to distribute various network configuration parameters to devices on a TCP/IP network. – IP addresses, subnet masks, default gateways, DNS servers, etc. DHCP employs a client-server architecture; a DHCP client is configured to request network parameters from a DHCP server on the network. A DHCP server is configured with a pool of available IP addresses and assigns one of them to the DHCP client. A Cisco router can be configured as a DHCP server. Here are the steps:
- Exclude IP addresses from being assigned by DHCP by using the ip dhcp excluded-address FIRST_IP LAST_IP
- Create a new DHCP pool with the ip dhcp pool NAME command.
- Define a subnet that will be used to assign IP addresses to hosts with the network SUBNET SUBNET_MASK command.
- Define the default gateway with the default-router IP command.
- Define the DNS server with the dns-server IP address command.
- (Optional) Define the DNS domain name by using the ip domain-name NAME command.
- (Optional) Define the lease duration by using the lease DAYS HOURS MINUTES command. If you don’t specify this argument, the default lease time of 24 hours will be used.
Here is an example configuration:
Floor1(config)#ip dhcp excluded-address 192.168.0.1 192.168.0.50 Floor1(config)#ip dhcp pool Floor1DHCP Floor1(dhcp-config)#network 192.168.0.0 255.255.255.0 Floor1(dhcp-config)#default-router 192.168.0.1 Floor1(dhcp-config)#dns-server 192.168.0.1
In the example above you can see that I’ve configured the DHCP server with the following parameters:
- the IP addresses from the 192.168.0.1 – 192.168.0.50 range will not be assigned to hosts
- the DHCP pool was created and named Floor1DHCP
- the IP addresses assigned to the hosts will be from the 192.168.0.0/24 range
- the default gateway’s IP address is 192.168.0.1
- the DNS server’s IP address is 192.168.0.1
To view information about the currently leased addresses, you can use the show ip dhcp binding command:
Floor1#show ip dhcp binding IP address Client-ID/ Lease expiration Type Hardware address 192.168.0.51 0060.5C2B.3DCC -- Automatic
In the output above you can see that there is a single DHCP client that was assigned the IP address of 192.168.0.51. Since we’ve excluded the IP addresses from the 192.168.0.1 – 192.168.0.50 range, the device got the first address available – 192.168.0.51. To display information about the configured DHCP pools, you can use the show ip dhcp pool command:
Floor1#show ip dhcp pool Pool Floor1DHCP : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 254 Leased addresses : 1 Excluded addresses : 1 Pending event : none 1 subnet is currently in the pool Current index IP address range Leased/Excluded/Total 192.168.0.1 192.168.0.1 - 192.168.0.254 1 / 1 / 254
This command displays some important information about the DHCP pool(s) configured on the device – the pool name, total number of IP addresses, the number of leased and excluded addresses, subnet’s IP range, etc. Download our Free CCNA Study Guide PDF for complete notes on all the CCNA 200-301 exam topics in one book. We recommend the Cisco CCNA Gold Bootcamp as your main CCNA training course. It’s the highest rated Cisco course online with an average rating of 4.8 from over 30,000 public reviews and is the gold standard in CCNA training:
Table of contents
- Table of contents
- Prerequisites
- Terminologies
- Steps in Configuring Cisco IOS DHCPv4 Server
- Step 1. Router Configurations
- Step 2. Create a DHCP server pool
- Step 3. Exclude IP addresses
- DHCP Server Verification
- DHCP Server Router Testing
- Conclusion
Prerequisites
The reader must put the following into consideration:
- The reader should know basic networking concepts.
- Good understanding of how to configure networks using any of the network simulation tools.
This article suits a reader who wants to know how to work with the Cisco packet tracer network simulator tool.
To download and install the Cisco packet tracer on a desktop or laptop, visit this link.
Terminologies
DHCP Server
is a network server used for leasing IPv4 addresses dynamically to hosts on extensive networks, reducing the burden on the network staff and virtually eliminating entry errors. It relies on the Dynamic Host Configuration Protocol (DHCP) to respond to broadcast queries from the DHCP clients.DHCP Clients
— These are the hosts/devices on the network that get the IP Addresses from the server through the DHCP protocol.Excluded IP Addresses
— These are addressing specifically reserved to the key hosts like the default gateways, DNS-server. Excluding some of the IP addresses prevents the situation where the DHCP clients are assigned an IP address that is already in use by the other key hosts on the network, preventing IP address duplication.DHCP POOL
— DHCP pools act as a built-in server on the network subnets in which they assign the clients the addresses. The pools can support up to 2048 addresses.
Steps in Configuring Cisco IOS DHCPv4 Server
Consider the local network connection below.
Step 1. Router Configurations.
We configure the routers to be used as the DHCP server by statically assigning the IPv4 addresses to their various interfaces.
Router>en Router#config terminal Router(config)#hostname R1 !changing our hostname R1(config)#interface g0/0 !specifying which interface to assign ip address R1(config-if)#ip address 10.0.0.1 255.0.0.0 !assigning ip address to interface g0/0 R1(config-if)#no shutdown !activating the interface R1(config-if)#exit R1(config)#interface g0/1 R1(config-if)#ip address 192.168.1.100 255.255.255.0 R1(config-if)#no shutdown R1(config-if)# R1(config-if)#exit R1(config)#do write
Router>en Router#config terminal Router(config)#hostname R2 R2(config)#interface g0/0 R2(config-if)#ip address 10.0.0.2 255.0.0.0 R2(config-if)#no shutdown R2(config-if)#exit R2(config)#interface g0/1 R2(config-if)#ip address 193.168.2.1 255.255.255.0 R2(config-if)#no shutdown R2(config-if)#do write Building configuration...
We now configured the interfaces with IP addresses both on R1 and R2.
R1#show ip interface brief !shows interface status Interface IP-Address OK? Method Status Protocol GigabitEthernet0/0 10.0.0.1 YES manual up up GigabitEthernet0/1 192.168.1.100 YES manual up up Vlan1 unassigned YES unset administratively down down R2#show ip interface brief Interface IP-Address OK? Method Status Protocol GigabitEthernet0/0 10.0.0.2 YES manual up up GigabitEthernet0/1 193.168.2.1 YES manual up up Vlan1 unassigned YES unset administratively down down
Step 2. Create a DHCP server pool
Use of ip dhcp pool
command followed by the pool name creates two pools POOL-A on router R1 and POOL-2 on router R2. This includes configuring the network addresses, default gateway, and the IP address of the DNS server.
Enter configuration commands, one per line. End with CNTL/Z. R1(config)#ip dhcp pool POOL-A !pool creation R1(dhcp-config)#? !get more details about pools default-router Default routers dns-server Set name server domain-name Domain name exit Exit from DHCP pool configuration mode network Network number and mask no Negate a command or set its defaults option Raw DHCP options R1(dhcp-config)#default-router 192.168.1.100 !ip address of default router R1(dhcp-config)#dns-server 192.168.1.50 !ip address of dns-server R1(dhcp-config)#network 192.168.1.0 255.255.255.0 !ip address of the default gateway/network R1(dhcp-config)#exit R1(config)# R1(config)#do write !saving the configurations Building configuration... [OK]
R2(config)# R2(config)#ip dhcp pool POOL-B R2(dhcp-config)#? default-router Default routers dns-server Set name server domain-name Domain name exit Exit from DHCP pool configuration mode network Network number and mask no Negate a command or set its defaults option Raw DHCP options R2(dhcp-config)#default-router 192.168.2.100 R2(dhcp-config)#network 192.168.2.0 255.255.255.0 R2(dhcp-config)#dns-server 192.168.2.50 R2(dhcp-config)#exit R2(config)#do write Building configuration...
Step 3. Exclude IP addresses
In our network, we must exclude the IP addresses on the R1 and R2 interfaces, together with the other 9 addresses to be used for static assignment to other devices like servers and device management interfaces.
R1(config)#ip dhcp excluded-address 192.168.1.100 R1(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.10 R1(config)#ip dhcp excluded-address 192.168.1.50 R1(config)#do write
R2(config)# R2(config)#ip dhcp excluded-address 192.168.2.100 R2(config)#ip dhcp excluded-address 192.168.2.1 192.168.2.10 R2(config)#ip dhcp excluded-address 192.168.2.50 R2(config)#exit
DHCP Server Verification
To confirm that our DHCP server is configured on the two routers, show running-config | section DHCP
command is used. The output is as shown below, which confirms the routers can now perform the functionalities of assigning IP addresses dynamically to the network clients.
R2#show running-config | section dhcp ip dhcp excluded-address 192.168.2.100 ip dhcp excluded-address 192.168.2.1 192.168.2.10 ip dhcp excluded-address 192.168.2.50 ip dhcp pool POOL-B network 192.168.2.0 255.255.255.0 default-router 192.168.2.100 dns-server 192.168.2.50
NOTE: The dhcp server can be disabled using
no service dhcp
command and re-enabled usingservice dhcp
command in the global configuration mode.
DHCP Server Router Testing
Once we have confirmed the routers have now configured to act as DHCP servers, we can test their functionalities by trying to assign Ip addresses to the clients. From our network, we have 4 PCs acting as the clients. Before the configurations, the router configured as the DHCP server could not assign the PCs the address dynamically, the DHCP failed as shown. After the configuration, we’ll try again to assign each client an IP address by selecting the DHCP option on the IP configuration interface window. The DHCP works successfully. This shows our routers are now DHCP enabled.
We can also try to test the communication between two clients on the same subnet using the
ping
command. Our network, PC5 can communicate with PC4 using the assigned IP addresses as shown.
NOTE: From the IP addresses assigned it is evident that the DHCP server assigned addresses from .11 excluding the IP addresses from .1 to .10 and .50 which were among the excluded addresses.
Conclusion
As we have seen, network routers can save the organization the cost of buying dedicated servers by providing the DHCP server functionality when configured properly. This information is crucial and will equip the learner with the knowledge of how to configure the routers to eliminate the burden of statically assigning IP addresses. To summarize:
- We learned what a DHCP server is.
- We explored how to use a router to act as a DHCP server.
- We configured a network, verified and configured the routers to perform the DHCP server functions.
- We learned how to enable and disable the DHCP server on the network.
One can find more information about DHCP-router configuration here. Happy coding. Peer Review Contributions by: Collins Ayuya
- How to see who is following you on facebook
- How to always win an argument
- How to what does scheduled delivery pending mean
- How to invite someone on skype
- How to block websites in google chrome