1

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?

4

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

  • Thanks, working fine. Just the ifenslave accepts only one interface name. – Zaboj Campula Feb 22 '18 at 8:53
  • Syntax 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! – Marc Feb 22 '18 at 9:04
1

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.

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.