Have you wondered what is local host’s IP and 127.0.0.1 what it actually is?
If you are on Internet 24×7 you might have definitely heard or seen an IP address 127.0.0.1 during your time on the net. The geeky nerds among you might know that 127.0.0.1 points to localhost. But do you know why is localhost‘s IP address 127.0.0.1 and not something else?
The basic logic behind this address is that it is used to establish a connection to the same computer used by the end-user. Below is a detailed answer by a user on Super User forum.
How does 127.0.0.1 work? Why is it called so?
Here is a geeky answer from a techie :
127 is the last network number in a class A network with a subnet mask of
127.0.0.1is the first assignable address in the subnet.
127.0.0.0cannot be used because that would be the wire number. But using any other numbers for the host portion should work fine and revert to using
127.0.0.1. You can try it yourself by pinging
127.1.1.1if you’d like. Why they waited until the last network number to implement this? I don’t think it’s documented.
Most developers use local host 127.0.0.1 to test their applications before actually deploying it. 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.
000.rrr.rrr.rrr Reserved [JBP] ... 127.rrr.rrr.rrr Reserved [JBP]
0 and 127 were the only reserved Class A networks by 1981. Out of the two available localhosts, 0 was used for pointing to a specific host and that left 127. So all developers testing their apps and websites have to use 127 for loopback. Some would also call it more sensible to choose 126.96.36.199 for loopback, but that was already given to BBC Packet Radio Network.
You can find more information and discussion about local host from Stack Exchange users here.