IP地址中的0

发布于 2024-11-26 19:35:50 字数 467 浏览 1 评论 0原文

我无法理解 IP 地址,特别是其中包含 0 的 IP 地址。

据我了解,主机 ID 全 0 的 IP 地址是指网络,例如 128.52.0.0/16

IP地址的网络ID中是否有0仍然有效?例如 128.52.0.1 和子网掩码 255.255.255.0

IP地址的主机ID是否可以包含0并且仍然有效?例如 128.52.0.1 和子网掩码 255.255.0.0

另外,出于某种原因,我认为网络 ID 为 0 的 IP 地址是指具有同一网络上的主机 ID 的主机。例如,子网掩码为 255.255.255.0 的网络 192.168.1.0 上的 0.0.0.1 指的是 192.168.1.1。这是正确的吗?

I am having trouble understanding IP addresses, specifically ones with 0s in them.

I understand that an IP address with all 0s for the Host ID refers to the network, such as 128.52.0.0/16.

Can the network ID of an IP address have 0s in it and still be valid? E.g. 128.52.0.1 with subnet mask 255.255.255.0.

Can the host ID of an IP address have 0s in it and still be valid? E.g. 128.52.0.1 with subnet mask 255.255.0.0.

Also, for some reason I got it into my head that IP addresses with 0s for the network ID refers to the host with the host ID on the same network. E.g. 0.0.0.1 on network 192.168.1.0 with subnet mask 255.255.255.0 refers to 192.168.1.1. Is this correct?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠北森屋 2024-12-03 19:35:50

IP 地址的网络 ID 中包含 0 是否仍然有效?例如 128.52.0.1 和子网掩码 255.255.255.0

是的。网络 ID 的八位字节为零是完全可以的。

IP 地址的主机 ID 中包含 0 是否仍然有效?例如 128.52.0.1,子网掩码为 255.255.0.0?

是的。主机 ID 具有零个八位字节是完全可以的,尽管您应该意识到全零位主机 ID 是按照约定保留的,意味着引用整个​​网络(就像全一位的主机 ID 一样)主机 ID 被保留为广播地址,旨在引用网络上的每个主机)。

而且,出于某种原因,我把它记在了我的脑海里......

这是正确的,根据 RFC5735,0.0.0.0/8 用于自我识别:

0.0.0.0/8 - 此块中的地址引用“此”网络上的源主机。地址0.0.0.0/32可以用作该网络上该主机的源地址; 0.0.0.0/8 内的其他地址可用于引用此网络上的指定主机([RFC1122],第 3.2.1.3 节)。

约定是使用全 1 位来表示每个“对象”,并使用全 0 位来表示该“对象”。引用道格拉斯·E·科默 (Douglas E. Comer) 的《Internetworking with TCP/IP》:

在主机想要通过网络进行通信但尚不知道网络 IP 地址的情况下,使用 netid 0 尤其重要。该主机暂时使用网络 ID 0,网络上的其他主机将该地址解释为“此”网络的含义。在大多数情况下,回复将完整指定网络地址,允许原始发件人记录它以供将来使用。

它在“常规”世界中可能不会被广泛使用,因为 BOOTP 和 DHCP 在尚不知道其网络 ID 的情况下都使用有限广播变体(全为 1 位)。但是,由于 RFC 尚未过时,我想它仍然有效。

Can the network ID of an IP address have 0s in it and still be valid? E.g. 128.52.0.1 with subnet mask 255.255.255.0?

Yes. It's perfectly okay for the network ID to have a zero octet.

Can the host ID of an IP address have 0s in it and still be valid? E.g. 128.52.0.1 with subnet mask 255.255.0.0?

Yes. It's perfectly okay for the host ID to have a zero octet although you should be made aware that the all-zero-bit host ID is reserved by convention, meant to refer to the network as a whole (just like the all-one-bit host ID is reserved as a broadcast address, meant to refer to every single host on the network).

Also, for some reason I got it into my head ...

This is correct, 0.0.0.0/8 is used for self-identification according to RFC5735:

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).

The convention is to use all-one-bits to mean every "object" and all-zero-bits to mean this "object". Quoting from "Internetworking with TCP/IP", Douglas E. Comer:

Using netid 0 is especially important in those cases where a host wants to communicate over a network but does not yet know the network IP address. The host uses network id 0 temporarily, and other hosts on the network interpret the address as meaning "this" network. In most cases, replies will have the network address fully specified, allowing the original sender to record it for future use.

It may not be used that much in the "regular" world since both BOOTP and DHCP use the limited broadcast variant (all one bits) in situations where they don't yet know their network ID. But, since the RFC hasn't been obsoleted, I guess it's still valid.

幼儿园老大 2024-12-03 19:35:50

128.52.0.1 只是 128.52.0.0/16 网络上的一个 IP 地址。本例中的网络 ID 为 128.52.0.0。然而,子网掩码是 255.255.0.0。掩码255.255.255.0对应于/24子网。

你的最后一段似乎是正确的。

128.52.0.1 is just an ip address on 128.52.0.0/16 network. Network id in this case is 128.52.0.0. Subnetmask, howerver, is 255.255.0.0. Mask of 255.255.255.0 corresponds to /24 subnet.

Your last paragraph seems correct.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文