不常见的 IP 符号
我知道可以将 IPv4 中的 IP 写为整数,例如 2130706433
而不是 127.0.0.1
。
造成这种可能性的原因是什么?
IPv6 有类似的表示法吗?
我尝试了 ping -6 1
作为 ping ::1
的尝试,但这不起作用(主机不存在)。
I know that it is possible to write IPs in IPv4 as an integer e.g. 2130706433
instead of 127.0.0.1
.
What is the reason for this possibility?
Is there a similar notation for IPv6?
I tried ping -6 1
as a try to ping ::1
, but that don't work (the host would not exists).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IPv4 地址可以用多种方式表示。例如,默认环回 IP 可以是以下之一:
第一个表示法(完整的 8 位十进制点)广泛使用,其余的表示法很少使用,但 inet_addr POSIX 标准函数允许。较新的 inet_ntop/inet_pton 中仅保留了第一个熟悉的符号处理 IPv4 和 IPv6 地址的 POSIX 标准函数。
对于 IPv6,标准定义了 16 位十六进制点分表示法以及可选的十进制点分尾符(用于嵌入式 IPv4)以及可选的零压缩。
例如:
单个地址仍然有多种表示形式。为了避免由此产生的混乱 RFC 5952 建议采用允许唯一表示法的规范形式。
IPv4 addresses can be represented in multiple ways. For example the default loopback IP can be one of:
The first notation (full 8-bit decimal dotted) is in wide usage, the remaining ones are seldom used but allowed by the inet_addr POSIX standard function. Only the first familiar notation has been retained in the newer inet_ntop/inet_pton POSIX standard functions which process both IPv4 and IPv6 addresses.
With IPv6, 16-bit hexadecimal dotted notation with an optional decimal dotted trailer (for embedded IPv4) and also an optional zero compression is what the standard defines.
eg:
There are then still multiple representations of a single address. To avoid the resulting confusion RFC 5952 recommends a canonical form that allows a unique notation.
IPv4 地址只是一个 32 位数字。您可以用任何可以表示这样的数字的方式来表示它(十进制、十六进制、八进制)。点分符号
abcd
更加实用。您可以对 IPv6 地址执行相同的操作,只不过这些地址是 128 位数字 - 更难理解十进制形式。
常用的工具只能处理常用的符号。十进制不是其中之一。
An IPv4 address is just a 32bit number. You could represent it in any way you can represent such a number (decimal, hex, octal). The dotted notation
a.b.c.d
is just much more practical.You can do the same thing with IPv6 addresses, except that those are 128bit numbers - even harder to grok in decimal form.
The usual tools will only deal with usual notations. Decimal isn't one of those.