什么是计算机网络中的127.0.0.1 IP地址或Localhost?

IP addresses are used to specify the hosts in a numeric way. There are different types of IP addresses in Computer networks. One of them is 127.0.0.1 which seems a bit confusing. 127.0.0.1 is a special-purpose IPv4 address. This address is assigned to the local system and can not be used by other systems.

IP地址用于以数字方式指定主机。 计算机网络中有不同类型的IP地址。 其中之一是127.0.0.1,这似乎有点令人困惑。 127.0.0.1是专用IPv4地址。 该地址已分配给本地系统,其他系统不能使用。

127.0.0.1 IP地址 (127.0.0.1 IP Address)

127.0.0.1 is mainly designed to test local system network protocols. We can ping 127.0.0.1 like other IP addresses on the local or remote networks. The ping ICMP request will reply with successfully if there is no problem with the operating system network stack. “127.0.0.1” is also called a loopback address because it is connected to the local system, not on a remote system. The IP address range 127.0.0.1/8 is completely registered for loopback purposes. This means Between 127.0.0.1 – 127.0.1.255 are registered for loopback interfaces.

127.0.0.1主要用于测试本地系统网络协议。 我们可以像本地或远程网络上的其他IP地址一样ping 127.0.0.1 。 如果操作系统网络堆栈没有问题,则ping ICMP请求将成功答复。 “ 127.0.0.1”也称为回送地址,因为它连接到本地系统而不是远程系统上。 IP地址范围127.0.0.1/8已完全注册用于回送。 这意味着在127.0.0.1 – 127.0.1.255之间注册了环回接口。

IP地址127.0.0.1用例 (IP Address 127.0.0.1 Use Cases)

At first it may seem unecassary to use IP address 127.0.0.1 but it provides some popular use cases.

最初,使用IP地址127.0.0.1似乎并不麻烦,但是它提供了一些流行的用例。

Loopback 127.0.0.1 can be used for testing purposes in order to check the current system network stack and functionalities. We can ping the 127.0.0.1 and if it is replying properly this means the TCP/IP network stack is working properly.

环回127.0.0.1可用于测试目的,以检查当前系统网络堆栈和功能。 我们可以ping 127.0.0.1,如果它正确答复,则意味着TCP / IP网络堆栈工作正常。

127.0.0.1 also used to block some applications and domains where the domain translation is pointed to 127.0.0.1. The host’s file contains the following record where the abc.com will be redirected to the localhost.

127.0.0.1还用于阻止某些应用程序和域,其中域转换指向127.0.0.1。 主机的文件包含以下记录,其中abc.com将被重定向到本地主机。

abc.com 127.0.0.1

Alternatively, 127.0.0.1 can be also used to start different services like web server, file server, application server on the local system which can not be accessed by other computers. This is a secure way to make web application development and use the localhost to access and test it.

另外,也可以使用127.0.0.1在本地系统上启动其他计算机无法访问的不同服务,例如Web服务器,文件服务器,应用程序服务器。 这是进行Web应用程序开发并使用localhost访问和测试它的安全方法。

平127.0.0.1 (Ping 127.0.0.1)

In this part we will ping the 127.0.0.1 to test our network stack. We will use ping utilyty which is explained in detail in the following tutorial.

在这一部分中,我们将ping 127.0.0.1来测试我们的网络堆栈。 我们将使用ping实用程序,下面的教程对此进行了详细说明。

$ ping 127.0.0.1
Ping 127.0.0.1
Ping 127.0.0.1
平127.0.0.1

平127.0.0.2和127.0.0.3 (Ping 127.0.0.2 and 127.0.0.3)

As stated previously the 127.0.0.1/8 range is completely registred for loopback interfaces which are created on the local system. We can also ping 127.0.0.2, 127.0.0.3 upto 127.0.0.255 as the same where they will reply.

如前所述,在本地系统上创建的回送接口已完全注册127.0.0.1/8范围。 我们也可以ping到127.0.0.2、127.0.0.3至127.0.0.255,直到他们回复为止。

> ping 127.0.0.2
> ping 127.0.0.3
Ping 127.0.0.2 and 127.0.0.3
平127.0.0.2和127.0.0.3

轨迹127.0.0.1 (Trace 127.0.0.1)

In order to see the 127.0.0.1 different from other IP addresses, we can trace IP addresses. Tracing will check the route to the given IP address and print intermediate hops and IP addresses. Below we can see that tracing to 127.0.0.1 only created a single step which takes less than 1ms. This simply means that 127.0.0.1 is on our computer. When we trace to the google.com we can see that it takes a lot much more time.

为了查看127.0.0.1与其他IP地址的不同,我们可以跟踪IP地址。 跟踪将检查到给定IP地址的路由,并打印中间跃点和IP地址。 在下面我们可以看到,跟踪到127.0.0.1仅创建了一个不到1ms的步骤。 这仅表示127.0.0.1在我们的计算机上。 当我们追踪到google.com时,我们发现它花费了很多时间。

> tracert 127.0.0.1
> tracert google.com
Trace 127.0.0.1
轨迹127.0.0.1

本地主机 (Localhost)

localhost is just a hostname used to solve DNS to 127.0.0.1 .Localhost will work 127.0.0.1 interchangebly. We can see that this domain name is defined in /etc/hosts for Linux and /Windows/etc/ for Windows operating systems. We can change the IP address or change the name of the host.

localhost只是用于将DNS解析为127.0.0.1的主机名。Localhost将可互换使用127.0.0.1 。 我们可以看到,该域名在Linux的/etc/hosts定义,在Windows操作系统的/Windows/etc/中定义。 我们可以更改IP地址或更改主机名。

127.0.0.1    localhost

AND print it like below.

并像下面那样打印。

$ cat /etc/hosts
Localhost
Localhost
本地主机

IPv6 127.0.0.1为:: 1(IPv6 127.0.0.1 As ::1)

IPv6 also has the same functionality for the “127.0.0.1“. This address is expressed as ::1 in a short manner but the real or full IP address is 0000:0000:0000:0000:0000:0000:0000:0001

IPv6对于“ 127.0.0.1 ”也具有相同的功能。 该地址以简短的方式表示为::1 ,但实际或完整的IP地址为0000:0000:0000:0000:0000:0000:0000:0001

翻译自: https://www.poftut.com/what-is-127-0-0-1-ip-address-or-localhost-in-computer-network/

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值