4

I am moving from Windows 7 to Ubuntu MATE 15.10

Each desktop PC is connected on 2 networks. Network 1 has internet access, network 2 does not. The only connection between the two networks are the desktops. Network 1 is serviced by a DHCP router 192.168.1.1. network 2 is serviced by a DHCP router 192.168.2.1.

I do not want to disable the DHCP of either router, as many other devices hookup and disconnect to each of the two networks during the day.

I want to use the network "metric" to prioritize the connections, so that network one gets all internet traffic:

Network 1 will have a metric=10 while Network 2 will have a metric=100

Ubuntu Network Connections GUI is installed, but not configured. I have fiddled with the /etc/network/interfaces file in an attempt to set metrics:

auto lo
iface lo inet loopback

iface eth1 inet dhcp
metric 10

iface eth2 inet dhcp
metric 100

This disables both network connections altogether according to the connections indicator in the top bar.

How can I get both networking connections working and have internet traffic routed on network 1?

1
  • 2
    The routing metric doesn't even enter the picture if one network is not connected to the Internet at all. Only the network that is connected to the Internet should supply a default route via DHCP, and the other should not. Metric is only needed when both networks provide a default route. – psusi Dec 10 '15 at 22:30
5

Your /etc/network/interfaces should look like the following to keep the interfaces enabled.

auto lo
  iface lo inet loopback

auto eth1
  iface eth1 inet dhcp 
  metric 10

auto eth2
  iface eth2 inet dhcp 
  metric 100

From the man interfaces page:

   Lines beginning with the word "auto" are used to identify the physical
   interfaces to be brought up when ifup  is  run  with  the  -a  option.
   (This  option is used by the system boot scripts.)  Physical interface
   names should follow the word "auto" on the same line.   There  can  be
   multiple  "auto"  stanzas.  ifup brings the named interfaces up in the
   order listed.

So, putting the word auto will make it so those connections come up on boot or when restarting the network.

Hope this helps!

0

I couldn't figure out how to make this entry post below Terran's entry.

Terrance, Thanks a million. I made the changes you suggested to my interface file and my Ubuntu MATE 15.10 boxes now have rock solid connections on both networks and simultaneous internet and file sharing access.

I wanted to post the results on this thread for the benefit of others whom cannot get 2 NICS working with one internet connection. I'll start with a working interfaces file example.

This is the /etc/network/interfaces file:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

# J5 Create USB/Ether Adapter MAC c4b
# Subnet Two Gateway 192.168.2.1

auto enx00051ba184cb
iface enx00051ba184cb inet dhcp
metric 100

# Ethernet internal port on Sager laptop MAC 254
# Internet Gateway 192.168.1.1

auto enp6s0
iface enp6s0 inet dhcp
metric 10

mark@UM1510:~$ sudo /etc/init.d/networking stop
[ ok ] Stopping networking (via systemctl): networking.service.
mark@UM1510:~$ sudo /etc/init.d/networking start
[ ok ] Starting networking (via systemctl): networking.service.

mark@UM1510:~$ route

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    10     0        0 enp6s0
default         192.168.2.1     0.0.0.0         UG    100    0        0 enx00051ba184cb
link-local      *               255.255.0.0     U     100    0        0 enx00051ba184cb
192.168.1.0     *               255.255.255.0   U     10     0        0 enp6s0
192.168.2.0     *               255.255.255.0   U     100    0        0 enx00051ba184cb

Results: On site resources are accessible from both networks by file manager and internet access is available simultaneously.

NOTE: The order of the listed connections in the interfaces file has no effect on the order of the connections seen in the route report. Instead, the metric parameter causes the favor of one network over the other and the resulting position one of the internet connection in the route report.

In the next, example only the metrics are switched in the interfaces file to favor the enx00051ba184cb connection over the enp6s0 connection. The network cables are also switched from one interface to the other to keep the network with the lowest metric assigned to the network with the internet connection. This is noted in the interface file comments below.

/etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

# J5 Create USB/Ether Adapter MAC c4b
# Internet Gateway 192.168.1.1

auto enx00051ba184cb
iface enx00051ba184cb inet dhcp
metric 10

# Ethernet internal port on Sager laptop MAC 254
# Subnet Two Gateway 192.168.2.1

auto enp6s0
iface enp6s0 inet dhcp
metric 100

mark@UM1510:~$ sudo /etc/init.d/networking stop
[sudo] password for mark: 
[ ok ] Stopping networking (via systemctl): networking.service.
mark@UM1510:~$ sudo /etc/init.d/networking start
[ ok ] Starting networking (via systemctl): networking.service.

mark@UM1510:~$ route

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    10     0        0 enx00051ba184cb
default         192.168.2.1     0.0.0.0         UG    100    0        0 enp6s0
link-local      *               255.255.0.0     U     10     0        0 enx00051ba184cb
192.168.1.0     *               255.255.255.0   U     10     0        0 enx00051ba184cb
192.168.2.0     *               255.255.255.0   U     100    0        0 enp6s0

Results: On site resources are accessible by file manager and internet access is available simultaneously.

All of this was accomplished with no changes made in the Network Connections GUI offered by Gnome. As a mater of fact the Network Connections Top Bar menu group in the MATE desktop is inactive with the interfaces file populated with entries below the lines:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

I have tried unsuccessfully to achieve the same results I have now achieved with Terrance's support with the Ubuntu Network Connections Manager GUI. Is it possible to migrate all these settings that I have done into the Ubuntu Network Connections Manager GUI ? Then reset the interfaces file back to default? i.e.:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
1
  • You're very welcome for the help! =) You can edit your original question adding what you wrote here to the bottom of it by starting with EDIT: then going on from there. You can also select my answer as the correct answer by clicking the gray check mark below the up down arrows to the left of my answer. Merry Christmas to you! =) – Terrance Dec 11 '15 at 22:12

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.