Bonding of Linux Network interfaces

What is Network bonding and why should I use it?

Bonding provides a method for aggregating multiple network interfaces into a single logical “bonded” interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed. So if you have multiple NICs it would be a good idea to give bonding a try.

How do I configure my RHEL/CENTOS server for use with bonding?

From a RHEL/CENTOS 6 server it’s quite easy.

Lets say your config is the following: first NIC is eth0 and second is eth1. We are going to use bond0 for our first bonding interface

Edit /etc/modprobe.d/dist.conf and the following line to the bottom.

alias bond0 bonding

next we will edit /etc/sysconfig/network-scripts/ifcfg-eth0

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

Next do the same for /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
IPV6INIT=no
USERCTL=no

Now we create the new bonding interface by creating /etc/sysconfig/network-scripts/ifcfg-bond0 (Please change the IP configuration to match your network.)

DEVICE=bond0
IPADDR=192.168.1.2
NETWORK=192.168.1.0
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=4.4.4.4
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
IPV6INIT=no
BONDING_OPTS=”mode=balance-alb miimon=100″

Next we restart the network. It’s recommended that you are at a console to do this step and not a SSH session.

/etc/init.d/network restart

ping your gateway: ping <your gateway>

ping 192.168.1.1

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=255 time=1.78 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=0.872 ms

If you have similar output We have connectivity!

Now lets look at out config

ip addr
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:1e:68:04:7a:10 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:1e:68:04:7a:11 brd ff:ff:ff:ff:ff:ff
3: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 00:1e:68:04:7a:0e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2 brd 192.168.1.255 scope global bond0
inet6 fe80::21e:68ff:fe04:7a0e/64 scope link
valid_lft forever preferred_lft forever

If your output looks like similar to above congratulations you’ve bonded your first two interfaces together.

For additional bonds just increment the interfaces. i.e bond1 with eth2 & eth3.

Tips:

If your using Virtualbox server here are the recommended bonding options for /etc/sysconfig/network-scripts/ifcfg-bond0

BONDING_OPTS=”mode=1 miimon=100 fail_over_mac=1″

Also change your virtual device Adapter type to
Intel PRO/1000 T Server.
I had to learn this from trail and error since the original config did not work.

The UMW Linux Administrator

Posted in Uncategorized | Leave a comment

Nifty get version script for Linux/Unix

Here’s a simple script I created that grabs all package information from a system, then outputs it to a comma delimited format great for spreadsheets. I grabbed a portion of code from novel’s OSdetech script so this will work on many different Linux distributions

__________

#!/bin/bash
#getversions.sh script by smelendy for umw.
#purpose: grab version info for servers
#OSdetect portion from http://www.novell.com/coolsolutions/feature/11251.html

OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`

GetVersionFromFile()
{
VERSION=`cat $1 | tr “\n” ‘ ‘ | sed s/.*VERSION.*=\ // `
}
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=`uname -p`
OSSTR=”${OS} ${REV}(${ARCH} `uname -v`)”
pkginfo -l |egrep “PKGINST|NAME|VERSION”
elif [ "${OS}" = "Linux" ] ; then
KERNEL=`uname -r`
if [ -f /etc/redhat-release ] ; then
DIST=’RedHat’
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
yum list | awk ‘{print $1, “, version ” $2}’
elif [ -f /etc/debian_version ] ; then
DIST=”Debian `cat /etc/debian_version`”
REV=””
dpkg –list | awk ‘{print $2, “, version ” $3}’
fi
OSSTR=”${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})”
fi
echo ${OSSTR}

echo Version report of `hostname` on ${OSSTR} system has successfully completed on `date`

____

example how to run

getversions.sh >  textfile.csv

 

More Scripts and other tips coming soon,

 

Posted in Uncategorized | Comments Off

Hello world!

Welcome vistors! This is the first of hopefully many posts to come. This site will provide tales of my many adventures of being a systems administrator here at the University of Mary Washington. Till next time.

Posted in Uncategorized | 1 Comment