Thursday, August 18, 2005

Ethernet bonding revisited


Ethernet bonding

2 days ago I was able to do ethernet bonding for my Linux box which acts as a proxy server and firewall. What I did was to bond two private network interfaces to act as one. What I need to do was installing 2 NICs and setting the driver (autodetect on modern distros). Then I need to create the bonding interface like this :

~#modprobe bonding mode=0 miimon=100

~#ifconfig bond0 192.168.0.2 netmask 255.255.255.0 up

~#ifenslave bond0 eth0

~#ifenslave bond0 eth1

Note:

bond0 is the "bond" interface. eth0 and eth1 are the interfaces to be bonded so called slave devices (or interfaces).They are connected to my private network (LAN). The bond interface will have MAC address of the first slave device to be its MAC address. Please take note that the mode=0 means that we want load-balancing capability. You can use this bond interface in iptables command or tcpdump. In my network environment, I use this command to the bond0 interface:

~#iptables -t nat -A PREROUTING -s 192.168.0.0/24 -d 0/0 -i bond0 -p tcp --dport 80 -j REDIRECT --to-port 3128

where squid is running on port 3128. If not, change it accordingly. For tcpdump :

~#tcpdump -i bond0

I wish you all good luck and happy bonding! :-)

No comments: