Router – How does a router relay DHCP packets when it is configured as a relay agent

dhcprouter

I know a router acting as a relay agent sends the DHCP messages from client to the DHCP server. When server replies back to the relay agent with the DHCPOFFER message how will this message be sent to client, broadcast or unicast?

Best Answer

Great question. The answer can be labbed in GNS3 like so -

Topology:

Topology

R1:

ip dhcp excluded-address 192.168.10.0 192.168.10.99
!
ip dhcp pool Users
   network 192.168.10.0 255.255.255.0
   default-router 192.168.10.1
!
ip route 192.168.10.0 255.255.255.0 10.1.2.2

R2:

interface FastEthernet0/1
 ip address 192.168.10.1 255.255.255.0
 ip helper-address 10.1.2.1

PC (which is actually just another router):

interface FastEthernet0/1
 ip address dhcp

Now let's take a look at some packet captures -

Traffic between R1 & R2:

Traffic between R1 & R2

Traffic between R2 & PC:

enter image description here

So you see, the traffic between R1 and R2 is unicast (as you'd expect) and the traffic between R2 and PC is broadcast, the same way as it would be if R2 were the DHCP server.

Note though that the DHCP request comes from R2's Fa0/1 interface. This therefore means that R1 needs a route to this network even though it is directly connected to R2. That explains why I've got the static route on R1.