什么是适用于localhost和0.0.0.0的IPV6? [英] What is IPV6 for localhost and 0.0.0.0?

查看:799
本文介绍了什么是适用于localhost和0.0.0.0的IPV6?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,localhost的IPv4地址为127.0.0.1(回送地址). localhost0.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.

推荐答案

众所周知,localhost的IPv4地址是127.0.0.1(回送地址).

As we all know that IPv4 address for localhost is 127.0.0.1 (loopback address).

实际上,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.

虽然主机名localhost通常可以解析为127.0.0.1::1,但是我看到有人将其绑定到不是环回地址的IP地址的情况.这有点疯狂……但是有时候人们会这么做.

While the hostname localhost will normally resolve to 127.0.0.1 or ::1, I have seen cases where someone has bound it to an IP address that is not a loopback address. This is a bit crazy ... but sometimes people do it.

我之所以说这太疯狂了",是因为这样做很容易破坏应用程序的假设.例如应用程序可能尝试在回送IP上进行反向查找,但未获得预期的结果.在最坏的情况下,应用程序可能最终会偶然地通过不安全的网络发送敏感流量……尽管您可能还需要犯其他错误才能实现".

阻止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 128 个地址.即是整个IPv6地址空间!
  • :: means just the IPv6 address 0:0:0:0:0:0:0:0
  • ::/128 means 0: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 means 0:0:0:0:0:0:0:0 with a netmask consisting of 0 bits. This gives a network range with 2128 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

这篇关于什么是适用于localhost和0.0.0.0的IPV6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆