network-programmingipv4

Why are there so many loopback addresses?


I saw that there are 16.581.375 loopback addresses, but nearly every program only uses 127.0.0.1. So why are there so many unused addresses?

IPv4 has many address problems, so why are people wasting so many IP addresses? Is there a reason for it?


Solution

  • In IPv4 the range 127.0.0.0 – 127.255.255.255 is reserved for loopback, i.e. a host’s self-address. These loopback IP addresses are managed entirely by and within the operating system and enable testing of communications in client-server architecture systems on a single machine. When a process creates a packet with a destination address of a loopback address, the operating system loops it back to itself directly without having to go through any NIC.

    You might also use it for things like: Simulating a large number of different computers in a fast network (simply bring up more interfaces and bind services to them) without using virtual machines. This might be helpful if you wanted to have a number of different web servers running locally on port 80 for some reason. Or permitting more locally running services than the 64k TCP would permit (though it seems unlikely that you would hit that limit rationally).

    Historically, the first implementation of TCP/IP didn't support the use of masks, which meant network nodes used the first number to distinguish network size and host ID. More info: https://www.experts-exchange.com/questions/20814842/why-loopback-testing-having-so-long-range.html