为什么ip地址127.001路由到127.0.0.1,127.011路由到127.0.0.9?

Why does the ip address 127.001 route to 127.0.0.1 and 127.011 route to 127.0.0.9?

通过一次意外的打字错误,我意识到当您尝试访问 IP 地址 127.0.01 时,它将成功路由到 127.0.0.1

玩这个,我注意到似乎发生了某种翻译。一些例子:

这些翻译背后的逻辑是什么?我已经在 MacOS 上尝试并复制了它,Linux 和 Windows.

来自wikipedia

When fewer than four numbers are specified in the address in dotted notation, the last value is treated as an integer of as many bytes as are required to fill out the address to four octets. Thus, the address 127.65530 is equivalent to 127.0.255.250.

你可以自己算一下看看。

示例:

127.9999 = 0111111100000000 00100111 00001111

=127.03915