The Secret of IPv4 and IPv6: Do you know what's special about 127.0.0.1 and ::1?

In today's computer networks, localhost is an important host name that refers to the computer currently in use. This name is reserved for loopback purposes, primarily for accessing network services running on the host. Access via the loopback network interface bypasses any local network interface hardware, making the loopback mechanism a convenient way to run local services.

The loopback mechanism can be used to run network services without the need for a physical network interface.

For example, you can access the home page of a locally installed website by entering the URL http://localhost into your browser. According to the IPv4 network standard, the entire address block 127.0.0.0/8 (more than 16 million addresses) is reserved for loopback purposes. This means that any packets sent to these addresses will be echoed back. The address 127.0.0.1 is the standard address for IPv4 loopback traffic, while the remaining addresses are not supported by all operating systems. However, they can be used to set up multiple server applications on the host machine, all of which can listen to the same port number.

In the IPv6 address structure, only one address is assigned to loopback, namely ::1. This standard prohibits this address from being assigned to any physical interface or used as a source or destination address for sending or receiving packets. This ensures proper use of loopback addresses and prevents unnecessary routing problems.

Name resolution

Normally, the localhost name resolves to the IPv4 loopback address 127.0.0.1 and the IPv6 loopback address ::1. This resolution is usually configured through the operating system's hosts file, which reads:

127.0.0.1 localhost
::1 localhost

This name can also be resolved by a Domain Name System (DNS) server, but there are some special considerations when using this name. IPv4 or IPv6 address lookup names localhost must always resolve to the corresponding loopback address. When a name resolver receives an address query (A or AAAA query), it SHOULD return the appropriate loopback address and give a negative response to any other requested record type.

When querying localhost, you should avoid sending requests to cached name servers to avoid placing a traffic burden on the domain name system root servers.

In the Domain Name System, the name .localhost is reserved as a top-level domain name, originally to avoid confusion with the host name localhost. Domain name registrars are prohibited from assigning domain names in the top-level .localhost domain to any user.

Historical background

Back in 1981, the network address block 127.0.0.0/8 was marked as "reserved" to prevent it from being assigned to general-purpose Class A IP networks. This block was officially designated for loopback purposes in 1986. By 1994, 2002, 2010, and 2013, this use was recognized as special-purpose IPv4 address blocks. Additionally, the purpose and definition of the IPv6 loopback address ::1 was first defined in 1995 and has not changed since then.

Packet processing

Handling of any packets sent to the loopback address is implemented in the link layer of the TCP/IP stack. These packets are not passed to any network interface controller (NIC) or hardware device driver, and should not appear outside the computing system or be routed by any router. This allows software testing and local servicing even without any hardware network interface.

Loopback packets differ from other packets only by their special IP addresses.

Although there are exceptions to the use of 127.0.0.0/8 addresses, they are exploited in traceroute error detection for Multiprotocol Label Switching (MPLS), a feature that makes them useful to avoid A convenient means of delivering faulty packets to the end user.

In various network project designs, understanding the particularities of loopback addresses is not only crucial for development, but also has a profound impact on system management and security settings. Have you ever wondered whether these seemingly common addresses hide more unknown secrets?

Trending Knowledge

The Loopback Mystery: Why is localhost so important to your computer?
In network communications, the host name localhost refers to the current computer used to access it. This name is reserved exclusively for loopback purposes. It allows us to access network services ru
The hidden power of local servers: How to run a website without an internet connection?
When we browse websites on the Internet, have you ever thought that we can still run our own websites in an environment without Internet access? This seemingly impossible task can actually be achieved
nan
With the increasing global demand for lobsters, the danger of overfishing follows.Lobster is not only a delicacy on the table in many regions, but also an important member of the marine ecosystem.Face

Responses