Friday, December 30, 2011

combine two or multiple NIC network cards ISP using network link aggregation and load balance round robin

Hard disk are getting bigger and bigger. Network interface card (NIC) and switch are getting cheaper and cheaper. It usually means more services can squeeze into a server. Combining multiple network interface into 1 big pipe would be a big plus for services that is bandwidth hungry. e.g. file server, email server & etc

Combining 2 or more network interface have a few advantages. One of them is load balancing. Load balancing enables the network interface card to share the load among the 2 or more network interface card defined. It serves as redundancy as well. But load balancing does not makes full use of the 2 or more network interface, it is meant to share network traffic load.

To fully utilize 2 or more network interface links, link aggregation should be used. Link aggregation is a method to combine 2 or more network interface to become a bigger pipe. It is also a way to combine 2 or more interface to use the same IP address. Using link aggregation can also create redundancy, if one of the link fails, the other links will take over.

This post is using FreeBSD as a server because FreeBSD have all the ports (software packages) you will need and server administration on it is made to ease systems administration daily task.Without further ado, below are the steps to configure 2 (or more) network interfaces to work as 1 big trunk or round robin :

Scenario

rl0 = 1st interface card device name
rl1 = 2nd interface card device name
192.168.0.78 = IP address used on both 1st & 2nd network interface card

Setup Link Aggregation on 2 (or more) network interface card

kldload /boot/kernel/ng_ether.ko
kldload /boot/kernel/ng_one2many.ko
ifconfig rl0 up
ifconfig rl1 up
ngctl mkpeer rl0: one2many upper one
ngctl connect rl0: rl0:upper lower many0
ngctl connect rl1: rl0:upper lower many1
ngctl msg rl1: setpromisc 1
ngctl msg rl1: setautosrc 0
ngctl msg rl0:upper \
setconfig "{ xmitAlg=1 failAlg=2 enabledLinks=[ 1 1 ] }"
ifconfig rl0 inet 192.168.0.78

Restore NIC to original status from the previous setup

ngctl rmhook em0: lower
(remove notes / services from inteface rl0)

Setup Round Robin on 2 (or more) network interface card

kldload /boot/kernel/ng_ether.ko
kldload /boot/kernel/ng_one2many.ko
ifconfig rl0 up
ifconfig rl1 up
ngctl mkpeer rl0: one2many upper one
ngctl connect rl0: rl0:upper lower many0
ngctl connect rl1: rl0:upper lower many1
ngctl msg rl1: setpromisc 1
ngctl msg rl1: setautosrc 0
ngctl msg rl0:upper \
setconfig "{ xmitAlg=2 failAlg=2 enabledLinks=[ 1 1 ] }"
ifconfig rl0 inet 192.168.0.78

Permanently make the changes take effect, put it in rc.local

e.g.


kldload /boot/kernel/ng_ether.ko
kldload /boot/kernel/ng_one2many.ko
ifconfig rl0 up
ifconfig rl1 up
ngctl mkpeer rl0: one2many upper one
ngctl connect rl0: rl0:upper lower many0
ngctl connect rl1: rl0:upper lower many1
ngctl msg rl1: setpromisc 1
ngctl msg rl1: setautosrc 0
ngctl msg rl0:upper \
setconfig "{ xmitAlg=1 failAlg=2 enabledLinks=[ 1 1 ] }"
ifconfig rl0 inet 192.168.0.78


ngctl can be run interactively for diagnostic purpose. Below list a few example :
list ### show list of nodes ###
show em0: ### show information of a node tied interface em0 ###

Au revoir !!!

Reference:
http://scratching.psybermonkey.net/2009/06/freebsd-combine-2-or-more-nic-using.html

No comments: