How to test bond interface in active/backup mode
Solution 1
You can remove the active bonding interface from the current configuration during runtime and put it back to it:
echo -eth0 > /sys/class/net/bond0/bonding/slaves
echo +eth0 > /sys/class/net/bond0/bonding/slaves
you should see that the slave will change
An otherway is to install ifenslave and use that command for doing it:
ifenslave -c bond0 eth1 eth0
That will set eth1 to the active interface
Solution 2
Instead of removing and adding an interface to /sys/class/net/bond0/bonding/slaves
to force a failover, one could just change the active slave with
echo eth1 > /sys/class/net/bond0/bonding/active_slave
if eth0
is currently active and eth1
is the backup.
In this case all interfaces would stay in state UP, but their roles (active/backup) would change.
Related videos on Youtube
Zaboj Campula
Senior alcohol consumer. Many years experience with playing billiard, darts and bowling.
Updated on September 18, 2022Comments
-
Zaboj Campula almost 2 years
I have a linux machine with with 2 physical network interfaces eth0 and eth1. There is a fault-tolerance (active-backup) bond created over these two interfaces. The bond0 has assigned IP address. eth0 and eth1 have no IP address assigned.
Everything is working OK. When link to eth0 goes down outgoing traffic is routed through eth1 and when eth0 goes up then linux switch back and uses eth0 for all outgoing traffic. So far so good.
I want to test if the path over eth1 is ok but do not want to break connection over eth0. Is there a way how to force kernel to use eth1 for outgoing traffic for some testing packet?
-
Zaboj Campula over 6 yearsThanks, working fine. Just the
ifenslave
accepts only one interface name. -
Marc over 6 yearsSyntax of ifenslave depends a bit on different linux distribution... but generelly it should help you with testing and configuring bondings. Great that it works for you!