I have two interfaces connected to two different routers - with different gateway and subnets. How to get IP addresses on bond interface from both enp1s0 and enp2s0 (in bonding active-backup mode)? Currently I get IP from primary, but if primary goes down the bond doesn't refresh IP and gateway, so switching to backup doesn't work. Only when I plug out both, then plug in backup, the bond interface refresh DHCP and get new IP and gateway from backup router. But still if then plug in primary again the bond interface doesn't renew IP so internet connection doesn't work.
I observed that only if the bond interface have IPs from both subnets the failover works. But I get it only once when plug out and plug in the cables randomly between interfaces.
My configuration in netplan:
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
ignore-carrier: yes #with or without doesn't change (without bonding had to have)
enp2s0:
ignore-carrier: yes #with or without doesn't change (without bonding had to have)
bonds:
bond0:
dhcp4: yes
interfaces:
- enp1s0
- enp2s0
parameters:
mode: active-backup
primary: enp2s0
mii-monitor-interval: 50
down-delay: 10
Maybe it would be better to do it without bonding but with metrics, but it didn't work to me that high-metric backup interface take over communication automatically when low-metric primary goes down.