Centos 6.6/7 Network Bonding

It turns out that Network NIC bonding in Centos 6 isn’t as bad as I thought, the only recommendation I can made is don’t try to set it up via a SSH session, make sure you’re either in a console session or actually in front of the server.

In my system I currently have eth0 and eth1 so I’ll be adding these two devices to the bond.

Make sure you’re in /etc/sysconfig/network-scripts

First create the ifcfg-bond0 file

DEVICE=bond0
IPADDR=xx.xx.xx.xx
NETMASK=xx.xx.xx.xx
GATEWAY=xx.xx.xx.xx
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
USERCTL=no

Next we’ll create the ifcfg-eth0/1 files

ifcfg-eth0

DEVICE=eth0
USERCTL=no
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

The only difference between the eth0/1 files are device, just make sure eth0 says eth0 etc

next we’ll created bonding.conf in /etc/modprobe.d as /etc/modprobe.conf is is depreciated in centos 6

alias bond0 bonding
options bond0 mode=balance-tlb miimon=100 downdelay=200 updelay=200

ok to explain the options a little

mode

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.

miimon

Specifies the MII link monitoring frequency in milliseconds. This determines how often the link state of each slave is inspected for link failures.

Downdelay

Specifies the time, in milliseconds, to wait before disabling a slave after a link failure has been detected.

Updelay

Specifies the time, in milliseconds, to wait before enabling a slave after a link recovery has been detected.

Simples ?

Under normal circumstances you could then once you’ve created all your files, just run modprobe bonding from the command, but this just creates a default bond with a round robin setup, so we don’t want that do we?

Run this from the command line instead

modprobe bonding mode=balance-tlb miimon=100 downdelay=200 updelay=200

It’s at this point, after realising I’m a pillock, that I lost my ssh connecttion so I couldn’t restart networking, oh well off to the server I go

restart networking or reboot the server.

Once back up you can check the bonding is working by looking at the bond0 file or checking the ip config

ip addr show

or the better way /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: transmit load balancing
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:25:64:3b:43:21
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:25:64:3b:43:22
Slave queue ID: 0

Yay it works, job done!

** UPDATE **

This also works on Centos 7

Instead of running the modprobe on it’s own and loosing the connection if you’re running this over SSH you can also issue a reboot command so try this

modprobe bonding mode=balance-tlb miimon=100 downdelay=200 updelay=200 ; reboot

something else i had to do is disable SELINUX and allow samba through the firewall

firewall-cmd –permanent –zone=public –add-service=samba
firewall-cmd –reload

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s