There is no place like home



Surely you've heard of 127.0.0.1. Additionally, you may know that 127.0.0.1 pointing to localhost. But, why is 127.0.0.1 the IP address of localhost and not something else?
Before trying to answer this question, let's talk a little about how things work. This address is used to establish a connection to the very same computer used by the end user. When dealing with IPv6 address, is set to use the concept :: 1:. As IPv6 addresses are entered into the game, the localhost became known as 0: 0: 0: 0: 0: 0: 0: 1.

How does 127.0.0.1? Why is it called so?
Often developers use 127.0.0.1 to test their applications. When you try to create a network connection to the loopback address 127.0.0.1, it works the same way as trying to make a connection to any remote device. However, you avoid connecting to the local network hardware interface.

But why the localhost IP address starts with 127?
Well, the 127 is the last network number in a class A network. It has a subnet mask 255.0.0.0. So the first assigned subnet address is 127.0.0.1. However, if you use any other number of the host portions, should work fine and return to 127.0.0.1. So you can ping to 127.1.0.1, if you want.

You may also have wondered why the last number of the network was chosen for this implementation. Well, the earliest referance of 127 as loopback is dating back to November 1986 RFC 990. And, by 1981, the 0 and 127 were the only reserved Class A networks.

The Class A network number 127 is assigned to the "loopback" function, ie, a datagram sent by a higher level protocol to a network 127 where the address should returns back to the host. Any IP datagram with a source or destination address set to a loopback address must not appear outside of a computing system, or be routed by any routing device. Packets received on an interface with a loopback destination address must be dropped. Such packets are sometimes referred to as Martian packets

IPv4 network standards reserve the entire 127.0.0.0/8 address block for loopback purposes. That means any packet sent to one of those 16,777,214 addresses (127.0.0.1 through 127.255.255.254) is looped back. IPv6 has just a single address, ::1.

As 0 was used for a particular host, the 127 stayed for loopback. Some would consider it more sensible to have selected 1.0.0.0 for loopback, but had already given to the BBC Packet Radio Network.