Skip to content

How to setup bonding

Debian

Install ifenslave package:

apt-get install ifenslave

Edit /etc/network/interfaces file and change eth0 settings:

auto bond0  
iface bond0 inet static  
        address x.x.x.x  
        netmask x.x.x.x  
        gateway x.x.x.x  
        dns-nameservers 78.24.12.150 217.16.191.70  
        dns-search vshosting.cz  
        bond-mode 802.3ad  
        bond-xmit-hash-policy layer3+4  
        bond-lacp-rate 1  
        bond-miimon 100  
        bond-downdelay 200  
        bond-updelay 200  
        slaves eth0 eth1

Ubuntu 18.04 and newer

Create /etc/netplan/config.yaml with the following contents:

network:
 version: 2
 renderer: networkd
 ethernets:
 eno1:
 dhcp4: no
 eno2:
 dhcp4: no
 bonds:
 bond0:
 addresses:
        - XXX.XXX.XXX.XXX/YY
 gateway4: XXX.XXX.XXX.XXX
 nameservers:
 addresses:  
 - 78.24.12.150  
 - 217.16.191.70
 interfaces:
        - eno1
        - eno2
 parameters:
 mode: 802.3ad
 mii-monitor-interval: 100

Then runnetplan apply.

Ubuntu 16.04

The configuration steps are the same as with Debian.

Centos 7 and 8

First you have to enable automatic loading of the bonding support module.

modprobe --first-time bonding

Create  ifcfg-bond0 file:

vi /etc/sysconfig/network-scripts/ifcfg-bond0

and insert

DEVICE=bond0  
NAME=bond0  
TYPE=Bond  
BONDING_MASTER=yes  
IPADDR=x.x.x.x  
PREFIX=xx  
ONBOOT=yes  
BOOTPROTO=none  
BONDING_OPTS="miimon=100 mode=4 lacp_rate=1 xmit_hash=1 downdelay=200 updelay=200"

Configure both interfaces that we want to have in bonding (edit the highlighted line)

vi /etc/sysconfig/networks-scripts/ifcfg-encp0sX
HWADDR="08:00:27:04:03:86"  
TYPE="Ethernet"  
**BOOTPROTO="none"**  
DEFROUTE="yes"  
PEERDNS="yes"  
PEERROUTES="yes"  
IPV4_FAILURE_FATAL="no"  
IPV6INIT="yes"  
IPV6_AUTOCONF="yes"  
IPV6_DEFROUTE="yes"  
IPV6_PEERDNS="yes"  
IPV6_PEERROUTES="yes"  
IPV6_FAILURE_FATAL="no"  
NAME="enp0s8"  
UUID="a97b23f2-fa87-49de-ac9b-39661ba9c20f"  
ONBOOT="yes"  
MASTER=bond0  
SLAVE=yes

Do the same also for the second interface.

Then start the interfaces

ifup ifcfg-enp0sX

If you use Network Manager, you'll need to reload the connection:

nmcli con reload

Finally, restart the network

systemctl restart network

Check the status of bonding

cat /proc/net/bonding/bond0

Centos 6.5

Create ifcfg-bond0 file,

vi /etc/sysconfig/network-script/ifcfg-bond0

and insert:

DEVICE=bond0  
BOOTPROTO=none  
ONBOOT=yes  
IPADDR=x.x.x.x  
NETWORK=x.x.x.x  
NETMASK=x.x.x.x  
USERCTL=no  
BONDING_OPTS="mode=4 miimon=100 lacp_rate=1 xmit_hash=1 downdelay=200 updelay=200"

Create bonding.conf file

vi /etc/modprobe.d/bonding.conf

and insert

alias bond0 bonding

Edit settings for eth0:

vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth1  
MASTER=bond0  
SLAVE=yes  
USERCTL=no  
ONBOOT=yes  
BOOTPROTO=none

Same for eth1.

Run:

modprobe bonding
service network restart

And check the status of bonding:

cat /proc/net/bonding/bond0  

Manual configuration

For manual bonding configuration , e.g. in a situation where the ifenslave package is missing, the following commands can be used in the terminal (eno1, eno2 are server network interfaces)

ip link add bond0 type bond
ip link set bond0 type bond mode 802.3ad
ip link set eno1 down
ip link set eno1 master bond0
ip link set eno2 down
ip link set eno2 master bond0
ip link set bond0 up
ip address add XXX.XXX.XXX.XXX/YY dev bond0
ip route add default via XXX.XXX.XXX.XXX

This procedure isn't persistent, configuration will be lost after reboot.