Cisco IOS DHCP Relay Agent

This giaddr field is required by the DHCP server or it won’t know from which pool it has to select an IP address.
>>> From the above statement I understood that DHCP server uses giaddr to select the pool.

Also, the source IP address of this unicast packet will be 192.168.12.2
>>> I didn’t understand why would it use 192.168.12.2 instead of 192.168.23.2 as the source ip.

Ok I get it.

The giaddr field is what the DHCP server actually uses to decide from which pool it should pick an IP address.

Cisco IOS routers will use the IP address on the incoming interface of the client as the source IP for the unicast packet to the DHCP server, I’m not really sure why they do this as this information isn’t required to relay the DHCP messages.

Some IOS versions support changing the source IP address with this command:

ip dhcp-relay source-interface loopback

Rene

Hi Rene,

Will the ip helper-address always be the address of the interface on the the DHCP server that connects to the DHCP relay?

Hi Adam,

Normally yes, the DHCP relay will add the IP address of the interface where it received the DHCP discover on in the “giaddr” field. It is possible though to leave it empty and use another field (option 82) with information that the DHCP server will use to decide what DHCP pool to use. (Large) ISPs might use this, on a normal network the IP address is probably enough.

Rene

Hi Rene,

Thanks a lot :slight_smile:

Rene I have a question…

What is the difference between DHCP relay and ip helper address.

I’m studying DHCP relay (IPv6) and that is a little confused.

Diana

Hi Diana,

A router becomes a DHCP relay when it “relays” DHCP broadcasts to another interface. We do this with the “IP helper-address” command.

This command, however, does more than just forwarding DHCP broadcasts, here’s a list:

  • UDP 69 - TFTP
  • UDP 67 - BOOTP Client
  • UDP 68 - BOOTP Server
  • UDP 37 - Time Protocol
  • UDP 49 - TACACS
  • UDP 53 - DNS
  • UDP 137 - NetBios
  • UDP 138 - NetBios Datagram

So by default, it will relay all broadcasts to these UDP destination ports. If you want you can also enable relaying for other destination ports. For example:

ip forward-protocol udp 3000

This would relay broadcast packets with destination UDP port 3000. You can also disable some of the default ports:

no ip forward-protocol udp 67
no ip forward-protocol udp 68
no ip forward-protocol udp 137
no ip forward-protocol udp 138

Hope this helps!

Rene

Rene

Hope you are well - hopelijk heb je veel snoepies gehad van dag !

Anyway, I tried the lab above for the DHCP but it din’t seem to work … so my client hasnt received an IP address seemingly here is what I got any ideas what is happening many thanks in advance:

Client#sh ip int br
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES DHCP   up                    up
Client#sh ip int f0/0
FastEthernet0/0 is up, line protocol is up
  Internet address will be negotiated using DHCP

Client:

interface FastEthernet0/0
 ip address dhcp
Client#sh ip route

Gateway of last resort is not set
Router#
*Mar  1 00:33:56.775: DHCPD: setting giaddr to 192.168.12.2.
*Mar  1 00:33:56.775: DHCPD: BOOTREQUEST from 0063.6973.636f.2d63.3230.312e.3062.3630.2e30.3030.302d.4661.302f.30 forwarded to 192.168.23.3.
*Mar  1 00:34:00.779: DHCPD: setting giaddr to 192.168.12.2.
*Mar  1 00:34:00.779: DHCPD: BOOTREQUEST from 0063.6973.636f.2d63.3230.312e.3062.3630.2e30.3030.302d.4661.302f.30 forwarded to 192 privilege level 15

Configuration applied as follows:

Router#

interface FastEthernet0/0
 ip address 192.168.12.2 255.255.255.0
 ip helper-address 192.168.23.3
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.23.2 255.255.255.0
 duplex auto
 speed auto
Router#sh ip route

Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, FastEthernet0/0
C    192.168.23.0/24 is directly connected, FastEthernet0/1

Debug:

Client#

*Mar  1 00:39:14.967: DHCPD: IP address change on interface FastEthernet0/0
DHCP#

ip dhcp pool NET12
   network 192.168.12.0 255.255.255.0

interface FastEthernet0/0
 ip address 192.169.23.3 255.255.255.0
 duplex auto
 speed auto

ip route 192.168.12.0 255.255.255.0 192.168.23.3
DHCP#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

C    192.169.23.0/24 is directly connected, FastEthernet0/0

Hi William,

I’m doing good, hope you as well :slight_smile: Been busy with Google translate? hehe

Your configuration is looking good. Looking at this line:

DHCPD: IP address change on interface FastEthernet0/0

I’d say that your client should have received an IP address. It still doesn’t have anything?

Rene

Renee

Ignore the last input from me (ik was helemaal gek!) … so i realised i made a typing error (typo) which meant i used the incorrect ip address on f0/0 on #DHCP … this meant i had no point to point since the ip address were discontigous furthermore i was never going to get my ip route in the routing table also on #DHCP … as soon as I corrected the interface and ensured the ip route configuration was correct all on #DHCP it worked - thanks very much Renee are great lab to simulate the DHCP process using the two additional routers (by proxy) as host and DHCP server respectively

Regards

Will

so i used a interface FastEthernet0/0
ip address 192.169.23.3 255.255.255.0

instead of 192.168 !!

Good to hear you found it Will!

Hi Rene,

Thanks, explained very well. It’s very easy to understand.

Regards,
M.Selvam

Hi Rene,

Can you explain the packet flow if the DHCP server is 3 routers away from the client network? In this scenario, what DHCP fields would change at every router?

Hi Shree,

Nothing will change. The router that is configured for DHCP relay will create these unicast packets. Other routers only have to route these packets to the DHCP server, that’s it. Here’s a packet capture of these unicast packets btw:

DHCP Relay Unicast Packets

Rene

Rene,
Thanks for the trace. It helped me understand packet flow better. But the intermediate routers add their address in gateway IP field or this field wont be changed? I think the hop count will increase for every router it traverses.

Hi,
Why after relaying,the source and destination port are the same (67)?

Thank you

When you use DHCP, the client might not have an IP address yet. That’s why it is using DHCP. Somehow, the server has to be able to reach the client (and vice versa). Using the same port number on both ends solves this issue.

Thank you for your support.

Hi Rene,

I had the same doubt as Lakshmi (9reply 11618)regarding the source ip for DHCP relay router to DHCP server.
But then if we think about it , the packets coming from dhcp sever will be destined to router interface and this is the interface where we will rebroadcast the dhcp packet.

In your example, if we use 23.2 as source-ip , then how will router know which interface to re-broadcast the DHCP packets ! We can have multiple relay configured for multiple networks.
Also, in most cases , the DHCP server will not be in connected segment so there will be routing.
By looking at the diagram , it feels that 23.2 source_ip is obvious to avoid static routes for reverse routing but in real life , you will need reverse routing for the relayed packets as DHCP server will be located centrally (most often for relays)

That’s what I could think of.

Please share your thoughts on the same.

Hi Rene,
1)I observed there are multiple “ip helper-address” configured on interface.Is it for redundancy or load sharing.
could you please clarify.

2)One more thing is that secondary IP address configured on same interface with different sub net what is the impact of it?

Thanks
Nilesh