DHCP server also acting as relay

Hi.

I want to use the DHCP server that comes with vxWorks 6.4.
The DHCP server implementation has a table that contains addresses of DHCP servers that will receive a copy of all the client requests that the local server gets, thus the server acts as a dhcp relay at the same time.

Can anyone explain to me what is the use of this and how exactly does it work?
When the DHCP servers gets a request, it will answer it. If an address is defined in the table mentioned above, a copy of the request will be sent to another DHCP server, which I assume will also reply to it.

What happens now? which reply does the client chose and why? How is this mechanism useful?

Thanks.

When a system (client) boots up, a DHCP lease negotiation occurs between a DHCP server and the client. Four messages are sent between the client and the DHCP server:

  • DHCPDISCOVER Broadcast message sent by client to request an IP address lease from a DHCP server.
  • DHCPOFFER Sent by one or more DHCP servers in response to the DHCPDISCOVER message.
  • DHCPREQUEST Sent by client to first DHCP server that responded to its request for an IP address.
  • DHCPACK Sent by DHCP server to client acknowledging the request. Contains assigned IP address, lease details and more.

Because a DHCPDISCOVER message is a broadcast message it is limited to the segment of the network. This means that a DHCP server must be located on the network segment unless the DHCP messages are routed to a DHCP server. One way is to configure the router to forward DHCP/BOOTP messages. Another way is to use a DHCP relay agent and is commonly used if a router does not support forwarding of DHCP/BOOTP messages.

In summary if your network has multiple segments, you have to do one of the following:

- Place a DHCP server on each segment.
- Place a DHCP Relay Agent on each segment.
- Configure your routers to forward DHCP broadcast messages.

Thanks for the answer. I still have some questions :slight_smile:

A client sends a DHCPDISCOVER to the router that acts both as a server and a relay. The server responds with a DHCPOFFER to the client and forwards the broadcast to the server specified in the relay, which also responds with a DHCPOFFER.
If the time difference between the arrival of the the DHCPOFFER messages from the two servers to the client is negligible, which one would the client use?
If the time difference is not negligible, then by the time the client gets the DHCPOFFER from the farther server, it will already have negotiated a lease with the server in it's segment.
I am still having trouble understanding what is the point of having both server and relay in the same machine.

In a word, redundancy.

The first one processed. The DHCPREQUEST sent by the client is broadcast so that all other DHCP servers that received the DHCPDISCOVER broadcast message from the client can reclaim the IP addresses that they offered to the client.

It seems (to me) that using both server and relay on the same machine opens more room for potential problems than solving any.
But it's good to know why and how it can be used anyways.

Thanks!
:slight_smile: