Setting Cisco Router as DHCP Server
This option really is optional if you want to set Cisco router to work with cable internet, but this is a good chance to add your skill in configuring Cisco devices.
From the previous post, you know how to configure your router's interface to accept IP address from DHCP server.
Now it's time to configure your router as DHCP server.
Once again you need to make sure your Router IOS image support the DHCP server feature if not then the command won't be available.
To set a DHCP server, you will configure a pool of network IP addresses that you want to give out to the clients (PC, printer, NAS, etc).
As shown on the image in the previous post, I want to give out the IP addresses from the network 192.168.1.0.
First thing you need to configure is to exclude the IP addresses that you dont want to give out.
For example, I've configured the router interface 0/1 to be 192.168.1.1, then I need to exclude 192.168.1.1 so the router won't give out this address.
You can configure the exclusion in the router's global configuration mode:
router> enable
router# configure terminal
router (config)# ip dhcp excluded-address 192.168.1.1
This command is very useful especially if you need to exclude a range of IP addresses, if you need to exclude say 192.168.1.1 until 192.168.1.10 you can do it like this:
router (config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
After the ip dhcp excluded-address we give the low IP address and the high IP address, this way your router not give IP addresses from 192.168.1.1 to 192.168.1.10, the router will start giving out address from 192.168.1.11 and so on.
Next thing to do is creating a pool of addresses, when issuing the ip dhcp pool, you'll be taken to the dhcp configuration mode where you can set the additional parameters beside the ip address and subnet mask to the clients.
In this example I want to make a pool with the name of HOME_CLIENTS
router> enable
router# configure terminal
router (config)# ip dhcp pool HOME_CLIENTS
router (dhcp-config)# network 192.168.1.0 255.255.255.0
router (dhcp-config)# default-router 192.168.1.1
router (dhcp-config)# import all
At the third line above you can see the configuration command of a pool with the name HOME_CLIENTS.
Fourth line shows that the pool HOME_CLIENTS will give out the addresses in the network 192.168.1.0, with the exception of the addresses in the ip dhcp excluded-address 192.168.1.1 that I showed you previously.
Fifth line tells the clients should be given a default gateway address of 192.168.1.1 (the router's IP address).
The sixth line is the one important thing for configuring DHCP server in cable internet environment.
The import all command tells the router to give out other configuration received from the ISP cable internet DHCP server to the clients in the LAN.
For example, most ISP will give the DNS servers IP addresses from their DHCP server and this configuration might change depends on the ISP, so you definitely want to give this configuration out to the clients.
If you have your own DNS server in the LAN, you can tell the clients to use this DNS server using the following command:
router (dhcp-config)# dns-server 192.168.1.2 192.168.1.3
The above command will send out DNS server address of 192.168.1.2 and 192.168.1.3 to the clients.
You can also configure the router to use the above DNS server using the following command in the global configuration mode:
router (config)# ip name-server 192.168.1.2 192.168.1.3
You can get more information on Cisco IOS DHCP and DNS commands in the cisco site, please click here to go there.
Please read also:
Configure Cisco Router to Work With Cable Internet - Part 1
Configure Cisco Router to Work With Cable Internet - Part 2
Configure Cisco Router to Work With Cable Internet - Part 4
This option really is optional if you want to set Cisco router to work with cable internet, but this is a good chance to add your skill in configuring Cisco devices.
From the previous post, you know how to configure your router's interface to accept IP address from DHCP server.
Now it's time to configure your router as DHCP server.
Once again you need to make sure your Router IOS image support the DHCP server feature if not then the command won't be available.
To set a DHCP server, you will configure a pool of network IP addresses that you want to give out to the clients (PC, printer, NAS, etc).
As shown on the image in the previous post, I want to give out the IP addresses from the network 192.168.1.0.
First thing you need to configure is to exclude the IP addresses that you dont want to give out.
For example, I've configured the router interface 0/1 to be 192.168.1.1, then I need to exclude 192.168.1.1 so the router won't give out this address.
You can configure the exclusion in the router's global configuration mode:
router> enable
router# configure terminal
router (config)# ip dhcp excluded-address 192.168.1.1
This command is very useful especially if you need to exclude a range of IP addresses, if you need to exclude say 192.168.1.1 until 192.168.1.10 you can do it like this:
router (config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
After the ip dhcp excluded-address we give the low IP address and the high IP address, this way your router not give IP addresses from 192.168.1.1 to 192.168.1.10, the router will start giving out address from 192.168.1.11 and so on.
Next thing to do is creating a pool of addresses, when issuing the ip dhcp pool, you'll be taken to the dhcp configuration mode where you can set the additional parameters beside the ip address and subnet mask to the clients.
In this example I want to make a pool with the name of HOME_CLIENTS
router> enable
router# configure terminal
router (config)# ip dhcp pool HOME_CLIENTS
router (dhcp-config)# network 192.168.1.0 255.255.255.0
router (dhcp-config)# default-router 192.168.1.1
router (dhcp-config)# import all
At the third line above you can see the configuration command of a pool with the name HOME_CLIENTS.
Fourth line shows that the pool HOME_CLIENTS will give out the addresses in the network 192.168.1.0, with the exception of the addresses in the ip dhcp excluded-address 192.168.1.1 that I showed you previously.
Fifth line tells the clients should be given a default gateway address of 192.168.1.1 (the router's IP address).
The sixth line is the one important thing for configuring DHCP server in cable internet environment.
The import all command tells the router to give out other configuration received from the ISP cable internet DHCP server to the clients in the LAN.
For example, most ISP will give the DNS servers IP addresses from their DHCP server and this configuration might change depends on the ISP, so you definitely want to give this configuration out to the clients.
If you have your own DNS server in the LAN, you can tell the clients to use this DNS server using the following command:
router (dhcp-config)# dns-server 192.168.1.2 192.168.1.3
The above command will send out DNS server address of 192.168.1.2 and 192.168.1.3 to the clients.
You can also configure the router to use the above DNS server using the following command in the global configuration mode:
router (config)# ip name-server 192.168.1.2 192.168.1.3
You can get more information on Cisco IOS DHCP and DNS commands in the cisco site, please click here to go there.
Please read also:
Configure Cisco Router to Work With Cable Internet - Part 1
Configure Cisco Router to Work With Cable Internet - Part 2
Configure Cisco Router to Work With Cable Internet - Part 4