127.0.0.0和127.0.0.1有什么区别?

Sometimes the most elementary of questions yield teachable moments; read on as we delve into how a single digit change between 127.0.0.0 to 127.0.0.1 offers a chance to look at network topology.

有时,最基本的问题会产生可教导的时刻; 请继续阅读,深入研究127.0.0.0到127.0.0.1之间的个位数变化如何提供查看网络拓扑的机会。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

问题 (The Question)

SuperUser reader Disa is curious about loopback IPs:

超级用户阅读器Disa对回送IP感到好奇:

I know that both are loopback IPs, but they have another ip mask.

我知道这两个都是回送IP,但是它们有另一个IP掩码。

What’s the difference between them? Can they be used interchangeably?

它们之间有什么区别? 它们可以互换使用吗?

===========================================================================

IPv4 routes
===========================================================================
Active routes:
Destination               Mask          Gateway        Interface Metric
      0.0.0.0          0.0.0.0      192.168.1.1      192.168.1.6     26
[...]
    127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
    127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
===========================================================================

IPv4 routes
===========================================================================
Active routes:
Destination               Mask          Gateway        Interface Metric
      0.0.0.0          0.0.0.0      192.168.1.1      192.168.1.6     26
[...]
    127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
    127.0.0.1  255.255.255.255         On-link         127.0.0.1    306

What kind of information can we tease out from this table?

我们可以从该表中获取什么样的信息?

答案 (The Answer)

Two SuperUser contributors jumped in to help solve the mystery. First, Mmmc offers this succinct overview:

两名SuperUser贡献者加入进来,帮助解决了这个难题。 首先,MMMC提供以下简要概述:

No. You cannot use them both. And they are not both loopback adresses.

不,您不能同时使用它们。 而且它们都不都是环回地址。

127.0.0.1 is a loopback address 127.0.0.2 is a loopback address 127.0.0.3 is a loopback address and so on

127.0.0.1是回送地址127.0.0.2是回送地址127.0.0.3是回送地址,依此类推

127.0.0.0 is a network address. Together with mask 255.0.0.0 it gives you a hint that whole class A of addresses starting with 127.*.*.* will contain loopback addresses.

127.0.0.0是网络地址。 连同掩码255.0.0.0一起,它提示您整个A类地址以127.*.*.*开头的地址都将包含环回地址。

Then, YLearn offers a broader overview of naming conventions in general and how to think about them:

然后,YLearn对一般的命名约定以及如何考虑它们进行了更广泛的概述:

What is shown in the screenshot is a routing table from a computer. The routing table is just a “roadmap” that tells a computer/router where to go to get to other devices on the network.

屏幕快照中显示的是来自计算机的路由表。 路由表只是一个“路线图”,它告诉计算机/路由器去哪里可以到达网络上的其他设备。

In some ways this is similar to how we navigate in real life.

在某些方面,这类似于我们在现实生活中的导航方式。

The first column provides the list of known destinations (where can I go) and the second column indicates how specific the destination (I can go to Canada or I can go to Uncle John’s house in Canada). Without getting into great detail, the “higher” the mask value, the more specific the destination. So a value of 0.0.0.0 covers going to any device and a value of 255.255.255.255 specifies an individual device.

第一列提供已知目的地的列表(我可以去哪里),第二列指示目的地的具体程度(我可以去加拿大,也可以去约翰叔叔在加拿大的家)。 无需太详细,掩码值“越高”,目的地就越具体。 因此,值0.0.0.0表示可以访问任何设备,而值255.255.255.255指定单个设备。

The third column specifies where traffic should go next to get to the destination (if you are going to Canada, you need to start by getting on Main Street) and the fourth column indicates which path out of the device should be used to get to the destination (from home you may only have your driveway but from the Walmart parking lot you may have several “exits” to choose from).

第三列指定前往目的地的交通的下一步位置(如果要去加拿大,则需要先从Main Street上开始),第四列指示应该使用设备的哪条路径到达目的地目的地(在家中可能只有车道,但在沃尔玛停车场中可能有多个“出口”可供选择)。

Finally, the metric gives the computer a way to choose the best path if there are multiple routes to the destination (you can go out either the north or east exit from the parking lot to get to Canada, but the east one is a faster).

最后,该度量标准为计算机提供了一种在到达目的地的路线多的情况下选择最佳路径的方法(您可以从停车场的北出口或东出口出去,到达加拿大,但东方向更快) 。

So to answer the original question, no you can’t use 127.0.0.0 and 127.0.0.1 interchangeably. The difference shown here is that there exists two routes – a general route to any device using 127.x.y.z and a very specific route to host 127.0.0.1 (which is in 127.0.0.0), both of which use the 127.0.0.1 interface

因此,要回答原始问题,不,您不能互换使用127.0.0.0和127.0.0.1。 此处显示的区别是,存在两条路由-使用127.xyz到任何设备的通用路由,以及到主机127.0.0.1(在127.0.0.0中)的非常特定的路由,两者都使用127.0.0.1接口


Have something to add to the explanation? Sound off in the the comments. Want to read more answers from other tech-savvy Stack Exchange users? 
有什么补充说明吗? 在评论中听起来不对。 是否想从其他精通Stack Exchange的用户那里获得更多答案? Check out the full discussion thread here. 在此处查看完整的讨论线程

翻译自: https://www.howtogeek.com/149227/whats-the-difference-between-127.0.0.0-and-127.0.0.1/

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值