I want to add two more loopback interfaces.

I used the following command:

ifconfig lo: netmask up

and type in ifconfig, i can see the loopback address was added.

But if i want to add one more interface... (for example the previous interface ( was overwritten.

Also when i look in /etc/network/interfaces i see no entry.

How can i add multiple loopback interfaces permanently?

5 Answers 5


It depends what you want lo or lo: which is an interface alias.

ifconfig lo:0 netmask up
ifconfig lo:1 netmask up
ifconfig lo:2 netmask up

works. If you want to have more IP's on lo use

route add -host dev lo
route add -host dev lo
route add -host dev lo

works too. If you want to remove it, use:

route del -host
route del -host
route del -host

See also IP-Aliasing Linux Networking-HOWTO

  • 1
    Works. Thanks! But what is the difference between lo and lo: and how to remove an interface from lo:?
    – Leviathan
    Apr 6, 2014 at 20:01
  • 1
    never saw lo: before. Remove with ifconfig lo: down
    – user224465
    Apr 6, 2014 at 20:46
  • What is the difference between ifconfig lo: and route add -host ? Are they doing the same thing?
    – hengxin
    Jul 30, 2014 at 8:00
  • 1
    lo:<foo> is a new interface that use lo as a base, its called a alias and you can operate it as a normal interface: set it up, down, etc. It creates a separation between just adding more ips to a interface or creating a new interface. It is useful when you dont want actions applied on one ip to be done also to the rest of the ips in one interface Jun 3, 2015 at 14:09
  • 1
    Used route add -host [dest] dev lo, and it caused some really unexpected behavior. It doesn't work on its own, without creating the interface alias route add doesn't work - not sure what it does. Does lo then forward the packages to the default gateway, or what happens? Get ping timeouts with route add. Seems like it might be dangerous.
    – John Doe
    May 22, 2017 at 14:50

If you keep using ifconfig lo... you're not creating a new interface, you're overwriting the previous one. You could try editing your interfaces file:

sudo vim /etc/network/interfaces

Mine looks like this:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

So, you could try and modifyi it to create new interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto lo2
iface lo2 inet loopback
auto lo3

Then, restart the network, or the whole system, and try to interact with the new interfaces with:

sudo ifconfig lo2/lo3 etc...
  • What are the ips for the new created lo2 and lo3? By the way, what do the numbers (interfaces(5), ifup(8), and ifdown(8)) mean? Thanks.
    – hengxin
    Jul 30, 2014 at 8:05
  • Those numbers are references to the man pages, but don't know exactly how they work. The lines are comented anyway. About the IP, you'll need to set them with ifconfig or with address etc under each interface. Oct 7, 2014 at 17:25
  • If you're curious what the numbers mean, run man man; the numbers indicate what section of the manual each manpage is in. Section 5 is for file formats and conventions, for example, and section 8 is for system administration commands (that usually are only expected to be run by root). Jul 6, 2015 at 23:36
  • 5
    I don't think that this actually works. You can only have on "lo" device per namespace according to driver/net/loopback.c. The "dummy" device may do everything you need, "sudo ip link add name loop1 type dummy"
    – mcr
    Sep 25, 2015 at 13:42
  • 1
    This doesn't work: Cannot find device "lo1" Jan 4, 2018 at 15:14

To add multiple loopback interfaces permanently, must do an additional check for dummy driver.

Dummy driver is used for the making of multiple loopbacks device instead of
creating multiple aliases to one device, with an attachment of different IP.

This lines add another loopback named loop1, loop2, loop3:

sudo ip link add name loop1 type dummy
sudo ip link add name loop2 type dummy
sudo ip link add name loop3 type dummy

Please check that dummy kernel module is loaded before running the above command:

sudo lsmod | grep dummy
  • this adds a dummy interface which works similar but lacks flags the lo interface has
    – sjas
    Jul 7, 2018 at 18:27

When using the newer iproute2 tool you can also do what user224465 suggests:

ip addr add dev lo
route add -host dev lo

I've used this to create a fake ip address for aws on docker, nl. Combine this with ectou_metadata and you have aws from the cloud on your docker image.

  • This is the correct answer for modern Ubuntu hosts
    – Rino Bino
    Feb 1 at 19:01
  • Is this permanent or transient? i.e. will these settings persist after a reboot?
    – Coder Guy
    Mar 8 at 19:46
  • This is transient. Mar 9 at 20:38

I've notice that I'm not the only one looking for a solution for multiple loopback interfaces. In the last period I was playing a lot with FRRouting and route-leak between VRF and I notice a strange problem with dummy interfaces: are not responding to ping if the dummy interface is under a VRF (more explantions in README.md on the github). For this reason I was writing a new driver based on dummy, VRF interface and loopback and I was able to make it to responds to ping.

Maybe there is somebody else intereseted to test it and see if it's suitable as a multi loopback interface.

Here are the sources: https://github.com/EasyNetDev/linux-multi-loopback

Also I opened a ticket to Linux Kernel mentioning this misbehavior of the dummy driver and about this new driver: https://bugzilla.kernel.org/show_bug.cgi?id=215675

Hope it helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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