0

I have been reading about the linux bonding driver. https://www.kernel.org/doc/Documentation/networking/bonding.txt

My goal is to improve the availability of my internet connection on a debian-based system by combining the ethernet interface (eth0) connected to LAN and a mobile internet connection provided by a surf-stick/GSM-module. Latter appears also as an ethernet interface in the output of ifconfig.

I installed ifenslave and added to my /etc/network/interfaces:

# Slaves
auto eth0
iface eth0 inet manual
  bond-master bond0
  bond-primary eth0
  bond-mode active-backup

auto eth1
iface eth1 inet manual
  bond-master bond0
  bond-primary eth0
  bond-mode active-backup

# Master
auto bond0
iface bond0 inet dhcp
  bond-slaves none
  bond-primary eth0
  bond-mode active-backup
  bond-miimon 100

After reboot my ifconfig output looks like

bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
    inet 192.168.178.47  netmask 255.255.255.0  broadcast 192.168.178.255
    inet6 fe80::ba27:ebff:feb6:c504  prefixlen 64  scopeid 0x20<link>
    ether b8:27:eb:b6:c5:04  txqueuelen 1000  (Ethernet)
    RX packets 436  bytes 34223 (33.4 KiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 312  bytes 80051 (78.1 KiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
    ether b8:27:eb:b6:c5:04  txqueuelen 1000  (Ethernet)
    RX packets 436  bytes 34223 (33.4 KiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 312  bytes 80051 (78.1 KiB)
    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 2  bytes 78 (78.0 B)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 2  bytes 78 (78.0 B)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

That is, the bonded interface is there. Strangely eth0 is also visible, while eth1 (the backup interface representing the surf-stick) is absent.

I can get access if eth0 is connected to the internet, but not if I remove that connection. That is, my setup behaves as if the surf-stick is not present.

I am not sure if I am getting the meaning of bonding correctly since the reference above talks about switches. In my case the two interfaces connect to gateways that are not in a common subnet.

Edit 1 I could solve the partial problem that the interfaces do not seem to be bonded correctly: It appears that this is caused by the boot order (one of the ethernet interfaces is from a USB device). Potentially the drivers are loaded only after the bonding happens. Anyhow, when I trigger the bonding at run-time (modifying /etc/network/interfaces and then running /etc/init.d/networking restart) the bonding seems to happen. However, I still do not get the wanted behavior.

Edit 2 A meanwhile (unfortunately) deleted answer pointed out that bonding may indeed be not useful for my application. If that is correct, is it possible to obtain a similar behavior using routing tables, and how? I would like to have one of the ethernet (eth0) devices as preferred default route when its gateway is connected to the internet. If not, a secondary default route (via eth1) should step in until eth0 gets internet connection again.

1

Bonding only works if you can create bonds on both sides of the connection. Also, bonding works on layer 2, so if you have layer 3 transport in between, it's not possible.

In other words, bonding doesn't work for your use case.

How to use two different internet connection simultaneously is a FAQ. You can

1) Do failover: Use only one connection, switch between them using custom scripts when one connection fails. The main issue here is to define "failure", i.e. how to detect when one connection has failed. One option is a ping in regular intervals to a known address.

2) Use protocols that support multi-homing like SCTP. Unfortunately, these haven't caught on, so this is not practical for most things you'd want to do on the Internet.

Otherwise, there's not much you can do due to how the widely used protocols (TCP and UDP) work.

| improve this answer | |
  • So you are saying that defining two "default" routes is also not an option? – highsciguy Jul 30 '18 at 10:31
  • You can't have two "default" rules. Either one will always get used, or they'll get used randomly, which will look to the other end like 50% packet loss, because half of the packets are not coming from the right IP address and therefore won't get processed. – dirkt Jul 30 '18 at 10:36
  • I have been thinking of the kind of solution discussed here: rjsystems.nl/en/2100-adv-routing.php . – highsciguy Jul 30 '18 at 20:59
  • This does policy routing, and decides by the originating address which route to use. All applications will use either the one route, or the other, but never both. Applications will need to bind to a specific address to decide which one (and not all applications have configurable options for that). If one connection fails, all applications using this connection will have to be restarted. – dirkt Jul 31 '18 at 4:15
  • Thanks that helps me. I discovered github.com/hugochinchilla/WFS.git , which may serve as a starting point for me. – highsciguy Jul 31 '18 at 17:35

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.