问题描述
众所周知,localhost
的IPv4地址为127.0.0.1
(回送地址). localhost
和0.0.0.0
的IPv6地址是什么,因为我需要阻止一些广告主机.
As we all know the IPv4 address for localhost
is 127.0.0.1
(loopback address). What is the IPv6 address for localhost
and for 0.0.0.0
as I need to block some ad hosts.
推荐答案
实际上,127.0.0.0/8
中的任何IPv4地址都是回送地址.
Actually, any IPv4 address in 127.0.0.0/8
is a loopback address.
在IPv6中,回送范围的直接模拟为::1/128
.因此,::1
(长格式为0:0:0:0:0:0:0:1
)是一个也是唯一的IPv6回送地址.
In IPv6, the direct analog of the loopback range is ::1/128
. So ::1
(long form 0:0:0:0:0:0:0:1
) is the one and only IPv6 loopback address.
阻止0.0.0.0
没有任何意义.在IPv4中,它永远不会被路由. IPv6中的等效地址是::
地址(长格式为0:0:0:0:0:0:0:0
)...也从未路由过.
Blocking 0.0.0.0
makes no sense. In IPv4 it is never routed. The equivalent in IPv6 is the ::
address (long form 0:0:0:0:0:0:0:0
) ... which is also never routed.
0.0.0.0
和::
地址保留为任何地址".因此,例如,提供Web服务的程序可以 bind 绑定到0.0.0.0
端口80,以通过主机的任何IPv4地址接受HTTP连接.这些地址不能作为IP数据包的源地址或目的地址.
The 0.0.0.0
and ::
addresses are reserved to mean "any address". So, for example a program that is providing a web service may bind to 0.0.0.0
port 80 to accept HTTP connections via any of the host's IPv4 addresses. These addresses are not valid as a source or destination address for an IP packet.
最后,一些评论询问了::/128
与::/0
与::
的关系.
Finally, some comments were asking about ::/128
versus ::/0
versus ::
.
这有什么区别?
严格来说,前两个是CIDR表示法而不是IPv6地址.他们实际上是在指定IP地址的范围. CIDR由IP地址和一个附加数字组成,该数字指定网络掩码中的位数.两者一起指定了地址范围;即通过忽略从给定地址中屏蔽的位形成的地址集.
Strictly speaking, the first two are CIDR notation not IPv6 addresses. They are actually specifying a range of IP addresses. A CIDR consists of a IP address and an additional number that specifies the number of bits in a netmask. The two together specify a range of addresses; i.e. the set of addresses formed by ignoring the bits masked out of the given address.
所以:
-
::
表示IPv6地址0:0:0:0:0:0:0:0
-
::/128
表示0:0:0:0:0:0:0:0
,其网络掩码由128位组成.这样就给出了一个网络范围,其中只有一个地址. -
::/0
表示0:0:0:0:0:0:0:0
,其网络掩码由0位组成.这样就给出了一个网络范围,其中包含2 个地址.即是整个IPv6地址空间!
::
means just the IPv6 address0:0:0:0:0:0:0:0
::/128
means0:0:0:0:0:0:0:0
with a netmask consisting of 128 bits. This gives a network range with exactly one address in it.::/0
means0:0:0:0:0:0:0:0
with a netmask consisting of 0 bits. This gives a network range with 2 addresses in it.; i.e. it is the entire IPv6 address space!
有关更多信息,请阅读有关IPv4&的Wikipedia页面. IPv6地址和CIDR表示法:
For more information, read the Wikipedia pages on IPv4 & IPv6 addresses, and CIDR notation:
- https://en.wikipedia.org/wiki/IPv4_address
- https://en.wikipedia.org/wiki/IPv6_address
- https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
- https://en.wikipedia.org/wiki/IPv4_address
- https://en.wikipedia.org/wiki/IPv6_address
- https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
这篇关于什么是适用于localhost和0.0.0.0的IPV6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!