Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an interface eth0, and I wish to give it an extra virtual IP. I achieve this by the following:

ifconfig eth0:0 netmask

This works fine, however, when I reboot, this is lost.

I have tried editing /etc/network/interfaces to add the following:

auto eth0:0 iface eth0:0 inet static

However, upon rebooting, the static ip for eth0 is loaded fine, but, the eth0:0 virtual IP is not loaded at all.

So, how can I permanently add the eth0:0 virtual IP?

share|improve this question
Possible duplicate:… .. this is for a bridge, but change br0 to eth0 and the method is the same. – Caesium Nov 27 '11 at 13:54
up vote 8 down vote accepted

Instead of that eth0:0 business, you should do this:

  • Configure your (one) static IP address in /etc/network/interfaces as you normally would:

    # The primary network interface
    auto eth0
    iface eth0 inet static
  • Add another IP to this interface by adding this right after the above:

    up /sbin/ip addr add dev eth0
    down /sbin/ip addr del dev eth0
  • The complete file should look like this

Now, if you check what IP addresses are configured by running ip addr show, both will show up:

2: eth0:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:1d:fa:0b brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
    inet scope global secondary eth0

My thanks to Lekensteyn for pointing me in the right direction. Every site on the internet just talks about eth0:0 for a secondary IP address. This seems like the proper way to do it.

share|improve this answer
Yes, ifconfig has been deprecated in favour of the iproute2 suite (the ip command). ifconfig will never leave my muscle memory though. Also important of note, ifconfig cannot see address aliases added by iproute2! (this doesn't make them work any less well). – Caesium Nov 27 '11 at 14:21
Great! @Caesium that's along the lines of what I suspected. Good to know I wasn't completely misremembering. :) – Stefano Palazzo Nov 27 '11 at 14:23
@Caesium I am a little confused, I tried manually typing "ip addr add dev eth0 label eth0:51" which is garbage information - and, it showed up in ifconfig just fine? ... Don't suppose you fancy coming in to chat to talk a little more!? – wilhil Nov 27 '11 at 14:25
@wilhil, ooh! you taught me something, if you add a label it does show up in ifconfig! If you don't use a label it doesn't. Thanks :) – Caesium Nov 27 '11 at 14:32
The pastebin entry posted is no longer available: The Paste you are looking for does not currently exist. – saji89 Mar 20 '14 at 4:43

If you want to do things the "traditional" way, the relevant part of /etc/network/interfaces should look like:

auto eth0:0
iface eth0:0 inet static

instead of this, where you made a mistake:

auto eth0:0 iface eth0:0 inet static
share|improve this answer
After adding, execute: ifup eth0:0 to start it manually. You can check if its working by executing: netstat -rn – lepe Aug 17 '15 at 4:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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