Network Bytes · Episode 83 · CCNA 4.6
"DHCP relay: ip helper-address"
A new client finds a DHCP server with a broadcast, and routers don't forward broadcasts. A DHCP relay on the router turns that broadcast into a unicast message to a server on another subnet, set on Cisco with ip helper-address on the interface facing the clients.
Why the broadcast gets stuck
A new device gets its address with the DHCP conversation called DORA: Discover, Offer, Request, Acknowledge (see EP49). The very first message, the Discover, has to be a broadcast: the laptop has no IP address yet and doesn't know where the server is, so it shouts to everyone on its local network.
That works when the DHCP server sits on the same subnet. In most companies it doesn't: one central server hands out addresses for many subnets, often in a data centre or another building. Between the laptop and that server there is at least one router, and routers do not forward broadcasts. That is part of their job, since it stops one network's broadcasts from flooding every other network. So the Discover never reaches the server.
The router as receptionist
The fix is a DHCP relay agent on the router. Think of a receptionist: a visitor calls out "is there anyone from IT here?", the receptionist hears it, picks up the phone and calls the IT office directly.
The router does the same. It hears the client's DHCP broadcast on its client-side interface and sends the message straight to the DHCP server's IP address as an ordinary unicast packet, which routers forward like any other traffic.
Configuring ip helper-address
On a Cisco router, the relay is set on the interface that receives the client broadcasts, usually the interface the clients use as their default gateway:
`` interface g0/1 ip helper-address 10.0.50.10 ``
10.0.50.10 is the DHCP server's address. The command goes on the client side, not on the interface facing the server. The DHCP service on the router must be running, which it is by default in Cisco IOS.
How the server picks the right pool
One server may hold address pools (scopes) for many subnets, so it needs to know where the request came from. When the router relays the message, it writes the address of the interface that heard the broadcast, here 192.168.10.1, into a DHCP header field called giaddr (gateway IP address).
The server reads giaddr, sees that it belongs to 192.168.10.0/24, and offers an address from that pool, for example 192.168.10.23. It sends its reply back to the relay address, and the router passes it on to the client. The rest of DORA follows the same path, and the laptop ends up with an address from the right subnet.
Try it yourself
In Cisco Packet Tracer (free with a Cisco Networking Academy account), build a router with two interfaces: one toward a switch with a PC, one toward a server. Give the server a static address such as 10.0.50.10, turn on its DHCP service and create a pool for 192.168.10.0/24 with gateway 192.168.10.1. Set the PC to DHCP and watch it fail to get an address. Then add ip helper-address 10.0.50.10 on the router's PC-side interface and renew the PC's address. Bonus: in simulation mode, follow the Discover and see it leave the router as a unicast.
Good to know
- CCNA 4.6 covers configuring and verifying the DHCP client and relay. EP49 covers the DORA steps.
- A DHCPv4 client starts with a broadcast Discover, and routers do not forward broadcasts.
ip helper-address <server>goes on the interface that receives the client broadcasts, usually the clients' default gateway interface.- The router relays the message to the server as a unicast, sourced from the router interface, and fills in the giaddr field with that interface's address. The server uses giaddr to choose the pool for that subnet and sends its replies back to the relay, which passes them to the client.
- By default
ip helper-addressalso forwards some other UDP broadcasts (for example TFTP and DNS); the short skips this. - The DHCP service must be running on the router (on by default in IOS).
- "Receptionist" is an analogy.
10.0.50.10and192.168.10.0/24are private example addresses (RFC 1918).
For CCNA learners
CCNA exam topic 4.6 is configure and verify DHCP client and relay. Know why a relay is needed (routers block broadcasts), where ip helper-address goes (the client-facing interface), and how giaddr lets the server pick the right pool.
Answer to the comment question
3 interfaces. The relay works per interface: each interface that receives client broadcasts needs its own ip helper-address. With three client VLAN interfaces, all three get the command, and all three point to the same server (ip helper-address 10.0.50.10). The interface facing the server needs none.
Test your knowledge
Quick quiz: "DHCP relay: ip helper-address"
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- Cisco, "Configuring the Cisco IOS DHCP Relay Agent": the relay is enabled on an interface by
ip helper-address; the client broadcast is forwarded to the server by IP unicast; the relay sets the giaddr field - IETF, "RFC 2131, Dynamic Host Configuration Protocol": relay agents, the giaddr field and how the server picks the subnet from it
- Cisco, "CCNA 200-301 v1.1 exam topics": 4.6 configure and verify DHCP client and relay
- IETF, "RFC 1918, Address Allocation for Private Internets": 10.0.50.10 and 192.168.10.0/24 are private example addresses
Video transcript
Your DHCP server is in another building. How does a new laptop still get an IP address?
With no address yet, the laptop shouts a broadcast for a DHCP server. But routers don't forward broadcasts.
So the router acts like a receptionist. It hears the shout and phones the server directly with a normal unicast message. That's a DHCP relay.
On a Cisco router, you set it on the interface facing the clients: ip helper-address, then the server's address.
The router adds its own interface address, so the server knows which subnet's pool to use. The reply comes back through the router.
A router has three client VLAN interfaces and one DHCP server. How many interfaces need a helper address? Comment your answer below!
That's your byte.
More from Network Bytes
- EP81"TFTP and FTP: backing up configs"
- EP82"Inter-VLAN routing: router on a stick"
- EP84"Dynamic ARP Inspection"
- EP85"IPv6 EUI-64: an address from your MAC"