gpt4 book ai didi

dhcp - 为什么要广播 DHCP Offer 和 Ack?

转载 作者:行者123 更新时间:2023-12-04 00:53:08 27 4
gpt4 key购买 nike

为什么服务器不能使用 DHCP 发现和请求的源 IP 中使用的目标 IP 地址 0.0.0.0?它可以使用从 DHCP 发现和请求中获知的客户端 MAC 地址将帧定向到适当的客户端机器。

最佳答案

单播或广播选项在 中指定。 DHCP RFC 2131 :

If the 'giaddr' field in a DHCP message from a client is non-zero, the server sends any return messages to the 'DHCP server' port on the BOOTP relay agent whose address appears in 'giaddr'. If the 'giaddr' field is zero and the 'ciaddr' field is nonzero, then the server unicasts DHCPOFFER and DHCPACK messages to the address in 'ciaddr'. If 'giaddr' is zero and 'ciaddr' is zero, and the broadcast bit is set, then the server broadcasts DHCPOFFER and DHCPACK messages to 0xffffffff. If the broadcast bit is not set and 'giaddr' is zero and 'ciaddr' is zero, then the server unicasts DHCPOFFER and DHCPACK messages to the client's hardware address and 'yiaddr' address. In all cases, when 'giaddr' is zero, the server broadcasts any DHCPNAK messages to 0xffffffff.



ciaddr giaddr 存在:

ciaddr        4  Client IP address; only filled in if client is in BOUND, RENEW or REBINDING state and can respond to ARP requests.
giaddr 4 Relay agent IP address, used in booting via a relay agent.


因此,DHCP 服务器根据客户端的当前状态(主要是它是否已经有 IP 地址)以及消息的发送者(如果它是中继代理或只是客户端)选择广播或不广播。

Unicast DHCPOFFER

在这种情况下,我的 DCHP 服务器选择单播 DHCPOFFER,因为我的机器已经有一个 IP 地址,而我的 LAN 中没有中继代理。

编辑:

并且没有人可以使用 IP 地址 0.0.0.0 作为目标地址。如 IPv4 RFC 5735 中所述:

0.0.0.0/8 - Addresses in this block refer to source hosts on "this" network. Address 0.0.0.0/32 may be used as a source address for this host on this network; other addresses within 0.0.0.0/8 may be used to refer to specified hosts on this network ([RFC1122], Section 3.2.1.3).

关于dhcp - 为什么要广播 DHCP Offer 和 Ack?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10636699/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com