Configure DHCP Server on Cisco Devices

DHCP is widely used in LAN environments to dynamically assign host IP addresses from a centralized server, thereby significantly reducing the overhead of IP address management. DHCP also helps conserve limited IP address space because IP addresses no longer need to be permanently assigned to hosts, and only hosts connected to the network use IP addresses. A DHCP server assigns and manages DHCP clients with IP addresses from a router or a specified address pool on a router.

In this article, learn how to configure a Cisco router as a DHCP server using the CLI and how to update it on multiple devices at the same time using the configlet in the NCM application.

Steps to configure DHCP server via CLI

1. Log in to the device using SSH/TELNET and go to enable mode.

2. Enter configuration mode.

  • Router#configure terminal
  • Enter configuration commands, one per line. Ends with CNTL/Z.
  • Router(config)#

3. Exclude IP address by using IP DHCP Exclude Address FIRST_IP LAST_IP Router (Configuration) #ip

  • Router(config)#ip dhcp excluded-address 192.168.0.1 192.168.0.50
  • Router(config)#

4. Use the command ip dhcp pool NAME

  • Router(config)#ip dhcp pool Floor1DHCP
  • Router(dhcp-config)#

5. Define a subnet that will be used to assign IP addresses to hosts using the network SUBNET SUBNET_MASK command.

  • Router(dhcp-config)#network 192.168.0.0 255.255.255.0
  • Router(dhcp-config)#

6. Use the default router IP command.

  • Router(dhcp-config)#default-router 192.168.0.1
  • Router(dhcp-config)#

7. Use the dns server IP address command to define the DNS server.

  • Router(dhcp-config)#dns-server 192.168.0.1
  • Router(dhcp-config)#

8. Return to the permission configuration mode

  • Router(dhcp-config)#exit
  • Router(config)#

9. Use the service dhcp interface type number command

  • Router(config)#service dhcp vlan1
  • Router(config)#

10. Exit configuration mode

  • Router(config)#exit
  • Router#

11. To view information about the current leased address, you can use the show ip dhcp bind command

  • Router#show ip dhcp binding
  • IP address Client-ID/ Lease expiration Type
  • Hardware address
  • 192.168.0.51 0060.5C2B.3DCC – Automatic

In the above output, the administrator can see that there is a DHCP client assigned IP address 192.168.0.51. Since the IP address has been excluded from the 192.168.0.1 – 192.168.0.50 range, the device gets the first available address – 192.168.0.51.

12. To query the configured DHCP pool information, use the show ip DHCP pool command. use case

  • 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 : none

This command displays some important information about the DHCP pool configured on the device, including the pool name, the total number of IP addresses, the number of leased addresses and excluded addresses, the IP range of the subnet, and so on.

13. Copy the running configuration to the startup configuration using the following command

  • Router#write memory
  • Building configuration… [OK]
  • Router#

The corresponding configuration can be created in the NCM application ( Network Configuration Manager ), as shown in the screenshot below.

insert image description here

The Configlet can also be downloaded as XML and imported into the NCM application using the file import option.

configuration name Configure DHCP server
describe How to configure a Cisco router as a DHCP server using the CLI and how to update multiple devices simultaneously in the NCM application using configlets.
execution mode script execution mode
configuration file 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

Guess you like

Origin blog.csdn.net/ITmoster/article/details/132410416