Arbitrary loopback ip addresses besides 127.0.0.1

660

Solution 1

Edit /etc/network/interfaces

add the following at the bottom of the file

auto lo:0
iface lo:0 inet static
address 127.0.0.2
netmask 255.0.0.0

Documentation on interfaces file can be found here : http://manpages.ubuntu.com/manpages/lucid/man5/interfaces.5.html

The definition above firstly tells the system to automatically bring the new lo:0 virtual interface (alias) up when the system starts. Then it sets interface lo:0 (bound to the loopback interface) to be a static address. The last two lines set the address and the netmask.

After you have added the above you will need to restart networking

sudo /etc/init.d/networking restart

or reboot the computer.

Solution 2

The whole 127.0.0.1/8 address space is reserved for loopback addresses. So you can use any address from 127.0.0.1 up to 127.255.255.254.

Share:
660
Davy Tomory
Author by

Davy Tomory

Updated on September 18, 2022

Comments

  • Davy Tomory
    Davy Tomory over 1 year

    trying to setup nginx to serve anarchistparty.org synapse homeserver reverse proxy. Nginx.conf is currently standard install, hasn’t been edited.

    Sudo nginx -t gives:

    nginx: [emerg] open() "/etc/nginx/sites-enabled/anarchistparty.org" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62 nginx: configuration file /etc/nginx/nginx.conf test failed

    anarchistparty.org is present in sites-available and symlinked

  • Majid Fouladpour
    Majid Fouladpour about 10 years
    +1, good to know fact. However, I tried 127.0.0.5 with my browser and I get (111) Connection refused error. So, I guess I should try the method @Sam suggests.
  • Kind Contributor
    Kind Contributor about 7 years
    They're reserved, but not available for applications unless the interface(s) are added. see askubuntu.com/questions/444124/how-to-add-a-loopback-interfa‌​ce/…. For contrast, on Windows, the full range is bindable without manually adding more interfaces.
  • Ihtisham Tanveer
    Ihtisham Tanveer over 1 year
    spelling mistake /ect/nginx/sites-enabled/ corect path. sudo ln -s /etc/nginx/sites-available/anarchistparty.org /etc/nginx/sites-enabled/