How to configure DHCP on a Cisco Router
I prefer running DHCP on a server within the network, but if it comes to it you do have the option of configuring DHCP on a Cisco router. I do believe some of the newer Cisco Catalyst switches have this ability too.
We are going to assume you have a Cisco router already setup and in service on your network.
First thing you will want to do is login to your router and go into config mode. Once in config mode you will want to setup a DHCP pool.
Router(config)# ip dhcp pool newpool
You can replace ‘newpool’ with whatever you choose to name your DHCP pool. Next thing we want to do is tell the router the network and subnet.
Router(dhcp-config)# network x.x.x.x y.y.y.y
Replace x.x.x.x with the network address and y.y.y.y with the subnet mask. Next we will tell the router what DNS domain name the clients will use.
Router(dhcp-config)# domain-name domain.com
Obviously, you will replace ‘domain.com’ with your domain. Now we need to tell the router the primary and secondary DNS server IP addresses to be used in the DHCP scope.
Router(dhcp-config)# dns-server 1.1.1.1 2.2.2.2
Replace 1.1.1.1 with your primary DNS server and 2.2.2.2 with your secondary DNS server. We need to specify the default gateway or router.
Router(dhcp-config)# default-router x.x.x.x
Replace x.x.x.x with your default gateway or router IP address. Next we want to specify the length of the lease of the addresses assigned by the DHCP server.
Router(dhcp-config)# lease 7
Here I have set the lease time to expire in 7 days. Alternatively, you can use the syntax ‘lease DAYS HOURS MINUTES’, replacing those variables with the obvious requirements. You can even go as far as setting it for an infinite perios of time using ‘lease infinite’.
This pretty much sums up setting up DHCP on a Cisco router with IOS. I do want to show you one more thing. Suppose you want to exclude some IP address that you want to reserve for static devices. The following command needs to be performed in the the global configuration mode, so type ‘exit’ and perform the following if you are still at the last step.
Router(config)# ip dhcp excluded-address x.x.x.x y.y.y.y
You will want to replace y.y.y.y with the start address of the range you want to exclude and replace y.y.y.y with the end address. Example: ‘ip dhcp excluded-address 192.168.100.0 192.168.100.100. This will exclude addresses all the way up to 192.168.100.100. Therefore, DHCP will start assigning IP address leases at 192.168.100.101.
Now that we have setup our DHCP scope we can enable to DHCP service.
Router(config)# service dhcp
Now you should be able to grab an IP address via DHCP. Don’t forget to save your configuration.