Is it possible to put a real IP (not in the 127.x.x.x) range on a loopback device?

  • Yes, of course. Nov 28, 2017 at 12:35
  • 3
    ... a danger is of course that you forget this IP is there and then you have head-scratching networking issues as the packets don't go to the expected public IP address ...
    – thrig
    Nov 28, 2017 at 13:40

4 Answers 4


On the current Linux kernel with the ip utility it is quite simple:

ip addr add dev lo

This can be useful when you have a service that binds a port on an interface, and want to run a different program on the same port and network. I use it to enable both bind and dnsmasq to co-exist on the same server.

If you are using /etc/network/interfaces to configure your interfaces, then update the lo stanza to include:

up ip addr add dev lo
  • Thanks. Will this persist reboots?
    – Peter Smit
    Nov 29, 2017 at 17:02
  • 1
    @PeterSmit Unlikely.
    – Kusalananda
    Feb 3, 2018 at 8:34

Nothing forbids to do it.

# ifconfig lo:1
# ifconfig lo:1
lo:1      Link encap:Local Loopback  
          inet addr:  Mask:
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
# ping -c 1    
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.025 ms

--- ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.025/0.025/0.025/0.000 ms


For this address to persist after a reboot on Ubuntu 16.04, you can modify your /etc/network/interfaces file with these ethtool commands:

auto lo lo:1

iface lo inet loopback

iface lo:1 inet static
  • Does this persist after a reboot?
    – Peter Smit
    Nov 29, 2017 at 17:02
  • 1
    No. Better to state the precise OS / distribution you are using to get a reliable answer, and possibly ask a new question or check if it hasn't already be answered.
    – jlliagre
    Nov 29, 2017 at 19:12
  • Ubuntu 16.04 LTS
    – Peter Smit
    Nov 29, 2017 at 19:51
  • Answer updated.
    – jlliagre
    Nov 29, 2017 at 20:49

As an alternative to using lo:0, you can also use dummy interfaces in Linux as in:

ifconfig dummy0
ifconfig dummy1

In addition to others answers:

  • I do not recommend changing the usual/official loopback interface address as a lot of functionality depends on it;
  • however, you can have/create several loopback/dummy interfaces - either lo:0 to lo:255 or dummyX interfaces;
  • it has to be taken into account that lo:0 to lo:255 are aliases, whilst dummyX are full interfaces;
  • moreover, one of the usual tactics in Linux for creating virtual IPs over BGP or OSPF is assigning them to loopback/dummy interfaces AND making pathways to them via routing;
  • again, some daemons have problems with announcing addresses in aliases (for instance, quagga ) - so dummyX interfaces are advised in those cases;
  • I would stress that without routing in the infrastructure, such addresses are only known/capable of being used in the server in question;
  • assigning a private/public address to a loopback interface, without the proper routing can be a low computing cost measure to blacklist communications temporarily with an IP address/network.

For more details, see for instance a BIND anycast setup tutorial done with Quagga/BIRD.

routing clues here: OSPF: Migrating Quagga to BIRD

P.S. Linux by default only creates dummy0 and dummy1 and has to be instructed to create a bigger number of dummy interfaces.

  • 1
    I'm absolutely going to use this with (static) routing. Is there any real difference between dummy and loopback interfaces?
    – Peter Smit
    Nov 29, 2017 at 17:03
  • @PeterSmit assigning vips to the loopback with be dealing with aliases of an interface, while dummy are full interfaces on their own right. there were issues using interface aliases with quagga...and I do not recommend changing lo . It also happens often you can/have to associate fw rules w/ an actual interface and not an alias. Nov 29, 2017 at 22:09

Yes, but that doesn't mean it's a good idea. If you use an IP that is ever going to be accessed by your system, any data that it tries to send there will be redirected to the local system instead, which can cause all kinds of odd networking issues. This means in particular that you can't safely use anything outside of the following ranges:

With the possible exception of any of the following dependent on how your other network interfaces are configured:

This is a case where RFC 1925, section 2, item 3 applies.

  • Actually, there are more ranges. In my case, it would be in the range (Carrier Grade NAT)
    – Peter Smit
    Nov 29, 2017 at 17:02
  • 1
    There may be more, but most of them are not widely used on client systems (I think the CGN range probably fits that), or they have ill-defined uses that many people may not understand (like, used for benchmarking), and I wanted to avoid saying something that might not be reasonably safe was in fact safe. Nov 29, 2017 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.