I have a VPS that has been assigned three IP addresses. Let's say that these are, and (The actual addresses are globally routable, but that is irrelevant for the purposes of this question. The netmask lengths, however, are like that.) The two subnets have different gateways, each in the respective subnet (obviously).

Originally, only was configured, through auto and inet stanzas in /etc/networking/interfaces specifying eth0.

Now I am trying to configure the other two IP addresses as well. The naïve approach of just adding auto eth0:1 and inet eth0:1 stanzas to interfaces netted me an error RTNETLINK answers: File exists - Failed to bring up eth0:1.. Googling suggested I should do ifconfig eth0 add ... followed by ifconfig eth0:1 netmask ... gw ..., but this feels fragile.

What is the proper way to, on Debian Wheezy, set up virtual interfaces (or even without virtual interfaces) for a single physical interface where the virtual interfaces are to be on different subnets?


With modern Linux, an interface can have multiple addresses without creating virtual interfaces. To do this, you need to use the ip command. This is not directly supported by Debian's ifupdown, but you can use a post-up script.

You can place a script in /etc/network/if-up.d with something like the following:

ip addr add dev eth0
ip addr add dev eth0

You can also add routes to this script, but assigning multiple default gateways is not recommended.

  • This seems to have done the trick. I don't know how Debian-esque it is, but it is certainly close enough for me. Thank you! (The only real downside is that the IP addresses don't show up in ifconfig's output, but I guess that isn't all that much of a downside these days.) – a CVn Nov 28 '13 at 20:47

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.