DHCP: broadcast flag

ipudp

I'm looking at some DHCP packets through wireshark. I notice that in the bootp section, there is a broadcast flag.

However, the dest IP is 255.255.255.255. Isn't it enough to indicate that it's broadcasted? Why is the flag needed?

Thanks,

lang2

Best Answer

DHCP flag serves a completely different purpose. It is set by a client to indicate to a server how the reply should be sent to back to the client. DHCP client sends its request by broadcast, initially, since it doesn't know the server's IP address. However, since the server knows the client's IP (it just provided it with one), server can send the reply back by unicast even if the request was sent by broadcast. Per RFC2131:

A client that cannot receive unicast IP datagrams until its protocol software has been configured with an IP address SHOULD set the BROADCAST bit in the 'flags' field to 1 in any DHCPDISCOVER or DHCPREQUEST messages that client sends. The BROADCAST bit will provide a hint to the DHCP server and BOOTP relay agent to broadcast any messages to the client on the client's subnet. A client that can receive unicast IP datagrams before its protocol software has been configured SHOULD clear the BROADCAST bit to 0.