LINUX BONDING (TEAMING)
Linux Network bonding
Linux network Bonding is creation of a single bonded interface by combining 2 or more Ethernet interfaces. This helps in high availability of your network interface and offers performance improvement. Bonding is same as port trunking or teaming.
Bonding allows you to aggregate multiple ports into a single group, effectively combining the bandwidth into a single connection. Bonding also allows you to create multi-gigabit pipes to transport traffic through the highest traffic areas of your network. For example, you can aggregate three megabits ports into a three-megabits trunk port. That is equivalent with having one interface with three megabytes speed
Steps for bonding in Oracle Enterprise Linux and Redhat Enterprise Linux are as follows..
Step 1.
Create the file ifcfg-bond0 with the IP address, netmask and gateway. Shown below is my test bonding config file.
$ cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.1.12
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
Step 2.
Modify eth0, eth1 and eth2 configuration as shown below. Comment out, or remove the ip address, netmask, gateway and hardware address from each one of these files, since settings should only come from the ifcfg-bond0 file above. Make sure you add the MASTER and SLAVE configuration in these files.
$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
# Settings for Bond
MASTER=bond0
SLAVE=yes
$ cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
# Settings for bonding
MASTER=bond0
SLAVE=yes
$ cat /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
Step 3.
Set the parameters for bond0 bonding kernel module. Select the network bonding mode based on you need The modes are
- mode=0 (Balance Round Robin)
- mode=1 (Active backup)
- mode=2 (Balance XOR)
- mode=3 (Broadcast)
- mode=4 (802.3ad)
- mode=5 (Balance TLB)
- mode=6 (Balance ALB)
Add the following lines to /etc/modprobe.conf
# bonding commands
alias bond0 bonding
options bond0 mode=1 miimon=100
Step 4.
Load the bond driver module from the command prompt.
$ modprobe bonding
Step 5.
Restart the network, or restart the computer.
$ service network restart # Or restart computer
When the machine boots up check the proc settings.
$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.0.2 (March 23, 2006)
Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth2
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:13:72:80: 62:f0
Look at ifconfig -a and check that your bond0 interface is active. You are done!. For more details on the different modes of bonding.
To verify whether the failover bonding works..
- Do an ifdown eth0 and check /proc/net/bonding/bond0 and check the “Current Active slave”.
- Do a continuous ping to the bond0 ipaddress from a different machine and do a ifdown the active interface. The ping should not break.
modes of bonding
These modes determine the way in which traffic sent out of the bonded interface is actually dispersed over the real interfaces. Modes 0, 1, and 2 are by far the most commonly used among them.
Mode 0 (balance-rr)
This mode transmits packets in a sequential order from the first available slave through the last. If two real interfaces are slaves in the bond and two packets arrive destined out of the bonded interface the first will be transmitted on the first slave and the second frame will be transmitted on the second slave. The third packet will be sent on the first and so on. This provides load balancing and fault tolerance.
Mode 1 (active-backup)
This mode places one of the interfaces into a backup state and will only make it active if the link is lost by the active interface. Only one slave in the bond is active at an instance of time. A different slave becomes active only when the active slave fails. This mode provides fault tolerance.
Mode 2 (balance-xor)
Transmits based on XOR formula. (Source MAC address is XOR'd with destination MAC address) modula slave count. This selects the same slave for each destination MAC address and provides load balancing and fault tolerance.
Mode 3 (broadcast)
This mode transmits everything on all slave interfaces. This mode is least used (only for specific purpose) and provides only fault tolerance.
Mode 4 (802.3ad)
This mode is known as Dynamic Link Aggregation mode. It creates aggregation groups that share the same speed and duplex settings. This mode requires a switch that supports IEEE 802.3ad Dynamic link.
Mode 5 (balance-tlb)
This is called as Adaptive transmit load balancing. The outgoing traffic is distributed according to the current load and queue on each slave interface. Incoming traffic is received by the current slave.
Mode 6 (balance-alb)
This is Adaptive load balancing mode. This includes balance-tlb + receive load balancing (rlb) for IPV4 traffic. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the server on their way out and overwrites the src hw address with the unique hw address of one of the slaves in the bond such that different clients use different hw addresses for the server.
LoadBalancing on Centos 6:
vi /etc/modprobe.d/bonding.conf
#add below lines
alias bond0 bonding
options bond0 mode=3 miimon=100
vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
USERCTL=no
BOOTPROTO=none
IPADDR=192.168.5.250
NETMASK=255.255.255.0
NETWORK=192.168.5.0
GATEWAY=192.168.5.5
ONBOOT=yes
BONDING_OPTS="miimon=100 mode=3"
TYPE=unknown
IPV6INIT=no
NAME=bond0
PREFIX=24
DNS1=8.8.4.4
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
UUID=ad33d8b0-1f7b-cab9-9447-ba07f855b143
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
TYPE=Ethernet
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth0
UUID=6fde6027-915b-4bf3-930d-e613ed8bc9cc
HWADDR=00:C0:9F:30:3B:9B
vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
TYPE=Ethernet
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth1
UUID=f123a6f6-b543-4156-8a11-268039eb312a
HWADDR=00:18:F8:0E:AD:A0
vi /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
HWADDR=F8:D1:11:C2:9C:42
TYPE=Ethernet
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth2
UUID=fb864ba7-c7a6-47ed-b9af-1f41f3ab1567
ONBOOT=yes
CentOS 6 Channel Bonding
Channel bonding (also known as “Ethernet bonding”) is a computer networking arrangement in which two or more network interfaces on a host computer are combined for redundancy or increased throughput.
mode=0 (Balance-rr) – This mode provides load balancing and fault tolerance.
mode=1 (active-backup) – This mode provides fault tolerance.
mode=2 (balance-xor) – This mode provides load balancing and fault tolerance.
mode=3 (broadcast) – This mode provides fault tolerance.
mode=4 (802.3ad) – This mode provides load balancing and fault tolerance.
mode=5 (balance-tlb) – Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.
mode=6 (balance-alb) – Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.
Note: Always append extra configuration in case of a rollback.
Configuring Channel Bonding
# cd /etc/sysconfig/network-scripts/
# vi ifcfg-bond0
We’ll be using mode=6 (balance-alb)
1
2 3 4 5 6 7 8 9 10 |
DEVICE=bond0USERCTL=noBOOTPROTO=noneONBOOT=yes
IPADDR=10.0.0.10NETMASK=255.255.0.0NETWORK=10.0.0.0BONDING_OPTS="miimon=100 mode=balance-alb" TYPE=UnknownIPV6INIT=no |
# vi ifcfg-eth0
1
2 3 4 5 6 |
DEVICE=eth0BOOTPROTO=noneONBOOT=yes
MASTER=bond0SLAVE=yes USERCTL=no |
# vi ifcfg-eth1
1
2 3 4 5 6 |
DEVICE=eth1BOOTPROTO=noneONBOOT=yes
MASTER=bond0SLAVE=yes USERCTL=no |
# vi ifcfg-eth2
1
2 3 4 5 6 |
DEVICE=eth2BOOTPROTO=noneONBOOT=yes
MASTER=bond0SLAVE=yes USERCTL=no |
Due to the fact that /etc/modprobe.conf has been deprecated in CentOS 6, the process of bonding network interfaces has changed a bit.
Now instead of defining your bond in your /etc/modprobe.conf, you define it in /etc/modprobe.d/bonding.conf
# vi /etc/modprobe.d/bonding.conf
Append the following onto the end out your modprobe config file
1
|
alias bond0 bonding
|
# service network restart
No comments:
Post a Comment