Dynamic Host Configuration Protocol (DHCP) is a network management protocol used to automate the process of configuring devices on IP networks, thus allowing them to use network services such as DNS, NTP, and any communication protocol based on UDP or TCP. A DHCP server dynamically assigns an IP address and other network configuration parameters to each device on a network so they can communicate with other IP networks.
Enabling DHCP Server:
Beginning in privileged EXEC mode, follow these steps to enable the DHCP server on the router:
Command | Purpose |
---|---|
configure terminal | Enter global configuration mode. |
service dhcp interface-type number | Enable the DHCP server on the interface. |
exit | Return to privileged EXEC mode. |
show running-config | Verify your entries. |
copy running-config startup-config | (Optional) Save your entries in the configuration file. |
Note: To disable the DHCP server, use the no service dhcp global configuration command.
Configuring DHCP Server:
Beginning in privileged EXEC mode, follow these steps to configure the DHCP server.
Command | Purpose |
---|---|
configure terminal | Enter global configuration mode. |
ip dhcp pool | Create a DHCP server address pool and enters DHCP pool configuration mode. Note: If you have changed the parameters of the DHCP server, you must perform a refresh using the no service dhcp interface-type number command and service dhcp interface-type number commands. |
network network-number mask | Specify the subnet network number and mask of the DHCP address pool. |
domain-name domain | Specify the domain name for the client. |
dns-server address | Specify the IP address of a DNS server that is available to a DHCP client. |
default-router address | Specify the IP address of the default router for a DHCP client. |
exit | Return to privileged EXEC mode. |
service dhcp interface-type number | Enable DHCP server on the interface. |
The following example configures the DHCP server:
Router# configure terminal
Router(config)# ip dhcp included-address 192.168.1.101 192.168.1.150
Router(config)# ip dhcp pool
Router(dhcp-config)# network 192.168.1.0 255.255.255.0
Router(dhcp-config)# domain-name cisco.com
Router(dhcp-config)# dns-server 8.8.8.8
Router(dhcp-config)# default-router 192.168.1.1
Router(dhcp-config)# exit
Router(config)# service dhcp vlan1