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
ifenslave and added to my
# 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.