I need to setup multiple networks on the same network card on Ubuntu Server 14.04.

My actual setup looks like this:


auto lo
iface lo inet loopback

auto em1
iface em1 inet static
dns-search domain

I tried with


auto em1:0
iface em1:0 inet static

but the second IP is not working.
If I use em2 instead of em1:0 only the second is working.

Could you please help me with this?

  • To the best of my knowledge, you can't have 2 gateways.
    – user508889
    Commented May 10, 2016 at 12:26
  • What do you mean by "not working"? If you run ifconfig can't you see both interfaces? @Brian it's possible to have two or more gateways, in this case one is the gateway for a local subnet and the other seems to be the gateway to reach the internet.
    – migrc
    Commented May 10, 2016 at 14:52
  • I don't see why you would need to set 2 gateways, @migrc. In my attempts setting 2 gateways in interfaces, the second one will be used, the first overwritten by the second directive. So unless there is a different command, I'm unsure how you would even do it.
    – user508889
    Commented May 10, 2016 at 15:02
  • @Brian You have two different subnets. To reach IPs on one subnet you go through one gateway and to reach IPs on other subnet you use the other, what is the problem?. Unless you only talk about a "gateway" when it is used toreach the internet, there are no reasons for don't even need two gateways. Other example, you can have your laptop connected with a network using wifi and connected to other network using ethernet, you will use wifi or ethernet depending on the subnet you want to send data, and if both can access the internet you will only use one of then at a time, but both would be valid.
    – migrc
    Commented May 10, 2016 at 15:40
  • I'm not the one with the problem, @migrc. However for clarity, when your destination is in the same subnet, you don't use the gateway. I maintain he shouldn't have 2 gateways set in interfaces. WIthout him interacting though, this is all for naught.
    – user508889
    Commented May 10, 2016 at 15:55

1 Answer 1


Thanks for the support!
I solved by setting up the gateway only for the external network em2 and routing the em1 on another gateway for net

See ya!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .