Watch on Instagram

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.

Posted · About a 1 minute watch, 4 minute read · Take the quiz

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-address also 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.10 and 192.168.10.0/24 are 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.

1Why can't a new laptop's DHCP Discover reach a server on another subnet by itself?
2What does a DHCP relay do with the client's broadcast?
3Where do you configure ip helper-address on a Cisco router?
4How does the DHCP server know which pool to use for a relayed request?

Sources

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

All Network Bytes lessons