IPV4 中的广播地址

IPV4 中的广播地址

我有一个小网络,子网掩码为 255.255.255.240,IP 范围为 192.168.2.1 - 192.168.2.12。我想从 192.168.2.1 广播一个数据包。我不希望这个数据包到达这个子网之外的任何地方。在阅读了几个基本教程后,我认为最佳广播地址应该是 192.168.2.255。但是维基百科

A special definition exists for the IP broadcast address 255.255.255.255. 
It is the broadcast address of the zero network or 0.0.0.0, which in Internet Protocol
standards stands for this network, i.e. the local network. Transmission to this address
is limited by definition, in that it is never forwarded by the routers connecting the
local network to other networks.

现在,我有点困惑。“本地网络”是指我的子网吗?哪一个可以确保数据包不会超出我的子网:192.168.2.255 还是 255.255.255.255?

答案1

实际上,192.168.2.0/28(即您指定的地址和网络掩码所在的网络)的 IP 范围是 192.168.2.1-192.168.2.14,而您的广播是 192.168.2.15

这是一个IPv4 计算器(还有其他)

答案2

192.168.2.0/28(您的子网)的广播地址是 192.168.2.15。如果您不想联系到您网络之外的任何人,那就使用这个地址吧。

有一些工具可以帮助您完成这些计算,我在 Linux 上使用 ipcalc,在 Windows 上有 Ipcalc.Net,但我确信在所有操作系统上还有更多工具。

答案3

sa将被同一子网中的所有人听到,在您的情况下为 192.168.2.0 192.168.2.255directed broadcast

如果您使用,255.255.255.255它将被网络中的每个人接收,而不仅仅是在特定的子网中。

  • 192.168.2.255 --> 限制为特定子网
  • 255.255.255.255 --> 所有人

因此,如果你不希望广播离开你的子网,你必须选择192.168.2.255

相关内容