cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

os:linux:network:bonding.html



Bonding - How to Configure Network Bonding in Linux

RHEL8/CentOS8,RHEL7/CentOS7 Bonding Configuration

Enable bonding module

# modprobe --first-time bonding
# lsmod | grep bonding
bonding 129237 0

nmcli

# nmcli con add type bond ifname bond0 con-name bond0 bond.options "mode=1 miimon=100 "
# nmcli con mod bond0 autoconnect yes
# nmcli con add type ethernet ifname eth0 con-name eth0 master bond0
# nmcli con add type ethernet ifname eth1 con-name eth1 master bond0


RHEL6/CentOS6 Bonding Configuration

Bonding Configuration

/etc/modprobe.d/bonding.conf

alias bond0 bonding


Interfaces Configurations

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

BONDING_OPTS is need.

DEVICE=bond0
BOOTPROTO=dhcp
ONBOOT=yes
BONDING_OPTS="mode=1 miimon=100"

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
MASTER=bond0
SLAVE=yes
BOOTPROTO=none


RHEL5/CentOS5 Bonding Configuration

Bonding Configuration

/etc/modprobe.conf

formerly(/etc/modules.conf)

alias bond0 bonding
options bond0 miimon=100 mode=1


Interfaces Configurations

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

DEVICE=bond0
IPADDR=192.168.0.10
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=static

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
MASTER=bond0
SLAVE=yes
BOOTPROTO=none


Ubuntu 20.04, 18.04 Bonding Configuration

network:
  version: 2
  renderer: networkd
  ethernets:
    em1:
      dhcp4: no
      dhcp6: no
    em2:
      dhcp4: no
      dhcp6: no
  bonds:
    bond0:
      dhcp4: no
      dhcp6: no
      interfaces:
        - em1
        - em2
      macaddress: "xx:xx:xx:xx:2b:62"
      parameters:
        mode: 802.3ad
        lacp-rate: fast
        mii-monitor-interval: 100
        transmit-hash-policy: layer2+3
network:
  version: 2
  renderer: networkd
  ethernets:
    em1:
      dhcp4: no
      dhcp6: no
    em2:
      dhcp4: no
      dhcp6: no
  bonds:
    bond0:
      dhcp4: no
      dhcp6: no
      interfaces:
        - em1
        - em2
      macaddress: "xx:xx:xx:xx:2b:62"
      parameters:
        mode: 802.3ad
        lacp-rate: fast
        mii-monitor-interval: 100
        transmit-hash-policy: layer2+3
  bridges:
    br0:
      dhcp4: yes
      dhcp6: yes
      macaddress: "xx:xx:xx:xx:2b:62"
      interfaces:
        - bond0


Ubuntu 16.04 Bonding Configuration

# apt-get install ifenslave

/etc/modules

...
bonding
...


/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eno1
iface eno1 inet manual
  bond-master bond0

auto eno2
iface eno2 inet manual
  pre-up sleep 5
  bond-master bond0

auto bond0
  iface bond0 inet dhcp
  bond-slaves eno1 eno2
  bond-primary eno1 eno2
  bond-mode active-backup
  bond-miimon 100






Bonding Mode

value mode explanation switch
0 balance-rr
load balancing (round-robin)
Trunking
1 active-backup
fault-tolerance
Many system uses this mode. VLAN
2 Balance-XOR
load balancing (xor)
Trunking
3 Broadcast
fault-tolerance
VLAN
4 802.3ad
IEEE 802.3ad Dynamic link aggregation
IEEE 802.3ad
5 Balance-tlb
transmit load balancing
VLAN
6 Balance-alb
adaptive load balancing
VLAN

Bonding Mode Example

active-backup (mode=1)
alias bond0 bonding
options bond0 mode=1
options bond0 miimon=100 
alias bond0 bonding
options bond0 miimon=100 mode=1 primary=eth0
alias bond0 bonding
options bond0 mode=1 arp_interval=1000 arp_ip_target=192.168.10.1,192.168.10.2
round-robin (default mode)
alias bond0 bonding
options bond0 miimon=0 arp_interval=1000 arp_ip_target=192.168.0.1,192.168.0.2,192.168.0.3


Checking the Bonding status

/proc/net/bonding/bond0

# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth4                    <- Active Interface : eth4
MII Status: up                                  <- up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up                                   <- up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 1c:c1:de:xx:xx:xx

Slave Interface: eth4
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:26:55:xx:xx:xx

SNMP MIB

# snmpwalk -v 1 -c public 192.168.1.101 interfaces
(abbr)
interfaces.ifTable.ifEntry.ifDescr.1 = lo
interfaces.ifTable.ifEntry.ifDescr.2 = bond1
interfaces.ifTable.ifEntry.ifDescr.3 = bond0
interfaces.ifTable.ifEntry.ifDescr.4 = eth0
interfaces.ifTable.ifEntry.ifDescr.5 = eth1
interfaces.ifTable.ifEntry.ifDescr.6 = eth2
interfaces.ifTable.ifEntry.ifDescr.7 = eth3
interfaces.ifTable.ifEntry.ifDescr.8 = eth4
interfaces.ifTable.ifEntry.ifDescr.9 = eth5
(abbr)

# snmpwalk -v 1 -c public 192.168.1.101 ip
(abbr)
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.1.101 = 3
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.2.1 = 4
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.3.1 = 6
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.4.101 = 2
(abbr)
#


Operation Note

How to change Active Interface

from eth1 to eth0

# cat /proc/net/bonding/bond0 |grep Currently
Currently Active Slave: eth1

# ifconfig eth1 down

# cat /proc/net/bonding/bond0 |grep Currently
Currently Active Slave: eth0

# ifconfig eth1 up
# cat /proc/net/bonding/bond0 |grep Currently

# cat /proc/net/bonding/bond0 |grep Currently
Currently Active Slave: eth0


load Bonding module




os/linux/network/bonding.html.txt ยท Last modified: 2021/03/16 by admin

Page Tools