Routelearn.net
Course menu

Course 12: IP Services on IOSLesson 1.2 (2 of 5 in this course)75 of 91 in the CCNA series

DHCP server and relay on IOS

Configuring a Cisco router as a DHCP server and as a relay agent with ip helper-address, and the router as a DHCP client.

Intermediate · 11 min read

DHCP (Dynamic Host Configuration Protocol) is a protocol that automatically leases IP settings, such as an address, subnet mask, default gateway and DNS servers, to clients. A Cisco router can act as a DHCP server, as a relay agent that forwards client broadcasts as unicast to a server on another subnet, or as a DHCP client on one of its interfaces.

In simple terms: DHCP hands out network settings so nobody has to type them on every device. A Cisco router can give out the settings itself, pass requests on to a server elsewhere, or ask for an address of its own.

A real-life situation

HQ is growing. Today 40 laptops on VLAN 10 need addresses, and typing them in by hand is not an option. Later, a central server (SRV1) at the server site should hand out addresses for every branch. You need R1 to do two jobs on Cisco IOS: first act as the DHCP server itself, then pass requests on to SRV1 as a relay agent. R1's internet link also gets its own address from the ISP by DHCP.

How DHCP works (the DORA exchange, leases, renewal) is covered in DHCP, which ends with a short Cisco lab. This lesson is the full IOS treatment.

What a Cisco router can do with DHCP

RoleWhat it meansKey command
ServerThe router keeps pools and leases addresses itself.ip dhcp pool
Relay agentThe router forwards client broadcasts as unicast to a server on another subnet.ip helper-address
ClientA router interface gets its own address from a DHCP server.ip address dhcp
Gi0/2 .2.1Gi0/0 .1192.168.10.0/24Gi0/1 .1.2 Gi0/010.0.12.0/30Gi0/1 .1192.168.20.0/24InternetNTP 198.51.100.10R1HQ edgeSW1mgmt 192.168.10.2PC1VLAN 10, DHCP clientR2server siteSRV1192.168.20.10
  1. 1. PC1 broadcasts a Discover. It reaches every device in VLAN 10, including R1's Gi0/0. The broadcast stops at R1.
  2. 2. Option A: R1 is the server. R1 has a pool for 192.168.10.0/24 and answers straight away.
  3. 3. Option B: R1 relays. With ip helper-address 192.168.20.10 on Gi0/0, R1 turns the broadcast into a unicast to SRV1, with giaddr 192.168.10.1.
  4. 4. R1 as a DHCP client. On Gi0/2, ip address dhcp lets the ISP give R1 its public address and a default route.

Why it works that way

A new client has no address and no idea where the server is, so it sends to the broadcast address 255.255.255.255. Routers never forward that broadcast to another subnet. So either the server must be on the same subnet as the client, or the router on that subnet must step in. That is all a relay agent is: the gateway catches the broadcast and sends it on, as a normal unicast packet, to a server it knows about.

The server also needs to know which subnet the client is on, to choose the right pool. When the router itself is the server, it uses the subnet of the interface the Discover arrived on. When it relays, it writes that interface's address into the giaddr (gateway IP address) field, and the server matches it against its pools.

How it works step by step (relay)

Step 1 of 8 · Discover
Relay across subnets · 192.168.10.0/24 → 192.168.20.0/24
PC1
VLAN 10, no address
R1 relay
Gi0/0 192.168.10.1
SRV1
192.168.20.10

1. Discover · Broadcast in VLAN 10 · UDP 68 → 67

Any DHCP server?

Tap this step's arrow for the details.

PC1 is configured
Address:
192.168.10.11/24
Gateway:
192.168.10.1
DNS:
192.168.20.53
DORA through a relay. The relay only changes how the messages travel, not what they say.

How to configure it on Cisco IOS

⚠️ Based on Cisco IOS / IOS XE documentation, not run on a lab device. Interface names vary by platform. The lab assumes routing between all subnets already works.

1. R1 as the DHCP server

ip dhcp excluded-address 192.168.10.1 192.168.10.10 ip dhcp excluded-address 192.168.10.200 192.168.10.254

Global configuration, before creating the pool. Addresses kept for the gateway, SW1 (192.168.10.2), printers and other static devices. Exclusions apply to all pools.

ip dhcp pool VLAN10 network 192.168.10.0 255.255.255.0 default-router 192.168.10.1 dns-server 192.168.20.53 198.51.100.53 domain-name hq.example.com lease 1 12

Pool configuration mode (the prompt becomes R1(dhcp-config)#). network can also take a prefix length: network 192.168.10.0 /24. lease is days, hours, minutes; the default is 1 day.

CommandWhat the client gets
networkAn address and mask from this subnet
default-routerIts default gateway (option 3)
dns-serverUp to 8 DNS servers (option 6)
domain-nameThe DNS suffix (option 15)
leaseHow long it may keep the address; lease infinite never expires
option 150 ip 192.168.20.10Optional: the TFTP server Cisco IP phones download their settings from

Before it offers an address, the router pings it (two pings by default). If something answers, it records a conflict and skips that address. The DHCP service is on by default; if someone disabled it, service dhcp turns it back on.

2. R1 as a relay to SRV1

Now the company moves DHCP to SRV1. Remove the pool from R1 (or the router will keep answering) and add the helper on the interface that faces the clients:

no ip dhcp pool VLAN10 interface GigabitEthernet0/0 ip helper-address 192.168.20.10

On R1. The helper goes on the interface that receives the broadcasts. You can list several helper addresses for backup servers.

SRV1 must have a scope (pool) for 192.168.10.0/24 with gateway 192.168.10.1, and a route back to that subnet. If SRV1 were another Cisco router, the pool would look exactly like the one above.

By default ip helper-address also forwards a few other UDP broadcasts, such as TFTP (69), DNS (53), TACACS (49), Time (37) and NetBIOS (137, 138). no ip forward-protocol udp <port> stops one of them.

3. R1 as a DHCP client toward the ISP

interface GigabitEthernet0/2 ip address dhcp no shutdown

The ISP's DHCP server gives R1 its public address. R1 also installs a default route via the gateway it learns, with administrative distance 254.

Full example (R1, server version)

hostname R1 ! ip dhcp excluded-address 192.168.10.1 192.168.10.10 ip dhcp excluded-address 192.168.10.200 192.168.10.254 ! ip dhcp pool VLAN10 network 192.168.10.0 255.255.255.0 default-router 192.168.10.1 dns-server 192.168.20.53 198.51.100.53 domain-name hq.example.com lease 1 12 ! interface GigabitEthernet0/0 ip address 192.168.10.1 255.255.255.0 no shutdown ! interface GigabitEthernet0/2 ip address dhcp no shutdown

How to verify it

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address          Client-ID/              Lease expiration        Type
                    Hardware address/
                    User name
192.168.10.11       0100.5079.6668.01       Oct 08 2026 02:15 AM    Automatic
192.168.10.12       0100.1b44.11a3.7c       Oct 08 2026 02:31 AM    Automatic
One line per leased address. The client ID is usually 01 (meaning Ethernet) followed by the client's MAC address. Automatic means it came from the pool; a manual binding would say Manual.
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip dhcp pool
Pool VLAN10 :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (first/next)       : 0 / 0
 Total addresses                : 254
 Leased addresses               : 2
 Pending event                  : none
 1 subnet is currently in the pool :
 Current index        IP address range                    Leased addresses
 192.168.10.13        192.168.10.1     - 192.168.10.254    2
Total addresses counts the whole subnet, including excluded ones. Leased addresses is how many are in use now.
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip dhcp conflict
IP address        Detection method   Detection time          VRF
192.168.10.50     Ping               Oct 06 2026 09:12 AM
Someone has set 192.168.10.50 by hand inside the pool. The router won't offer it until you fix the device and run clear ip dhcp conflict *.
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip interface brief | include GigabitEthernet0/2
GigabitEthernet0/2     203.0.113.2     YES DHCP   up                    up
The Method column says DHCP: the address was learned, not typed. show ip route would show S* 0.0.0.0/0 [254/0] via 203.0.113.1.

On the relay, check show running-config interface GigabitEthernet0/0 or show ip interface GigabitEthernet0/0, which lists the helper address. On the server side, the binding table shows whether the request ever arrived.

What goes wrong and how to troubleshoot it

  • Clients get a 169.254.x.x address. No server answered. Is the pool there, does its network match the client subnet, and is the gateway interface up? With a relay, is the helper on the right interface and can the router ping the server?
  • Clients get an address but can't leave the subnet. default-router is missing or wrong in the pool.
  • The pool runs out. Check show ip dhcp pool. Exclusions may be too wide, or the lease too long for a busy guest network.
  • Relayed requests get no answer. The server has no pool for the giaddr subnet, or no route back to it, or an ACL blocks UDP 67.
  • Clients get addresses from the wrong server. A rogue DHCP server (often a home router plugged in by a user) is answering first. That is what DHCP snooping stops.
debug ip dhcp server events

Shows the router assigning, renewing and releasing addresses. Use debug ip dhcp server packet for every message.

Common mistakes

  • Putting ip helper-address on the interface toward the server instead of the one toward the clients.
  • Forgetting to exclude the gateway and other static addresses, then seeing conflicts.
  • Typing ip dhcp excluded-address inside the pool. It is a global command.
  • Leaving a pool on the router after moving to a central server, so two servers answer.
  • Writing the mask as a wildcard (0.0.0.255) on the network line. DHCP pools use a normal subnet mask.

💡 Exam tip: the blueprint asks you to configure and verify DHCP client and relay. Expect to pick the interface where ip helper-address belongs (the client-facing one), to spot a missing default-router, and to read show ip dhcp binding. Know that ip address dhcp makes a router interface a client, and that the client sends from UDP 68 to UDP 67.

Key takeaways

  • Server: global ip dhcp excluded-address, then ip dhcp pool with network, default-router, dns-server.
  • Relay: ip helper-address on the client-facing interface turns broadcasts into unicasts and sets giaddr.
  • Client: ip address dhcp, which also adds a default route with AD 254.
  • The router pings an address before offering it and logs conflicts.
  • Verify with show ip dhcp binding, show ip dhcp pool and show ip dhcp conflict.

Check yourself

Predict · scenario 1

PC1 in VLAN 10 should get an address from SRV1 at 192.168.20.10. R1's Gi0/0 faces VLAN 10 and Gi0/1 faces R2. Where does ip helper-address 192.168.20.10 go?

Predict · scenario 2

Clients get addresses from R1's pool but can't reach anything outside 192.168.10.0/24. Which pool command is most likely missing?

Predict · scenario 3

A relayed Discover arrives at SRV1 with giaddr 192.168.10.1. Which pool does SRV1 use?

Predict · scenario 4

R1's Gi0/2 has 'ip address dhcp' and gets 203.0.113.2 from the ISP. What else does R1 usually learn?

Predict · scenario 5

show ip dhcp conflict lists 192.168.10.50. What does that tell you?

FAQ

Does ip dhcp excluded-address go inside the DHCP pool?
No. It is a global configuration command, entered outside the pool. It applies to every pool on the router. Inside the pool you only define the network and the options such as default-router and dns-server.
On which interface do I put ip helper-address?
On the interface that receives the clients' broadcasts, which is the clients' default gateway interface (for example the LAN interface or the SVI of the users' VLAN). Not on the interface facing the DHCP server.
How does a central DHCP server know which pool to use for a relayed request?
The relay agent writes the address of the interface the request arrived on into the giaddr field. The server picks the pool whose network contains that address. That is why a pool for every remote subnet is needed on the server.
What does ip address dhcp do on a router?
It makes that router interface a DHCP client, which is common on an internet link to an ISP. The router takes an address and mask, and by default installs a default route toward the gateway the server offers, with administrative distance 254.