I'm trying to find an option to add/assign multiple IP addresses and Gateways to the Ubuntu Server. The reason behind is, I want to access devices from two different networks.
For instance I may want to access a device at 192.168.2.45 as well as 192.168.10.45. If I configure my network interface to the static IP 192.168.2.68 I'm able to access only the devices at 192.168.2.xxx and if I change my IP to 192.168.10.158 I'm able to access only the devices at 192.168.10.xxx.
I'm able to do this in Ubuntu Desktop using the network manager as this screen-shot shows:
With the above configuration I'm able to access devices in both the networks 192.168.10.xxx and 192.168.2.xxx. I need help in applying the same configuration to my Ubuntu Server.
Use the following configuration for
/etc/network/interfaces
:Firstly, you almost never want two default routes, as it can cause traffic to traverse the network in unexpected ways, leading to slowdowns or even the box being unable to communicate at all to addresses on some segments. If you do not provide a default route on an interface, traffic to the segment in which that interface resides will transit that interface. A default route in a catch-all for traffic that is not local to a segment directly tied to an interface.
To setup network interface configuration without use of the wizard, you would edit the file "/etc/network/interfaces". This file can have multiple interface stanzas, one for each physical or logical interface [1]. In most cases, if you want multiple addresses on a single physical interface (especially if they are in different internet layer subnets), you will want to assign each address to a separate VLAN virtual interface [2].
1: See http://manpages.ubuntu.com/manpages/utopic/man5/interfaces.5.html
2: See https://wiki.ubuntu.com/vlan