2

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

My actual setup looks like this:

Internal

auto lo
iface lo inet loopback

auto em1
iface em1 inet static
address 179.24.12.11
netmask 255.255.255.0
gateway 179.24.12.1
dns-search domain

I tried with

External

auto em1:0
iface em1:0 inet static
address 179.22.12.11
netmask 255.255.255.0
gateway 179.22.12.1
dns-nameservers 8.8.8.8

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?
Thanks

  • To the best of my knowledge, you can't have 2 gateways. – user508889 May 10 '16 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 May 10 '16 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 May 10 '16 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 May 10 '16 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 May 10 '16 at 15:55
2

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 179.0.0.0.

See ya!

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.