10

Most applications only need the one loopback IP address of 127.0.0.1. However, not only is the address block 127.0.0.1/32 provided, and even 127.0.0.0/24 is provided as well but in fact the whole range 127.0.0.0/8 is provided. Clearly, this is a totally and completely unconscionable waste of space as there is no purpose what so ever to having multiple loopback IP addresses. Or maybe not. Why is there more than one loopback IP address?

2

3 Answers 3

7

127/8 (shorthand for 127.0.0.0/8) is reserved by IANA.

Win95 supported 127.0.0.1 but not other 127/8 addresses. WinXP supported 127/8. Cisco IOS supports no loopback addresses by default, but does support the loopback concept, and addresses can be manually assigned. If a computer has no need for more than one loopback address, or zero of them, there's no reason it has to support all those addresses. But, since IANA has now reserved all of them for that purpose, there is no compelling reason for a TCP/IP stack to not support them.

For the most part, there's no compelling need for multiple addresses; I often use multiple loopback connections, but can do so simply by specifying different TCP ports. (I do it for SSH port forwarding. Other VPN software may also be a frequent user for such things, as Isaac Hanson referred to in his answer.) Whether you use different TCP ports on one address (there are 65,535 of them), or multiple IP addresses, makes little technical difference. (However, having unique addresses might be easier in some cases, like if you had multiple servers that could listen to the same "default" port number.)

totally and completely unconscionable waste of space

Ah, such strong language. Allow me to rile you up further :)

Actually, the much bigger waste of IPv4 addresses is 224/3, which contains 224/4 (minimally used for multicast) and 240/4 (almost entirely wasted, with just one address as the exception). So, don't think that we're almost out of IPv4 addresses. IANA has just been handing out the addresses from the former Class A, Class B, and Class C. But don't think for a minute that every last address has been used in the most effective way possible. To see some others: IETF BCP 153 (currently points to RFC 6890). The older RFC 5735 had much of the same information in a different format, e.g. section 4 on page 6. Poke around those, or some other standards, and I'm pretty sure you can find some other large amounts of addresses that are not being super-efficiently used/allocated.

It was decided that supporting some standards may be more desirable than helping IPv4 to limp along even more. One key reason for this may be that some people really were wanting to help push people towards IPv6 adoption.

3

Additional ip addresses in that range can be useful for binding to VPN connections, and for testing services that you don't want bound to localhost.

3
  • This answer should get more votes. In the micro-service era with lots of RAM, it's common for a single machine to host an entire cloud of services, used solely for test purposes.
    – fernacolo
    Aug 9, 2019 at 22:17
  • Aren't the other ip addresses also "localhost" though? Dec 24, 2021 at 16:37
  • @NickManning : Technically, yes (at least they're all "loopback" like "localhost"), but since they're all different IP addresses, each can be assigned a different name other than "localhost" in your hosts file or DNS, and used for other purposes.
    – Spam Hater
    May 3, 2022 at 3:31
2

Why is there more than one loopback IP address?

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.

Source: Network Numbers


If it's a whole class A, what is the point of other arbitrary values for the last three octets?

The purpose of the loopback range is testing of the TCP/IP protocol implementation on a host. Since the lower layers are short-circuited, sending to a loopback address allows the higher layers (IP and above) to be effectively tested without the chance of problems at the lower layers manifesting themselves. 127.0.0.1 is the address most commonly used for testing purposes.

Source: IP Reserved, Loopback and Private Addresses

For more information see What is the loopback device and how do I use it? and why is loopback IP address from 127.0.0.1 to 127.255.255.254?.

1
  • I'm compelled to point out disagreement with "The purpose of the loopback" for testing. Although I've seen that stated in multiple places, I don't recall seeing that in any IETF RFCs. e.g., RFC 1700 page 5 Furthermore, I've effectively used loopback for other purposes, like listening for traffic coming from a source that's more trusted than an external network interfaces. The reason for OpenBSD PF FAQ Example's "best practice to disable all filtering on loopback interfaces." isn't just diagnostics.
    – TOOGAM
    Oct 2, 2015 at 19:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .