Digging into IPv4 Loopback Addressing

Anyone who has worked with IPv4 networking has learned about the loopback address. To explain, say your system cannot connect to the Internet. The problem could be any of the following:

  1. Your router isn’t forwarding your IP packets to the Internet.
  2. Your internal network isn’t forwarding your packets to the router.
  3. Your system isn’t transmitting packets to the network due to a problem with your systems network interface card (NIC).
  4. Your system’s network configuration is incorrect.

The loopback address provides a way to check item 3, verifying your NIC is physically capable of transmitting and receiving packets. The old-fashioned way is to use a loopback cable that routes the transmit line (TX) from the NIC back to the receive line (RX) on the NIC. However, today cards build in the ability to internally loopback the packet when the address is detected. This negates the need for a special cable, but it does remove some components from the test, as the signal never leaves and enters the NIC. Still, it’s a pretty good test, as few networking problems are caused by failed transceiver components on a NIC.

I was curious about why is the standard address? Would work?

IP Addressing Background, Notation

First, it helps to have some background on IP addressing. IP addresses are 32-bit numbers, broken into 4 8-bit numbers, called octets. These octets are separated by a period in standard IPv4 notation, such as

The subnet mask is used to identify which part of the IP address is the network ID, and which part is the system ID. If you bitwise AND the subnet mask with the IP address, those bits not zeroed are the network ID, and those that are zeroed are the system (computer) ID. For example, a class A address with an IP address of, with the subnet mask of, means the network ID is 1.x.y.z, and the system ID is x.2.3.4. The letter variables are used to indicate any number from 0 to 255.

Reserved IP Addresses

In any network, two IP addresses are reserved, one with the system ID bits all being 1, and the other with all of them being 0.

The system ID bits being all 1 indicates the message is a broadcast message, sent to and processed by every system on the network. Hence, and, with subnet masks of and respectively, are both broadcast messages for their respective networks. No systems on those networks can have that address.

More interesting to me is the case where all system ID bits are 0. Per this study guide 1)CompTIA Network+ Certification Study Guide, 6th edition, by Glen E. Clarke, this is reserved because it matches the system ID. For example, is not a valid IP addresses, because when the subnet mask ( is AND’d with the IP address, the result of matches the network ID.

It seems to me this should be a valid IP address, as the network ID doesn’t consist of all 4 octets. My belief is a system ID of all 0s has been reserved to simplify the implementation; we can simply mask out the system ID, and treat the 32-bit result as a system ID, for comparison purposes, without having to exclude the system ID bits.

Private IP Addresses

A final note on IPv4 addressing. Some addresses are defined as “private”, or in network speak, nonroutable. A routable IP address is allowed to leave the network.

Say your on a system with an IP address of, and you try and load the website “google.com”, which today on my system, resolves to an IP address of Google’s IP address is not on your home network of 192.168.2.x, so it gets forwarded to your gateway device, your router, which then sends it to “the cloud”, via your Internet Service Provider (ISP). Eventually, it’ll get routed to Google’s server, and the response will get routed back to you.

However, if you try and get to an address like, your router will not forward this address onto “the cloud”. It’s not on your network, but it’s a private, nonroutable IP address, and your router will simply ignore it.

This is done to prevent collisions between internal networks and publicly accessible networks. Internal networks should use these private IP addresses. Systems on the Internet are not allowed to use those private addresses, so there will not be a conflict with your internal networks and external networks.

IP Address Classes

The IP standard 2)https://tools.ietf.org/html/rfc791/ specifies 5 classes for IP addresses. This may become obsolete as the industry moves to a classless IP system 3)https://tools.ietf.org/html/rfc1519/ or moves to IPv6, but today, this is still useful information.

This table shows the IP address ranges for the different classes, the default subnet mask, and the private (nonroutable) addresses within each class. This information comes from this book 4)CompTIA Network+ Certification Study Guide, 6th edition, by Glen E. Clarke and this website 5)https://en.wikipedia.org/wiki/Classful_network/.

Class Leading Bits First Octet Default Subnet Mask # of Hosts/Network Private IP Range
A b0 1 – 127 256x256x256 – 2 = 16,777,214 10.x.y.z
B b10 128 – 191 256×256 – 2 = 65,534 172.16.x.y – 172.31.x.y
C b110 192 – 223 254 192.168.x.y
D b1110 225 – 239
E b1111 240 – 247

A couple interesting things to note from this table:

  1. The leading bits provide an easy way for the addressing logic (be it in hardware or software) to determine the class of an IP.

  2. Not all available IP address are used. For example, isn’t in any range, although the leading bits indicate it could be a class A address. Also, seems to be a class E address based on the leading bits, but isn’t indicated has a valid IP, per 6)CompTIA Network+ Certification Study Guide, 6th edition, by Glen E. Clarke. This site 7)https://en.wikipedia.org/wiki/Classful_network/ indicates these are, at least technically, part of those classes, but the classless system described on this webpage 8)https://en.wikipedia.org/wiki/Reserved_IP_addresses/ has them reserved for other purposes.

Questions Regarding the Loopback Address

With this understanding, these are the questions that came to my mind.

Why a class A Address for Loopback Tests?

Loopback addresses are for testing your local system. Why use a class A address, which eliminates 16,777,214 addresses (256x256x256 = 16,777,216 address, minus the 2 reserved addresses discussed above), when a class C address would eliminate only 254 addresses?

Why not use a Private IP Address for Loopback Testing?

Again, the loopback address is for testing a local system. It’s not supposed to get routed anywhere, so why not use a private address? We don’t want this to go beyond the system being tested, much less to another network.

I would argue that a loopback address of would’ve been a better choice than Maybe I’m missing something. If you know what, please let me know.

Do all Addresses in the 127.x.y.z Range Work?

I tried pinging the various loopback addresses on my home system running Ubuntu 16.04, LTS. What I wanted to understand is if non-standard loopback addresses work as expected. The table below shows the IPs I tested.

|IP Address|Result|Comment|
||64 bytes from icmp_seq=1 ttl=64 time=0.016 ms|The standard loopback IP address.|
||Do you want to ping broadcast? Then -b|The system is correctly treating this as a broadcast address.|
||64 bytes from icmp_seq=1 ttl=64 time=0.019 ms|A valid, though non-standard loopback IP address.|
||64 bytes from icmp_seq=1 ttl=64 time=0.020 ms|A valid, though non-standard loopback IP address.||Do you want to ping broadcast? Then -b|Again, the system is treating this as a broadcast address.|

So yes, non-standard loopback addresses do work, not just the standard, with the exceptions of the reserved broadcast and network ID addresses. Granted I didn’t test all combinations of 127.x.y.z, but I believe other combinations will work as expected.


The point of all this is to dig a little deeper into the loopback addressing mechanism in IPv4. While most people know about, most don’t know other addresses work just as well. Personally, I find “” easier to type than “, so I might adopt this as my new, standard loopback address. Besides, it’s fun to be different, sometimes.

Keep in mind the broadcast address and network ID are always reserved IP addresses.

I’ve posed a few questions and suppositions in this discussion. If you have any answers or clarifications, I’d love to hear from you.

References   [ + ]

1, 4, 6. CompTIA Network+ Certification Study Guide, 6th edition, by Glen E. Clarke
2. https://tools.ietf.org/html/rfc791/
3. https://tools.ietf.org/html/rfc1519/
5, 7. https://en.wikipedia.org/wiki/Classful_network/
8. https://en.wikipedia.org/wiki/Reserved_IP_addresses/


  1. // Reply

    I think you ll need to have an arm device to install on, as ext2 and one partition, then dd the ext2 formated disk into a file.

    1. // Reply

      Did you mean this comment for my blog post on IPv4 and loopback addressing? That post is about network protocols, not a processor architecture or file systems.

Leave a Reply

Your email address will not be published. Required fields are marked *