为什么 DHCP 请求和确认消息是广播的而不是单播的?

Why are DHCP request and acknowledgment messages broadcasted and not unicasted?

在DORA进程的'Request'部分,客户端知道DHCP服务器的IP和MAC地址(因为在Offer中发送的IP数据报有这个信息)。那么如果目的地是已知的,为什么请求仍然广播到网络上的每台机器?

与DORA 过程的'Ack' 部分类似,客户端的IP 地址现已在其中成功设置并为DHCP 服务器所知。为什么它仍然广播消息?

对于网络中有多个DHCP服务器,客户端收到多个OFFER响应的情况,广播REQUEST,来自RFC 2131 Section 3.1:

The servers receive the DHCPREQUEST broadcast from the client. Those servers not selected by the DHCPREQUEST message use the message as notification that the client has declined that server's offer. The server selected in the DHCPREQUEST message commits the binding for the client to persistent storage and responds with a DHCPACK message containing the configuration parameters for the requesting client.

来自服务器的 ACK 可能并不总是广播数据包,但在您检查的情况下可能是。 DHCP 协议的一部分允许启用 DHCPOFFER、DHCPACK 和 DHCPNAK 消息的广播目的地。这是必要的,因为一些 TCP/IP 堆栈在 IP 地址被完全声明并分配给网络接口之前无法接收单播数据报。来自 RFC 2131 Section 4.1:

Normally, DHCP servers and BOOTP relay agents attempt to deliver DHCPOFFER, DHCPACK and DHCPNAK messages directly to the client using uicast delivery. The IP destination address (in the IP header) is set to the DHCP 'yiaddr' address and the link-layer destination address is set to the DHCP 'chaddr' address. Unfortunately, some client implementations are unable to receive such unicast IP datagrams until the implementation has been configured with a valid IP address (leading to a deadlock in which the client's IP address cannot be delivered until the client has been configured with an IP address).

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.