setting priority of two ethernet connections

427 views
Skip to first unread message

nebius

unread,
Jul 20, 2014, 6:43:49 AM7/20/14
to beagl...@googlegroups.com
Hi,
here Nevio, from Italy. I'm new in the forum.
I'm playing with a BeagleBone Black C with debian 7.5 2014-07-06 version.
The BBB is connected to the local network with internet access, and I run it with ssh.
I have connected also a usb internet-key (Huawei E3131) that work out of the box. This internet key is different from the others because it is seen as an ethernet device, not usb device.
I am having trouble with configuring which internet connection the system has to use.
In particular I would like the BBB use the internet connection via LAN if the internet via LAN is up, else the other connection (via usb internet key).
I have configured the two eth connections with different priorities (/etc/network/interfaces), however if the LAN has no internet connection the system don't use the usb-key.
I post my config file.

eth0 = wired connection, gateway 192.168.0.1
eth1 = via usb internet key, gateway 192.168.1.1

debian@arm:~$ ping 8.8.8.8
PING
8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.0.1 icmp_seq=1 Destination Net Unreachable
From 192.168.0.1 icmp_seq=2 Destination Net Unreachable
From 192.168.0.1 icmp_seq=3 Destination Net Unreachable
From 192.168.0.1 icmp_seq=4 Destination Net Unreachable
From 192.168.0.1 icmp_seq=5 Destination Net Unreachable
^C
--- 8.8.8.8 ping statistics ---
9 packets transmitted, 0 received, +9 errors, 100% packet loss, time 8012ms


debian@arm:~$ ping -I eth1 8.8.8.8
PING
8.8.8.8 (8.8.8.8) from 192.168.0.14 eth1: 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=3 ttl=43 time=658 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=43 time=1687 ms
64 bytes from 8.8.8.8: icmp_req=1 ttl=43 time=2687 ms
64 bytes from 8.8.8.8: icmp_req=4 ttl=43 time=47.6 ms
^C
--- 8.8.8.8 ping statistics ---
8 packets transmitted, 7 received, 12% packet loss, time 7003ms
rtt min
/avg/max/mdev = 47.670/899.876/2687.464/921.850 ms, pipe 3


debian@arm:~$ sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    10     0        0 eth1
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.7.0     0.0.0.0         255.255.255.252 U     0      0        0 usb0


debian@arm:~$ nano /etc/network/interfaces


# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).


# The loopback network interface
auto lo
iface lo inet loopback


# The primary network interface
auto eth0
iface eth0 inet
static
address
192.168.0.14
netmask
255.255.255.0
gateway
192.168.0.1


# Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE


# The secondary network interface
auto eth1
allow
-hotplug eth1
#allow-auto eth1
iface eth1 inet
static
address
192.168.1.100
netmask
255.255.255.0
gateway
192.168.1.1
metric
10


# WiFi Example
#auto wlan0
#iface wlan0 inet dhcp
#    wpa-ssid "essid"
#    wpa-psk  "password"


# Ethernet/RNDIS gadget (g_ether)
# ... or on host side, usbnet and random hwaddr
# Note on some boards, usb0 is automaticly setup with an init script
iface usb0 inet
static
    address
192.168.7.2
    netmask
255.255.255.0
    network
192.168.7.0
    gateway
192.168.7.1

liyaoshi

unread,
Jul 21, 2014, 4:34:33 AM7/21/14
to beagl...@googlegroups.com
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0

This mean all package out from 192.168.0.1 
Try route delete 0.0.0.0 once 
Make sure only have 
0.0.0.0         192.168.1.1     0.0.0.0         UG    10     0        0 eth1

When only usb dongle connect .

Or try ifconfig eth0 0.0.0.0 when eth0 down


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jerônimo Lopes

unread,
Jul 21, 2014, 7:23:29 PM7/21/14
to beagl...@googlegroups.com
Hi Nevio,
 
​​

2014-07-20 7:43 GMT-03:00 nebius <nev...@gmail.com>:
Hi,
here Nevio, from Italy. I'm new in the forum.
I'm playing with a BeagleBone Black C with debian 7.5 2014-07-06 version.
The BBB is connected to the local network with internet access, and I run it with ssh.
I have connected also a usb internet-key (Huawei E3131) that work out of the box. This internet key is different from the others because it is seen as an ethernet device, not usb device.

Sorry if this is not the focus of your question, but can you tell how you make this modem work like an ethernet device? "Plug'n play" or did you do some kind of configuration?

I've recently have some problems on make this modem work in ofono, but if the modem can work it would be nice.​

I am having trouble with configuring which internet connection the system has to use.
In particular I would like the BBB use the internet connection via LAN if the internet via LAN is up, else the other connection (via usb internet key).
I have configured the two eth connections with different priorities (/etc/network/interfaces), however if the LAN has no internet connection the system don't use the usb-key.
I post my config file.

eth0 = wired connection, gateway 192.168.0.1
eth1 = via usb internet key, gateway 192.168.1.1
I believe Debian default ​network connection manager is Wicd, I never used. 

I'm currently using Connman to manage connections and default route. You can check some documentation here: 

nebius

unread,
Jul 22, 2014, 4:59:09 AM7/22/14
to beagl...@googlegroups.com
Thank you Iiyaoshi, it works
sudo route del -net 0.0.0.0 gateway 192.168.0.1
and now if I ping an external address it uses 192.168.1.1 gateway (usb internet key).

But how can I automate this?
I can add to /etc/network/interfaces, on the eth0 section:
down route del -net 0.0.0.0 gw 192.168.0.1
up route add
-net 0.0.0.0 gw 192.168.0.1 metric 0

but I don't know if the eth0 ethernet connection has internet access or not. Because sometimes I will connect the board to the notebook with a crossover cable to manage it. In this case eth0 will be up but without internet connection, so the BBB should still use internet key at 192.168.1.1
Is there a method that tried both ways, and chose the one working that has higher priority?


To Jeronimo Lopes:
in my case there was no need for any configuration. With some operating systems I have read that you have to make switching between mass-storage and modem behavior (as usual with internet keys), but with debian and ubuntu even this. I only rename the connection that initially appeared as "rename3" rather than "eth1", adding the mac-address with the correct name in the file /etc/udev/rules.d/70-persistent-net.rules.
I will try wicd! thank you for the advice!

cfor...@unicauca.edu.co

unread,
Dec 2, 2015, 10:47:24 PM12/2/15
to BeagleBoard
Hi,

I my case, I use two interfaces  eth0 (to local network access) and wlan0 (to get internet),   the eth0 blocks wlan0, and I don't get internet, when Unplugged the cable, I get internet again.  How I set Priority in the interfaces?? the most important for me is  wlan0  to have internet,  the second one  eth0.

I tried with IFMETRIC, but my BBB omit everything. 
When I reboot, use a few seconds the wlan0, but a moment after, eth0 blocks again.

with route -n ,  I see the routing,  Despite of set metric 0 or 1 to the wlan0,  and metric 5, 10 or higher,  the eth0 appers with  a metric 0  ???

This procedures work fine with the Rasberry pi.

any ideas, or help in this topic.


Universidad del Cauca: Calidad académica con compromiso regional y nacional.
Reply all
Reply to author
Forward
0 new messages