2

I am trying to set up fail-back configuration in bonding but I am unable to get around the interface configuration. My interface is as follow:

auto bond0
iface bond0 inet static
       address 192.168.1.39
       netmask 255.255.255.0
       up /sbin/ifenslave bond0 eth1 eth3
       down /sbin/ifenslave -d bond0 eth1 eth3

My /etc/modprobe.d/bonding.conf file is:

alias bond0 bonding
options bonding mode=3

I test it by running ping from other system. My bond status is as follows:

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (broadcast)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 44:a8:42:03:68:2c
Slave queue ID: 0

Slave Interface: eth3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 44:a8:42:03:68:2c
Slave queue ID: 0

When I remove eth1 cable the fail-over works and eth3 carries out the data (The ping still continues).

If I connect back eth1 and remove eth3 the ping stops and the bonding status doesn't contain any of the interface. The bond status is:

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (broadcast)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

I tried with all the modes in the bonding ( 0 to 6 ). But none of the configuration provides the fail-back support. Where am I going wrong?

1 Answers1

6

EDIT 2019-01-10: These instructions are for Ubuntu 16.04 and older. I will try to update with instructions for 18.04.

In this answer, we are using active-backup bonding with a bond-primary interface set that allows for fail-over to go back to the primary when it is available. More information can be found: https://wiki.linuxfoundation.org/networking/bonding


Bonding in Ubuntu is a different setup then as in other distros of Linux like RedHat. I have done a few bonding configurations in Ubuntu and I will lay it out below as best as possible.

As it looks, you already have ifenslave installed, but if not, install ifenslave:

sudo apt-get install ifenslave

Next, take a look at /etc/modules and make sure it has the following lines:

loop
lp
rtc
bonding

In the /etc/network/interfaces file, set your loopback, eth1, and eth3 interfaces:

auto lo
    iface lo inet loopback

auto eth1
    iface eth1 inet manual
    bond-master bond0
    bond-primary eth1

auto eth3
    iface eth3 inet manual
    bond-master bond0

Now set your bond0 interface with active-backup for fail-over if one of the NIC connections fail:

auto bond0
    iface bond0 inet static
    address 192.168.1.39
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1
    bond-mode active-backup
    bond-miimon 100
    bond-slaves none

Save the changes to /etc/network/interfaces file and restart your networking service:

sudo /etc/init.d/networking restart

Now you can check your bonding setup. Make sure that your bond0, eth1 and eth3 are correct:

sudo ethtool bond0
sudo ethtool eth1
sudo ethtool eth3

Check to see if fail-over now works by removing eth1 from bond0:

sudo ifenslave -d bond0 eth1

Check to see if you can still ping the gateway:

ping -c2 192.168.1.1

Add eth1 back to bond0:

sudo ifenslave bond0 eth1

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183
  • This answers the question indirectly. I wanted automated fail-back after connecting physical cable. I managed to attain that by adding a script in ifup/ifdown folder. – Paul Justin Aug 10 '17 at 05:14
  • @PaulJustin Did you even try this suggested answer or did you go another route for your own? – Terrance Aug 10 '17 at 05:18
  • @PaulJustin If you found a solution not already posted that fixed your problem, I recommend posting it as an answer yourself. Your answer could describe how you added the script and give the contents of the script (possibly with modifications or redaction, if you feel that is necessary), and any other information that would help someone else use your solution. Then future readers who arrive here will be able to benefit both from this answer and your answer. – Eliah Kagan Aug 10 '17 at 15:37
  • @Terrance we have followed your steps for active backup in ubuntu 18.04 server, Though the configurations are set, but there is no internet connection. – Purushothaman Jan 10 '19 at 08:27
  • @Purushothaman 18.04 has a different way of configuring active backup. I will have to write another answer or add on a new section to this one about doing it. Sorry that this one didn't work for now. – Terrance Jan 10 '19 at 14:42