不常见的 IP 符号

发布于 2025-01-06 10:45:58 字数 211 浏览 3 评论 0原文

我知道可以将 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 技术交流群。

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

发布评论

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

评论(2

习ぎ惯性依靠 2025-01-13 10:45:58

IPv4 地址可以用多种方式表示。例如,默认环回 IP 可以是以下之一:

  • 127.0.0.1
  • 0177.0.0.1
  • 0x7f.0.0.1
  • 127.0.1
  • 127.1
  • 2130706433
  • 017700000001
  • 0x7f000001

第一个表示法(完整的 8 位十进制点)广泛使用,其余的表示法很少使用,但 inet_addr POSIX 标准函数允许。较新的 inet_ntop/inet_pton 中仅保留了第一个熟悉的符号处理 IPv4 和 IPv6 地址的 POSIX 标准函数。

对于 IPv6,标准定义了 16 位十六进制点分表示法以及可选的十进制点分尾符(用于嵌入式 IPv4)以及可选的零压缩。

例如:

  • 2001:0db8:85a3:0000:0000:8a2e:9370:7334
  • 2001:0db8:85a3::8a2e:9370:7334

单个地址仍然有多种表示形式。为了避免由此产生的混乱 RFC 5952 建议采用允许唯一表示法的规范形式。

IPv4 addresses can be represented in multiple ways. For example the default loopback IP can be one of:

  • 127.0.0.1
  • 0177.0.0.1
  • 0x7f.0.0.1
  • 127.0.1
  • 127.1
  • 2130706433
  • 017700000001
  • 0x7f000001

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:

  • 2001:0db8:85a3:0000:0000:8a2e:9370:7334
  • 2001:0db8:85a3::8a2e:9370:7334

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.

玉环 2025-01-13 10:45:58

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.

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