This tutorial is about configuring a Cisco Router to serve as a DHCP server for client computers.
1. create the DHCP pool that defines the network of IP addresses that will be given out to the clients. Note that 'NET-POOL' is the name of the DHCP IP Pool we are creating: Router(config)#ip dhcp pool NET-POOL
Router(dhcp-config)#network 192.168.1.0 255.255.255.0 Network address to be used by the DHCP pool
2. Configure the parameters to be sent to the client,
Router(dhcp-config)#dns-server 192.168.1.5 195.170.0.1
To provide the DNS server IP address
Router(dhcp-config)#default-router 192.168.1.1
To provide the IP address of the default gateway
Router(dhcp-config)#domain-name NAME
To provide the name of the domain of the network (if in a domain environment)
Router(dhcp-config)#netbios-name-server 192.168.1.10
To provide the IP address of the NetBIOS name server
Router(dhcp-config)#lease DAYS HOURS MINUTES To define the lease time of the addresses given to the client. You can make it infinite by using this command instead; lease infinite
3. Configure the IP addresses to be excluded from the pool. This is usually done to avoid the conflicts caused by the DHCP with servers and printers. Remember to give ALL servers and network printers static IP addresses in the same range of the DHCP pool. And then exclude these addresses from the pool to avoid conflicts.
Router(config)#ip dhcp excluded-address 192.168.1.1
Above command will exclude a single address. You can repeat it as much as you see fit for the IP addresses you want to exclude.
Router(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.10
where 1st IP to 2nd IP to be excluded from the pool
This way you can exclude a range or ranges of IP addresses and reserve them for static addresses use.
4. Enable the DHCP service in the router
Router(config)#service dhcp
Usually the DHCP service is enabled by default on your router.
5. Use the following commands to check the DHCP operation on the router:
Router#show ip dhcp binding
This command shows the current bindings of addresses given to clients
Router#show ip dhcp server statistics
This command show the DHCP server statistics.
Router#debug ip dhcp server
This debug command is used to troubleshoot DHCP issues.
Implementation notes:
1. If you have a DHCP server other than the router, and you would like to let the router to forward the DHCP requests from a certain LAN to the DHCP server laying outside that LAN, go to the Ethernet interface that does not have the DHCP server and type the following command:
Router(config-if)#ip helper-address 10.10.10.10
where the IP address of the server laying outside this LAN.
2. You can create a DHCP database agent that stores the DHCP binding database. A DHCP database agent is any host, for example, an FTP, TFTP, or RCP server that stores the DHCP bindings database. You can configure multiple DHCP database agents and you can configure the interval between database updates and transfers for each agent. To configure a database agent and database agent parameters, use the following command in global configuration mode:
Router(config)#ip dhcp database url [timeout seconds | write-delay seconds]
An example url is this
ftp://user:password @ 192.168.0.3/router-dhcp (remove the spaces before implementing)
If you choose not to configure a DHCP database agent, disable the recording of DHCP address conflicts on the DHCP server. To disable DHCP address conflict logging, use the following command in global configuration mode:
Router(config)#no ip dhcp conflict logging
DHCP service uses port 67 and 68. So, if you are using a firewall, remember to open these ports.
To clear DHCP server variables, use the following commands as needed:
Router#clear ip dhcp binding *
If you want to clear a certain binding not all of them, replace the * in the previous command with the IP address to be cleared.
1. create the DHCP pool that defines the network of IP addresses that will be given out to the clients. Note that 'NET-POOL' is the name of the DHCP IP Pool we are creating:
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)# host address [mask | /prefix-length]
Specifies the IP address and subnet mask of the client.
The prefix length specifies the number of bits that comprise the
address prefix. The prefix is an alternative way of specifying the
network mask of the client. The prefix length must be preceded by a
forward slash (/).
Router(dhcp-config)# client-identifier unique-identifier
Specifies the unique identifier for DHCP clients. This command is used for DHCP requests.
DHCP clients require client identifiers. The unique identification of the client is specified in dotted hexadecimal notation, for example, 01b7.0813.8811.66, where 01 represents the Ethernet media type.
Router(dhcp-config)#dns-server 192.168.1.5 195.170.0.1
To provide the DNS server IP address
Router(dhcp-config)#default-router 192.168.1.1
To provide the IP address of the default gateway
Router(dhcp-config)#domain-name NAME
To provide the name of the domain of the network (if in a domain environment)
Router(dhcp-config)#netbios-name-server 192.168.1.10
To provide the IP address of the NetBIOS name server
Router(dhcp-config)#lease DAYS HOURS MINUTES
3. Configure the IP addresses to be excluded from the pool. This is usually done to avoid the conflicts caused by the DHCP with servers and printers. Remember to give ALL servers and network printers static IP addresses in the same range of the DHCP pool. And then exclude these addresses from the pool to avoid conflicts.
Router(config)#ip dhcp excluded-address 192.168.1.1
Above command will exclude a single address. You can repeat it as much as you see fit for the IP addresses you want to exclude.
where 1st IP to 2nd IP to be excluded from the pool
This way you can exclude a range or ranges of IP addresses and reserve them for static addresses use.
4. Enable the DHCP service in the router
Router(config)#service dhcp
Usually the DHCP service is enabled by default on your router.
5. Use the following commands to check the DHCP operation on the router:
Router#show ip dhcp binding
This command shows the current bindings of addresses given to clients
Router#show ip dhcp server statistics
This command show the DHCP server statistics.
Router#debug ip dhcp server
This debug command is used to troubleshoot DHCP issues.
Implementation notes:
1. If you have a DHCP server other than the router, and you would like to let the router to forward the DHCP requests from a certain LAN to the DHCP server laying outside that LAN, go to the Ethernet interface that does not have the DHCP server and type the following command:
Router(config-if)#ip helper-address 10.10.10.10
where the IP address of the server laying outside this LAN.
2. You can create a DHCP database agent that stores the DHCP binding database. A DHCP database agent is any host, for example, an FTP, TFTP, or RCP server that stores the DHCP bindings database. You can configure multiple DHCP database agents and you can configure the interval between database updates and transfers for each agent. To configure a database agent and database agent parameters, use the following command in global configuration mode:
Router(config)#ip dhcp database url [timeout seconds | write-delay seconds]
An example url is this
ftp://user:password @ 192.168.0.3/router-dhcp (remove the spaces before implementing)
If you choose not to configure a DHCP database agent, disable the recording of DHCP address conflicts on the DHCP server. To disable DHCP address conflict logging, use the following command in global configuration mode:
Router(config)#no ip dhcp conflict logging
To clear DHCP server variables, use the following commands as needed:
Router#clear ip dhcp binding *
If you want to clear a certain binding not all of them, replace the * in the previous command with the IP address to be cleared.