Can I adjust metrics on my two network interfaces?

I have two subnets.

192.168.6.x for special purposes, and I am cabled directly to the router by Ethernet. It has an WAN connection to the internet gateway so the specialized devices can do software updates, but they primarily talk to each other. Each has a static address and a hosts file so they are all accessible by name.

The service entrance is 192.168.1.1 and I can directly to it via WiFi with a static IP address.

On Windows 7 and 8.1 it is very easy to set the .1 interface to have a metric of 1 and the .6 have a metric of 10.

Any time I need to communicate with a unit on .6 there is only one interface that can do it, so all is fine.

When I need to do an Internet stream or download it favors the .1 interface and doesn't interfere with the instrumentation.

So now, with a new ubuntu 14.04 machine becoming such a useful workstation I need the same setup for it.

.6 is cabled to Ethernet, and .1 is via WiFi. Right now it seems very random which path a large download will take, often upsetting the data loggers on .6


Network configuration is done in the GUI Setup, Network screen.

eth0 is 192.168.6.204, gateway 192.168.6.1, dns 192.168.1.1

wlan1 is 192.168.1.214, gateway 192.168.1.1, dns 192.168.1.1

and

/etc/interfaces looks like this:

enter image description here

There is no /wpa_supplicant/wpa_supplicants file.

/etc/hosts looks like this:

enter image description here

The route command returns this:

enter image description here

Which shows the metrics exactly the opposite of what I want, and even though the gateway address for wlan1 shows as 192.168.1.1 in the setup screen it doesn't show it in the routing table.

So clearly I have two problems in the routing table. Metrics and gateways.

My original question is in the title: Can I adjust metrics on my two network interfaces? But the more I look into this I think I should change the title to ask how do you control ubuntu 14.04 networking other than by the GUI.

2

1 Answer

You can add metric to your interface

If you use dhcp to configure eth interface

sudo nano /etc/network/interface

then add metric

auto eth0 iface eth2 inet dhcp metric 800

If you have static ip

auto eth1 iface eth1 inet static address 10.10.0.10 netmask 255.255.255.0 gateway 10.10.0.1 metric 800 

Also you can create script to change gefault gateway

Example:

 sudo nano /etc/network/if-up.d/script

and put content

# Check for specific interface if desired
[ "$IFACE" != "eth0" ] || exit 0
# put default gw to wless
route add default dev wlan0 

give script privilege

chmod 755 /etc/network/if-up.d/script

if-up.d will trigger script called script when eth0 go up and put default gw to wlan0

Or you can to manually add metric to route

sudo route add default gw 10.10.0.1 metric 800

10.10.10.1 is default gateway for eth network

Or if you do not need resources on ethernet subnet except that subnet, I mean all the host you talk trough cable is on same subnet, you can delete default gw from eth card setting.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like