386 Chapter 13: Dynamic Host Control Protocol
DHCP Roles
There are at least two devices involved in any DHCP setup—a DHCP server and a DHCP
client. There are often additional devices in the network between the client and server, called
DHCP relays. The following sections describe the function and configuration of each of
these DHCP roles.
Acting as a DHCP Server
The following steps configure an IOS device as a DHCP server:
Step 1 Create a pool of addresses to assign to clients. The syntax for this command is
Router(config)# ip dhcp pool
name
Step 2 Assign a network to the pool:
Router(config-dhcp)# network
network/mask
Step 3 Tell the client how long it can keep the address—this is called the lease
period. Most DHCP implementations use a three-day lease, but IOS
defaults to one day:
Router(config-dhcp)# lease
days
Step 4 Identify the DNS server:
Router(config-dhcp)# dns-server
address
Step 5 Finally, identify the default gateway:
Router(config-dhcp)# default-router
ip-address
NOTE Many client operating systems use something called Automatic Private IP Addressing.
This process assigns an IP address, even in the absence of a DHCP server. If a DISCOVER
message is not answered, the client picks a random 16-bit number and prepends it with 169.254.
It performs a gratuitous ARP and assigns that address to itself.
The idea of Automatic Private IP Addressing is that two travelers could link their devices
quickly and easily. For instance, two train commuters could play a game on the way to the city.
They configure DHCP on their laptops and use Automatic Private IP Addressing on the train and
get a different IP in the office.
If you see a 169.254.x.x address, it means that the DHCP server is not reachable. The PC will
not work because there is not a router to or from that IP. Troubleshoot this by finding out
why the PC cannot see the DHCP server.
DHCP Roles 387
Addresses are always assigned on the interface that has an IP address in the same subnet as the
pool. Example 13-1 shows this configuration in context.
Some IOS devices receive an IP address on one interface and assign IP addresses on another. In
these instances, DHCP may import the options and parameters from one interface and pass
them to the other interface. The command to do so is
Router(config-dhcp)# ii
ii
mm
mm
pp
pp
oo
oo
rr
rr
tt
tt
aa
aa
ll
ll
ll
ll
Using import all can reduce the headache of setting up DHCP in remote offices. The router, once
it is onsite, can determine the local DNS and options.
There are a variety of commands to manage an IOS DHCP server. The additional commands are
listed in Table 13-2.
Acting as a DHCP Relay
Normally, routers do not forward broadcast. There are a few times when an exception to this rule
would be useful. IP assignment, for instance, would be easier if you did not have to deploy a
DHCP server on every segment. If routers passed broadcasts, a central server could take care of
remote locations.
Example 13-1 DHCP
Router(config)# ii
ii
nn
nn
tt
tt
ee
ee
rr
rr
ff
ff
aa
aa
cc
cc
ee
ee
ff
ff
aa
aa
ss
ss
tt
tt
ee
ee
tt
tt
hh
hh
ee
ee
rr
rr
nn
nn
ee
ee
tt
tt
00
00
//
//
11
11
Router(config-if)# ii
ii
pp
pp
aa
aa
dd
dd
dd
dd
rr
rr
ee
ee
ss
ss
ss
ss
11
11
77
77
22
22
..
..
11
11
66
66
..
..
11
11
..
..
11
11
22
22
55
55
55
55
..
..
22
22
55
55
55
55
..
..
22
22
55
55
55
55
..
..
00
00
Router(config)# ii
ii
pp
pp
dd
dd
hh
hh
cc
cc
pp
pp
pp
pp
oo
oo
oo
oo
ll
ll
11
11
Router(config-dhcp)# nn
nn
ee
ee
tt
tt
ww
ww
oo
oo
rr
rr
kk
kk
11
11
77
77
22
22
..
..
11
11
66
66
..
..
11
11
..
..
00
00
//
//
22
22
44
44
Router(config-dhcp)# dd
dd
ee
ee
ff
ff
aa
aa
uu
uu
ll
ll
tt
tt
--
--
rr
rr
oo
oo
uu
uu
tt
tt
ee
ee
rr
rr
11
11
77
77
22
22
..
..
11
11
66
66
..
..
11
11
..
..
11
11
Router(config-dhcp)# ll
ll
ee
ee
aa
aa
ss
ss
ee
ee
33
33
Router(config-dhcp)# dd
dd
nn
nn
ss
ss
--
--
ss
ss
ee
ee
rr
rr
vv
vv
ee
ee
rr
rr
11
11
77
77
22
22
..
..
11
11
66
66
..
..
77
77
77
77
..
..
11
11
00
00
00
00
Table 13-2 Descriptions of DHCP Server Commands
Command Description
service dhcp Enables DHCP server (on by default)
ip dhcp database Configures a database agent
no ip dhcp conflict logging Disables logging of conflicts
ip dhcp excluded-address start-ip end-ip Lists addresses that should be excluded from the pool
domain-name domain Default DNS assignment

Get CCNP BSCI Official Exam Certification Guide, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.