September 26, 2020

127.0.0.0/8 IP Range Is All Loopback

That the 127.0.0.1 IP is a loopback/localhost is widely known. It is used daily by many developers for testing of programs talking over the network. However, did you know that the whole 127.0.0.0/8 IP range are loopback addresses? You have a few million IP addresses reserved on each machine to talk to itself.

Millions of loopback addresses
Figure 1. Millions of IP addresses should be enough for talking to yourself

Most of the time, 127.0.0.1 is enough. However, I had in the past use for this. For example, I had multiple VMs running locally and an app host needing to talk to these local VMs on the same port. So, I just assigned different loopback addresses to these machines and could easily test the scenario.

Using Different IPs for VMs
Figure 2. Using Different IPs for VMs, for example in Virtualbox

Anyway, that’s it. Knowing this might become useful to you one day ;)

Tags: Development