2

I have a RaspberryPi 3b+ with a raspbian OS on it.

I'm trying to bond the onboard ethernet with a USB modem dongle (Huawei E3372, HiLink fw).

The problem is that when ethernet cable is switched of, the gateway for default route remains the same and not the dongle's one.

The dongle it self with usb_modeswitch becomes an eth1 interface.

Here are the configurations:

# cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

bonding

# cat /etc/modprobe.d/bonding.conf
options bonding fail_over_mac=active mode=active-backup primary=eth0 primary_reselect=always

# cat /etc/network/interfaces.d/0_lo
auto lo
iface lo inet loopback

# cat /etc/network/interfaces.d/10_eth0
auto eth0
allow-hotplug eth0
iface eth0 inet manual
    bond-master bond0
    bond-primary bond0

# cat /etc/network/interfaces.d/11_eth1
auto eth1
allow-hotplug eth1
iface eth1 inet manual
    bond-master bond0
    pre-up sleep 15 #it needs time for raspi to obtain an IP from the dongle

# cat /etc/network/interfaces.d/20_bond0
auto bond0
iface bond0 inet manual
    bond-slaves           none
    bond-miimon           200
    bond-updelay          200
    bond-downdelay        200
    dns-nameservers       8.8.8.8
    dns-nameservers       8.8.4.4

# cat /etc/dhcpcd.conf
...
denyinterfaces eth0 eth1
...

# ifconfig
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.1.103  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 aaaa::aaaa:aaaa:aaaa:aaaa  prefixlen 64  scopeid 0x20<link>
        ether XX:XX:XX:XX:XX:XX  txqueuelen 1000  (Ethernet)
        RX packets 82  bytes 17140 (16.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 91  bytes 13715 (13.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether XX:XX:XX:XX:XX:XX  txqueuelen 1000  (Ethernet)
        RX packets 58  bytes 8247 (8.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 91  bytes 13715 (13.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether YY:YY:YY:YY:YY:YY  txqueuelen 1000  (Ethernet)
        RX packets 24  bytes 8893 (8.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 600 (600.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 600 (600.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.253.1  netmask 255.255.255.0  broadcast 192.168.253.255
        inet6 ssss::ssss:ssss:ssss:ssss  prefixlen 64  scopeid 0x20<link>
        ether ZZ:ZZ:ZZ:ZZ:ZZ:ZZ  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 29  bytes 4600 (4.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.254   0.0.0.0         UG    202    0        0 bond0
192.168.1.0     0.0.0.0         255.255.255.0   U     202    0        0 bond0
192.168.253.0   0.0.0.0         255.255.255.0   U     304    0        0 wlan0

# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 200
Up Delay (ms): 200
Down Delay (ms): 200

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: XX:XX:XX:XX:XX:XX
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: YY:YY:YY:YY:YY:YY
Slave queue ID: 0

# dmesg | grep bond
[    4.686567] IPv6: ADDRCONF(NETDEV_UP): bond0: link is not ready
[    4.735082] bond0: making interface eth0 the new active one
[    4.736341] bond0: Enslaving eth0 as an active interface with an up link
[    4.737083] IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
[   20.709485] bond0: Enslaving eth1 as a backup interface with an up link

Case 1. Ethernet cable in, USB dongle in.

Both ethX interfaces are up, default route gateway is 192.168.1.254. Internet working fine!

Case 2. Ethernet cable out, USB dongle in.

eth0 interface is down, eth1 is up, default route gateway remains the same 192.168.1.254. Internet NOT working.

When I put denyinterfaces bond0 into /etc/dhcpcd.conf no default route is available at all and this interface can't obtain any IP.

I believe the problem is the gateway. Does anyone have any clue why is that happening. Thanks in advance!

  • 2
    Note that bonding needs to be done on both ends of the link: It's meant to use e.g. two ethernet LAN cables like a single LAN cable. But as you probably don't control the other end of the Huwai mondem, you can't bond it. And no, you can't use bonding as a way to use two internet connections; that's a FAQ. – dirkt May 8 at 18:00
  • Usually, when you have 2 internet connections, you have them from different internet providers, and you just obtain the network definitions by provider's dhcp. Which means you normally have different ip addresses on both 'internet' interfaces. I have the same situation. As far as I got, bonding will provide one with a fail-over mechanism, so I just can't get why bonding is not applicable to USB modem, which actually acts as an ethernet interface (eth1). – Maxim Ilin May 9 at 7:31
  • Bonding in the way you want to use it works on layer 2. If you have a situation where you have two different IP addresses (layer 3), it can't work by definition. Also, you don't seem to believe me when I told you that you need do to it on both ends. But the ISPs (and two different ones) control the other end, so bonding just won't work in your case. Sorry. There are some other crutches you could try for two ISPs at ones (like the source-specific routing), but they remain crutches. – dirkt May 9 at 12:18
  • Ok, I got it. Thank you guys! In my case I will then need to control default routings. I think I need to do that with 1) crontab; 2) route add/delete default; 3) iptables. – Maxim Ilin May 9 at 13:27

Your Answer

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

Browse other questions tagged or ask your own question.