Cisco IOS DHCP Relay Agent

DHCP is often used for hosts to automatically assign IP addresses and uses 4 different packets to do so. Since a host doesn’t have an IP address to start with, we use broadcast messages on the network that hopefully end up at a DHCP server.

The problem with broadcast is that this means that the DHCP server has to be in the same broadcast domain since routers do not forward broadcast packets. Take a look at the following picture:

dhcp relay agent topology

On the left side we have a client (H1), in the middle a router (R1) and on the right side is our DHCP server. The client wants to get an IP address through DHCP and will send broadcast a DHCP discover message. The router, doing its job will not forward broadcast traffic so the DHCP discover will never reach the DHCP server…ouch!

So how can we solve this? We have to use the DHCP Relay Agent feature. In short, the router will forward DHCP requests from the client towards the DHCP server, when the DHCP server responds it will forward the messages back to the client.

Let me describe this process in detail, step-by-step to you:

dhcp relay discover

The first thing that happens is that our client will broadcast a DHCP discover message, the router will receive this message since its in the same broadcast domain as the client. Here’s what happens next:

dhcp relay discover unicast

The router receives the DHCP discover message on its FastEthernet 0/0 interface and will normally just discard this packet. With the DHCP relay agent feature enabled, it will do something else. It will forward the DHCP discover message as a unicast packet and also inserts a field called giaddr (Gateway IP Address) in the DHCP packet. It will insert IP address in this field since we received the DHCP discover on the FastEthernet 0/0 interface. This giaddr field is required by the DHCP server or it won’t know from which pool it has to select an IP address. Also, the source IP address of this unicast packet will be Let’s continue:

dhcp relay offer unicast

The DHCP server has received the DHCP discover message and in return will send a DHCP offer message. This will be sent as a unicast packet to the router…

dhcp relay offer broadcast

The router, being a good relay will forward the DHCP offer on its FastEthernet0/0 interface as a broadcast.

dhcp relay request broadcast

The client likes the content of the DHCP offer message and will create a DHCP request which is broadcasted. The router hears this broadcast and will do this:

dhcp relay request unicast

Just like the initial DHCP discover message, this DHCP request will be forwarded as a unicast packet. Once again the giaddr field is inserted with IP address The DHCP server receives the DHCP request and will process it…

dhcp relay dhcp ack

Last but not least, the DHCP server will send a DHCP ACK in response to the DHCP request. This is sent to the router by using unicast and our router will broadcast it on its FastEthernet 0/0 interface so the client receives it. The client now has an IP address and our mission is a great success.

Now you know how the DHCP relay agent works, let’s take a look at the configuration shall we?


I will be using 3 routers for this, the topology is the same as the one I just used for my explanation:

dhcp relay 3 routers example

Let’s start with the configuration of the interfaces:

H1(config)#interface FastEthernet 0/0
H1(config-if)#no shutdown
R1(config)#interface FastEthernet 0/0
R1(config-if)#no shutdown
R1(config-if)#ip address
R1(config)#interface FastEthernet 0/1
R1(config-if)#no shutdown
R1(config-if)#ip address
DHCP(config)#interface FastEthernet 0/0
DHCP(config-if)#no shutdown
DHCP(config-if)#ip address

Nothing special so far…let’s make a DHCP pool for the /24 network. That’s where the client is at:

DHCP(config)#ip dhcp pool NET12

I won’t configure any options like a gateway or DNS server since the only thing I care about is the DHCP agent relay feature. When the DHCP server receives DHCP packets from the router, the source IP address will be so we need to make sure our DHCP server knows how to reach this network. A static route will do the job:

DHCP(config)#ip route

The only thing left to do is to enable the DHCP agent relay option. You only have to use one command to activate this:

R1(config)#interface FastEthernet 0/0
R1(config-if)#ip helper-address

That’s it, the ip helper-address command does the job. Here’s a quick way to verify that it has been enabled:

R1#show ip interface FastEthernet 0/0
FastEthernet0/0 is up, line protocol is up
  Internet address is
  Broadcast address is
  Address determined by setup command
  MTU is 1500 bytes
  Helper address is

That’s all we have to configure, let’s find out if it works. I’ll enable a debug on the router so you can see that it’s relaying the DHCP packets:

R1#debug ip dhcp server packet

Now we’ll tell the client to get an IP address through DHCP:

H1(config)#interface FastEthernet 0/0
H1(config-if)#ip address dhcp

Here’s what you will see on the router:

DHCPD: Finding a relay for client 0063.6973.636f.2d63.3230.332e.3266.3161.2e30.3030.302d.4661.302f.30 on interface FastEthernet0/0.
DHCPD: setting giaddr to
DHCPD: BOOTREQUEST from 0063.6973.636f.2d63.3230.332e.3266.3161.2e30.3030.302d.4661.302f.30 forwarded to
DHCPD: forwarding BOOTREPLY to client c203.2f1a.0000.
DHCPD: broadcasting BOOTREPLY to client c203.2f1a.0000.

That’s looking good! You can see that it is relaying something from the client that it has received on its FastEthernet 0/0 interface and the giaddr field is set to

The packet is being forwarded to the DHCP server. Our client has received an IP address:

H1#show ip int brief 
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0      YES DHCP   up                    up 

That’s it! Our router successfully received an IP address from the DHCP server on the other side, our router relayed everything.

hostname DHCP
ip dhcp pool NET12
ip cef
interface FastEthernet0/0
 ip address
ip route

hostname H1
no ip routing
no ip cef
interface FastEthernet0/0
 ip address dhcp
hostname R1
ip cef
interface FastEthernet0/0
 ip address
 ip helper-address
interface FastEthernet0/1
 ip address

Add comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.