0

I am struggling with this for over a week. I am new to the networking so I am learning everything from the start past few days.

I am in need to implement seamless switch between two network interfaces. For example I have one internal network wifi in my laptop and one external connected through usb. From the internal wifi I connect to one router and from external wifi I connect to mobile hotspot. So I each wifi adapter has assigned it's own IP from different subnet and different default gateway.

I discovered that something like this should be doable with bonding. So I started to work on this solution. Spent few days on learning some basing routing stuff and I finally almost have it working with last detail on which I am stuck for three days and I am not even sure that it can be done..

Lets say I have two default gateway: first - 192.168.2.1 second - 192.168.3.1

So I have this in my /etc/network/interfaces file:

auto bond0 iface bond0 inet static address 192.168.1.10 netmask 255.255.255.0

auto enp0s3 iface enp0s3 inet manual

auto enp0s8 iface enp0s8 inet manual

I setup links with bonding, bonding mode, etc..

I add some routes

routes

with this setup when I ping some IP on the internet, my wireshark endlessly saying on icmp requets: no response found!

but when I add this:

ifconfig bond0:1 192.168.2.10 netmask 255.255.255.0

ifconfig bond0:2 192.168.3.10 netmask 255.255.255.0

bonding is working fine and when I turn off one of the NICs bonding automatically switch to another (I am running with active-backup) and internet is working.. But the only reason I am doing this is to get seamless download. Lets say I am downloading huge file and using one NIC and it fails so I want that second NIC will be automatically used and my download will continue. But with this setup the download fails because my bonding interface is using either bond0:1 or bond0:2 IP based on the active slave. So when there is a change to new slave my IP change and download fails...

So from what I read, I understand that if I want also my download to seamlessly continue my IP must remain the same when a slave changes..

So I need to remove these two:

ifconfig bond0:1 192.168.2.10 netmask 255.255.255.0

ifconfig bond0:2 192.168.3.10 netmask 255.255.255.0

then my bonding interface allways uses the static ip 192.168.1.10, but with this I am getting: no response found.

I tried some forwarding, nat stuff with ip tables and other stuff I found but nothing worked for me. Am I missing only some small piece to get it going ? Or it can't be done ? I need to implemented a solution without any additional routers or additional settings on the existng routers. It must be a purely setup on my machine. Is this possible ?

Thanks a lot for every answer.

eraz
  • 1
  • 1

1 Answers1

0

Unfortunately none of this works how you expect.

Bonding is intended to join multiple network interfaces in the same broadcast domain, such as two Ethernet NICs plugged into the one switch.

Bonding is not intended as an IP failover between two different IP subnets like you want.

Bonding also changes the MAC address of the devices joined to it, however most consume wifi NICs will not pass frames where the source MAC is not their own MAC.

Your IP addressing also makes no sense, you've got 192.168.1.10/24 and your two router IPs are in different subnets. Any router needs to be in the same subnet, because the router is how you leave the subnet.

What you actually want is to use NetworkManager and setup each connection individually, as if the other one didn't exist. NM will apply a metric to the routes so the Ethernet is preferred when the cable is plugged in, but the system falls back to Wifi when the cable is pulled out.

You still cannot do hot seamless failover of existing established connections, because the Ethernet and the Wifi connection will have different IP addresses on the same subnet. It's as if you're changing from one NIC to the other, just very quickly.

suprjami
  • 3,476
  • 20
  • 29