Criando Bond - CentOS 7.4
Criando Bond - CentOS 7.4
5 | Unixmen
Linux allows us to bond multiple network interfaces into single interface using a special
kernel module named bonding. The Linux bonding driver provides a method for
combining multiple network interfaces into a single logical “bonded” interface. The
Ad depends upon the mode; generally speaking, modes
behaviour of the bonded interfaces ✕
provide either hot standby or load balancing services. Additionally, link integrity
monitoring, may be performed.
mode=0 (balance-rr)
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 1/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
mode=1 (active-backup)
Active-backup policy: In this mode, only one slave in the bond is active. The other
one will become active, only when the active slave fails. The bond’s MAC address is
externally visible on only one port (network adapter) to avoid confusing the switch. This
mode provides fault tolerance.
mode=2 (balance-xor)
XOR policy: Transmit based on [(source MAC address XOR’d with destination MAC
address) modulo slave count]. This selects the same slave for each destination MAC
address. This mode provides load balancing and fault tolerance.
mode=3 (broadcast)
Broadcast policy: transmits everything on all slave interfaces. This mode provides
fault tolerance.
mode=4 (802.3ad)
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the
same speed and duplex settings. Utilizes all slaves in the active aggregator according to
the 802.3ad specification.
Prerequisites:
– Ethtool support in the base drivers for retrieving the speed and duplex of each
slave.
– A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will
require some type of configuration to enable 802.3ad mode.
mode=5 (balance-tlb)
Adaptive transmit load balancing: channel bonding that does not require any
special switch support. The outgoing traffic is distributed according to the current load
(computed relative to the speed) on each slave. Incoming traffic is received by the
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 2/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
current slave. If the receiving slave fails, another slave takes over the MAC address of
the failed receiving slave.
Prerequisite:
– Ethtool support in the base drivers for retrieving the speed of each slave.
mode=6 (balance-alb)
Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for
IPV4 traffic, and does not require any special switch support. The receive load
balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies
sent by the local system on their way out and overwrites the source hardware address
with the unique hardware address of one of the slaves in the bond such that different
peers use different hardware addresses for the server.
In this handy tutorial let us see how to setup network bonding on CentOS 7 and CentOS
6.5. Though it was tested on CentOS, it should work on RHEL and Scientific Linux 6.x
versions.
1. enp0s3;
2. enp0s8;
3. enp0s9.
Let us combine two NICs (enp0s8, and enp0s9) and make them into one NIC named
bond0.
In CentOS 7, the bonding module is not loaded by default. Enter the following command
as root user to enable it.
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 3/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
modinfo bonding
Sample output:
filename: /lib/modules/3.10.0-
123.el7.x86_64/kernel/drivers/net/bonding/bonding.ko
alias: rtnl-link-bond
author: Thomas Davis, tadavis@lbl.gov and many others
description: Ethernet Channel Bonding Driver, v3.7.1
version: 3.7.1
license: GPL
srcversion: E52AE00A79EA6FEFB5BF718
depends:
intree: Y
vermagic: 3.10.0-123.el7.x86_64 SMP mod_unload modversions
signer: CentOS Linux kernel signing key
sig_key: BC:83:D0:FE:70:C6:2F:AB:1C:58:B4:EB:AA:95:E3:93:61:28:FC:F4
sig_hashalgo: sha256
parm: max_bonds:Max number of bonded devices (int)
parm: tx_queues:Max number of transmit queues (default = 16) (int)
parm: num_grat_arp:Number of peer notifications to send on failover
event (alias of num_unsol_na) (int)
parm: num_unsol_na:Number of peer notifications to send on failover
event (alias of num_grat_arp) (int)
parm: miimon:Link check interval in milliseconds (int)
parm: updelay:Delay before considering link up, in milliseconds (int)
parm: downdelay:Delay before considering link down, in milliseconds
(int)
parm: use_carrier:Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for
off, 1 for on (default) (int)
parm: mode:Mode of operation; 0 for balance-rr, 1 for active-backup, 2
for balance-xor, 3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, 6 for balance-
alb (charp)
parm: primary:Primary network device to use (charp)
parm: primary_reselect:Reselect primary slave once it comes up; 0 for
always (default), 1 for only if speed of primary is better, 2 for only on active
slave failure (charp)
parm: lacp_rate:LACPDU tx rate to request from 802.3ad partner; 0 for
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 4/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
Go to the directory where CentOS stores the network configuration files. By default RHEL
and its clones such as CentOS, Scientific Linux stores the network configuration files under
/etc/sysconfig/network-scripts/ directory.
vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
NAME=bond0
TYPE=Bond
BONDING_MASTER=yes
IPADDR=192.168.1.150
PREFIX=24
ONBOOT=yes
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 5/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
BOOTPROTO=none
BONDING_OPTS="mode=1 miimon=100"
Note: Here, BONDING_OPTS describes the bonding mode. In our case, we will be
configuring mode1(active-backup). Save and close file. 192.168.1.150 is bond0 IP
address.
Now, we should modify both(enp0s8 & enp0s9) configuration files as shown below. First,
let us start from enp0s8.
vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
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
vi /etc/sysconfig/network-scripts/ifcfg-enp0s9
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 6/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
HWADDR=08:00:27:E7:ED:8E
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=enp0s9
UUID=e2352c46-e1f9-41d2-98f5-af24b127b3e7
ONBOOT=yes
MASTER=bond0
SLAVE=yes
ifup ifcfg-enp0s8
ifup ifcfg-enp0s9
Now, enter the following command to make Network Manager aware the changes.
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 7/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
Now enter the following command to check whether the bonding interface bond0 is up and
running:
cat /proc/net/bonding/bond0
Sample output:
As you see in the above output, the bond0 interface is up and running and it is configured
as active-backup(mode1) mode. In this mode, only one slave in the bond is active. The
other one will become active, only when the active slave fails.
To view the list of network interfaces and their IP address, enter the following command:
ip addr
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 8/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
Sample output:
That’s it.
I want to assign multiple IP addresses to bond0 interface. What should i do? Very simple,
just create an alias for the bond0 interface and assign multiple IP addresses.
Let me make it more clear. Say for example we want to assign IP address 192.168.1.151
to bond0. To create an alias for bond0, copy the existing configuration file(ifcfg-bond0)
to a new configuration file(ifcfg-bond0:1).
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 9/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
cp /etc/sysconfig/network-scripts/ifcfg-bond0 /etc/sysconfig/network-
scripts/ifcfg-bond0:1
vi /etc/sysconfig/network-scripts/ifcfg-bond0:1
DEVICE=bond0:1
NAME=bond0
TYPE=Bond
BONDING_MASTER=yes
IPADDR=192.168.1.151
PREFIX=24
ONBOOT=yes
BOOTPROTO=none
BONDING_OPTS="mode=1 miimon=100"
Here,
Save and close the file. Restart network service to take effect the saved changes.
Now list out the network interfaces and their IP address using the command:
ip addr
Sample output:
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 10/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
As you above the alias bond0:1 has been created and it’s up now.
I have three network interfaces, namely eth0, eth1 and eth2 in my CentOS 6.5 system.
Let us combine two NICs (eth1 and eth2) and make them into one NIC named bond0.
Go to the directory where CentOS stores the network configuration files. By default RHEL
and its clones such as CentOS, Scientific Linux stores the network configuration files under
/etc/sysconfig/network-scripts/ directory.
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 11/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.200
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BONDING_OPTS="mode=1 miimon=100"
Note: Here BONDING_OPTS describes the bonding mode. In our case, we will be
configuring mode1(active-backup). Save and close file. 192.168.1.200 is bond0 IP
address.
Next we have to load up the bond0 interface into the kernel. To do that, create a new file
/etc/modprobe.d/bonding.conf,
vi /etc/modprobe.d/bonding.conf
Now we should modify both(eth1 & eth2) configuration files as shown below. First, let us
start from eth1.
vi /etc/sysconfig/network-scripts/ifcfg-eth1
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 12/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
DEVICE=eth1
MASTER=bond0
SLAVE=yes
USERCTL=no
ONBOOT=yes
BOOTPROTO=none
# vi /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
MASTER=bond0
SLAVE=yes
USERCTL=no
ONBOOT=yes
BOOTPROTO=none
modprobe bonding
Now enter the following command to check whether the bonding interface bond0 is up and
running:
cat /proc/net/bonding/bond0
Sample output:
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 13/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
As you see in the above output, the bond0 interface is up and running and it is configured
as active-backup(mode1) mode. In this mode, only one slave in the bond is active. The
other one will become active, only when the active slave fails.
To view the list of network interfaces and their IP address, enter the following command:
# ifconfig
Sample output:
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 14/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
As per the above output, bond0 is configured as master; eth1 and eth2 are configured
as a slave.
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 15/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
I want to assign multiple IP addresses to bond0 interface. What should i do? Very simple,
just create an alias for the bond0 interface and assign multiple IP addresses.
Let me make it more clear. Say for example we want to assign IP address 192.168.1.201
to bond0. To create an alias for bond0, copy the existing configuration file(ifcfg-bond0)
to a new configuration file(ifcfg-bond0:1).
cp /etc/sysconfig/network-scripts/ifcfg-bond0 /etc/sysconfig/network-
scripts/ifcfg-bond0:1
vi /etc/sysconfig/network-scripts/ifcfg-bond0:1
DEVICE=bond0:1
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.201
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BONDING_OPTS="mode=1 miimon=100"
Save and close the file. Restart network service to take effect the saved changes.
Now list out the network interfaces and their IP address using the command:
ifconfig
Sample output:
You should see the alias bond0:1 has been created and up.
SK
http://www.ostecnix.com/
A Linux enthusiast, FOSS Supporter & Linux Consultant from Tamilnadu, India.
Jessica Lange? Try Not to Smile When You See Her Now
Parentz Talk
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 18/19
18/07/2018 Linux Basics: Create Network Bonding On CentOS 7/6.5 | Unixmen
https://www.unixmen.com/linux-basics-create-network-bonding-on-centos-76-5/ 19/19