When DHCP starts the client has no idea about the network it’s currently on. Some clients may store the IP address they were previously on and send this out with the Discovery and Request packets, but the network is not truly set up until after the server has sent it’s final Ack message.
Because of this the server does not know the network’s true broadcast address, however there is an address mapped for this very purpose.
255.255.255.255
If you run arp -a you will see that every interface has the following mapping
- 255.255.255.255 ff-ff-ff-ff-ff-ff static
This means that just like a networks broadcast IP this message will be transmitted to all network adapters on the local network segment.
The DHCP server listens for messages heading for port 67 UDP while the DHCP client listens for messages on port 68 UDP
Lets lake a look at a DORA sequence in Wireshark
- 148 16.564069 0.0.0.0 255.255.255.255 DHCP 342 DHCP Discover - Transaction ID 0xaccba128
- 149 16.592933 192.168.0.1 255.255.255.255 DHCP 590 DHCP Offer - Transaction ID 0xaccba128
- 150 16.593516 0.0.0.0 255.255.255.255 DHCP 362 DHCP Request - Transaction ID 0xaccba128
- 151 16.652333 192.168.0.1 255.255.255.255 DHCP 590 DHCP ACK - Transaction ID 0xaccba128
So what do we see here. In this case both client and server are using the address 255.255.255.255 as the destination address. The client also sends a transaction ID. When the server broadcasts it’s reply it sends back that same ID so the DHCP client can pick out the response that’s meant for it.
It’s easy to assume then that that is the final answer, HOWEVER it’s not quite there yet.
The client may send a request with the broadcast flag cleared. In this situation the server will actually send the request directly to the network adapter that made the request. This is because the client also sends it’s layer 2 address as part of the DHCP packet.
The server will also set the layer 3 address to the intended IP address of the client. So on the surface our DORA trace now looks like this:
- 148 16.564069 0.0.0.0 255.255.255.255 DHCP 342 DHCP Discover - Transaction ID 0xaccba128
- 149 16.592933 192.168.0.1 192.168.0.10 DHCP 590 DHCP Offer - Transaction ID 0xaccba128
- 150 16.593516 0.0.0.0 255.255.255.255 DHCP 362 DHCP Request - Transaction ID 0xaccba128
- 151 16.652333 192.168.0.1 192.168.0.10 DHCP 590 DHCP ACK - Transaction ID 0xaccba128
Note: that the client still sends to 255.255.255.255 until after the ACK stage.
The DHCP protocol requires that a when a server receives a request it SHOULD respond back with the unicast addresses. But, it does go on to say that if unicast transmission is not possible then such a message MAY be sent back to the client as a broadcast message instead.
So to sum up:
Broadcast flag set:
Both client and server use 255.255.255.255 as the destination address.
Both client and server use 255.255.255.255 as the destination address.
Broadcast flag not set.
Client uses 255.255.255.255
Server SHOULD address intended for client.
Server SHOULD address intended for client.
Finally there’s one more thing to consider. What about when a client that’s connected to a network is renewing it’s IP address?
A DHCP client will try renewing it’s address at time T1 which is typically 50% of the lease time. Because the client knows the address og the DHCP server at this point it will try sending directly to the server and the server will respond directly to the client
- 32 6.179740 192.168.0.10 192.168.0.1 DHCP 350 DHCP Request - Transaction ID 0x9c8a32fb
- 33 6.215039 192.168.0.1 192.168.0.10 DHCP 590 DHCP ACK - Transaction ID 0x9c8a32fb
The above shows a successful RENEW - note that we don’t go through the full DORA process here.
If the server does not respond to the client, the client will keep attempting retries at smaller and smaller intervals (typically half the time remaining until T2) until the time left until T2 is less than a minute.
Then the client will switch to broadcasting the DHCP request on 255.255.255.255 again. Provided the server responds with an ACK passage before the end of the lease period, then the client will carry on using the address and update the lease.