Thursday, October 13, 2016

Why Is Localhost’s IP Address 127.0.0.1? What Is Its Meaning?



Short Bytes: Ever wondered why 127.0.0.1 IP address is assigned to localhost? Why not some other IP address like 121.9.1.1 or anything else? The answer to this question lies in the fact that by 1981, 0 and 127 were the only reserved Class A networks. As 0 was used for pointing to a specific host, 127, the last network number, was left for loopback IP address or localhost.


How does 127.0.0.1 work? Why is it called so?

Very often developers use 127.0.0.1 to test their applications. When you try to establish a network connection to the 127.0.0.1 loopback address, it works in the same manner as making a connection with any remote device. However, it avoids connection to the local network interface hardware.
But, why does the localhost IP address starts with 127? Well, 127 is the last network number in a class A network. It has a subnet mask of 255.0.0.0. So, the first assignable address in the subnet is 127.0.0.1.
However, if you use any other numbers from the host portions, it should work fine and revert to 127.0.0.1. So, you can ping 127.1.0.1 if you like.
You might also ask why the last network number was chosen to implement this. Well, the earliest mention of 127 as loopback dates back to November 1986 RFC 990. And, by 1981, 0 and 127 were the only reserved Class A networks.
The class A network number 127 is assigned the “loopback” function, that is, a datagram sent by a higher level protocol to a network 127 address should loop back inside the host. No datagram “sent” to a network 127 address should ever appear on any network anywhere.
As 0 was used for pointing to a specific host, 127 was left for loopback. Some would also call it more sensible to choose 1.0.0.0 for loopback, but that was already given to BBC Packet Radio Network.


SourceSuperUser

No comments:

Post a Comment