4.6 Configure and verify DHCP client and relay

CCNA 200-301 v1.1 · 4.0 IP Services

DHCP gives hosts an address, mask, default gateway and DNS servers automatically, in four messages: Discover, Offer, Request, Acknowledge. The Discover is a broadcast, so it never leaves its VLAN: a DHCP relay (ip helper-address) on the gateway forwards it to a server in another subnet. For the CCNA you configure a router as a DHCP client, as a relay, and read the bindings on the server.

What you must know

How a host gets an address

  1. Discover: the client broadcasts from 0.0.0.0 to 255.255.255.255, UDP 68 to 67.
  2. Offer: a server proposes an address and options.
  3. Request: the client asks for the offered address (still a broadcast, so other servers learn their offer was not taken).
  4. Acknowledge: the server confirms the lease. The client checks the address is free and starts using it.

Leases expire. The client tries to renew at half of the lease time, directly with its server.

DHCP client

A router can take its own address from DHCP, typically on the interface facing an ISP. A default route can come with it.

interface GigabitEthernet0/0
 ip address dhcp
 no shutdown
!
R1# show dhcp lease

DHCP relay

A broadcast stops at the router. On the gateway interface of the clients' VLAN, ip helper-address catches the Discover and sends it as a unicast to the server (1). The relay writes its own interface address in the giaddr field, and the server uses that address to choose the right pool for the clients' subnet.

interface Vlan10
 ip address 10.1.10.1 255.255.255.0
 ip helper-address 10.0.50.5

A basic IOS DHCP server

ip dhcp excluded-address 10.1.10.1 10.1.10.20
!
ip dhcp pool VLAN10
 network 10.1.10.0 255.255.255.0
 default-router 10.1.10.1
 dns-server 10.0.50.53
 lease 7

On the hosts, check the result with ipconfig /all (Windows), ipconfig getpacket en0 (macOS) or ip address (Linux). ipconfig /release and /renew force a new exchange.

Commands

show ip dhcp bindingThe leases the server has given: address, MAC (client ID) and expiry.
show ip dhcp poolEach pool's range, how many addresses are leased and the next one to hand out.
show ip dhcp conflictAddresses the server found already in use (by ping or gratuitous ARP).
show ip interface Vlan10Includes the helper address configured on the interface.
show dhcp leaseOn a router that is a DHCP client: its lease.

Exam traps

Check yourself

Put the four DHCP messages in order.
Discover, Offer, Request, Acknowledge (DORA).
Clients in VLAN 20 get no address; the server is in another subnet. What is missing?
ip helper-address <server> on the VLAN 20 gateway interface (the SVI or subinterface).
How does the server know which pool to use for a relayed request?
From the giaddr field, which the relay fills with the address of the interface that received the broadcast.
Which command makes R1 take its outside address from the ISP?
ip address dhcp on that interface.

Labs

Try it live: PAT, DHCP server and NTP

More topics in 4.0 IP Services