Configure DHCP on a Cisco Router
In this short tutorial let's configure a DHCP server on a Cisco Router. Why would we want to do that? Well configuring a basic DHCP server on a router is a good idea if this is a branch/satellite office or just a small business. There are some pros and cons of configuring DHCP on a Cisco Router so let's briefly discuss them and then start configuring.
Putting DHCP on a router is pretty easy and that's one advantage of setting up DHCP no need to setup a Linux or Windows server. However this also depends on what type of environment you are running, if the company has an Active Directory structure that can be a showstopper if you want have DHCP on the router. There can be a problems because while your domain controller controls DNS any PC that gets an address from DHCP that the router is handing out may not be updated in DNS. (Active Directory likes to have DNS that is current) There have been issues with Active Directory and the best solution is to setup the DHCP service on the Windows server and disable DHCP on the router.
That way both DNS and DHCP is automatically added/updated when a new PC joins the network. Along with way more functionality on the server side than the router side, like such as clustering and or load balancing DHCP servers if there is ever need. Although Cisco routers are great it's not designed for a clustering load balancing DHCP server. A router's main job is forwarding and routing data and although routers can have more than one job besides routing this also adds more load to the router if it already has big shoes to fill. ;)
So now let's begin learning how to configure DHCP, listed below is the current running-config on the router called Branch-1 in which we will configure DHCP on.
BRANCH-1#show run
Building configuration...
Current configuration : 1075 bytes
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
hostname BRANCH-1
boot-start-marker
boot-end-marker
no network-clock-participate aim 0
no network-clock-participate aim 1
no aaa new-model
ip subnet-zero
ip cef
ip ips po max-events 100
no ftp-server write-enable
interface FastEthernet0/0
ip address 192.168.40.1 255.255.255.0
duplex auto
speed auto
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
ip classless
no ip http server
no ip http secure-server
control-plane
line con 0
logging synchronous
line aux 0
line vty 0 4
login
scheduler allocate 20000 1000
end
- For this example we are going to be configuring a DHCP pool called DHCP-40-POOL.
- We are also going to be excluding address from this pool which will be 192.168.40.0 - 192.168.40.5
- In this example we don't have an internal DNS server so we will be using one of OpenDNS's servers. That IP address is 208.67.222.222. We will also configure a secondary DNS server, that IP address is 8.8.8.8 (Thanks Google)
- Finally are domain name for this example will be BRANCH1.ryansrealm.com/ciscoskills
Let's get connected to Branch-1 and verify you are in global configuration mode and type the following to create a DHCP pool. (This example is using DHCP-40-POOL)
BRANCH-1(config)#ip dhcp pool DHCP-40-POOL
BRANCH-1(dhcp-config)
BRANCH-1(dhcp-config)#?
DHCP pool configuration commands:
accounting Send Accounting Start/Stop messages
bootfile Boot file name
class Specify a DHCP class
client-identifier Client identifier
client-name Client name
default-router Default routers
dns-server DNS servers
domain-name Domain name
exit Exit from DHCP pool configuration mode
hardware-address Client hardware address
host Client IP address and mask
import Programmatically importing DHCP option parameters
lease Address lease time
netbios-name-server NetBIOS (WINS) name servers
netbios-node-type NetBIOS node type
network Network number and mask
next-server Next server in boot process
no Negate a command or set its defaults
option Raw DHCP options
origin Configure the origin of the pool
subnet Subnet allocation commands
update Dynamic updates
utilization Configure various utilization parameters
vrf Associate this pool with a VRF
BRANCH-1(dhcp-config)#network 192.168.40.0 255.255.255.0
BRANCH-1(dhcp-config)#default-router 192.168.40.1
BRANCH-1(dhcp-config)#domain-name BRANCH1.example.com
BRANCH-1(dhcp-config)#dns-server 208.67.222.222 8.8.8.8
BRANCH-1(dhcp-config)#exit
BRANCH-1(config)#ip dhcp excluded-address 192.168.40.0 192.168.40.5
BRANCH-1#show running-config
Building configuration...
Current configuration : 1083 bytes
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
hostname BRANCH-1
! -- OMITTED --
ip dhcp excluded-address 192.168.40.0 192.168.40.5
ip dhcp pool DHCP-40-POOL
network 192.168.40.0 255.255.255.0
dns-server 208.67.222.222 8.8.8.8
default-router 192.168.40.1
domain-name BRANCH1.example.com
! -- OMITTED --
Related articles
- Coping with Holiday Traffic - Secondary DHCP Subnets (ioshints.info)
- Top 10 Important command prompt's commands (andiwijaya.wordpress.com)
- Real World DNS Abuse: Finding Common Ground (blogs.cisco.com)
- Cisco IOS DHCP Server tip (diecarvi.wordpress.com)