Bonding Ethernet Interfaces in Linux *UPDATED*

This short HOWTO will tell you how to 'bond' two (or more) physical ethernet interfaces together to look and act as a single interface under Linux.

It was originally written for Mandrakelinux users but it has also been tested on recent versions of Mandriva Linux.

HOWTO

This example assumes you have two interfaces and want to use them in a 'fail-over' setup, where if one cable dies, the kernel will automatically switch to using the other cable.. This setup is quite common on server hardware.

In /etc/modules.conf on a 2.4.x kernel, or in /etc/modprobe.conf on a 2.6.x kernel, you should have something similar to the following:


	alias eth0 e1000	# Intel GigE (pci) port 1
	alias eth1 e1000	# Intel GigE (pci) port 2

	alias bond0 bonding				# Kernel nic bonding driver
	alias bond1 bonding				# Another bonded interface
	options bond0 max_bonds=2 miimon=100 mode=1	# 100ms fail-over timer. Mode 1 = Active/Backup
	options bond1 miimon=100 mode=1			# Same for bond1 

You need the following files in /etc/sysconfig/network-scripts/ :


	ifcfg-bond0
	ifcfg-eth0
	ifcfg-eth1

ifcfg-eth0 and ifcfg-eth1 should look similar to the following:


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

The DEVICE= section should reflect the interface the file relates to (ifcfg-eth1 should have DEVICE=eth1). The MASTER= section should indicate the bonded interface to be used. Assign both e1000 devices to bond0.

The bond0 file contains the actual IP address information:


	DEVICE=bond0
	IPADDR=192.168.1.1
	NETMASK=255.255.255.0
	ONBOOT=yes
	BOOTPROTO=none
	USERCTL=no
	MII_NOT_SUPPORTED=yes

Simply restarting the network service 'service network restart' should present you with a new 'bond0' interface. This is the interface you should see traffic going in and out of if youwere to tcpdump the interface.

You will also notice (using /sbin/ifconfig) that all of the ethX interfaces are also up, and also have IP addresses.


bond0     Link encap:Ethernet  HWaddr 00:04:23:61:06:30
	  inet addr:192.168.1.1  Bcast:194.61.191.127  Mask:255.255.255.224
          inet6 addr: fe80::204:23ff:fe61:630/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:240339580 errors:0 dropped:0 overruns:0 frame:0
          TX packets:264367658 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3328878476 (3174.6 Mb)  TX bytes:2497930422 (2382.2 Mb)

eth0      Link encap:Ethernet  HWaddr 00:04:23:61:06:30
          inet6 addr: fe80::204:23ff:fe61:630/64 Scope:Link
          UP BROADCAST RUNNING NOARP SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:43224057 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50149177 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:965949319 (921.2 Mb)  TX bytes:3242163496 (3091.9 Mb)
          Base address:0xdcc0 Memory:fcfa0000-fcfc0000

eth1      Link encap:Ethernet  HWaddr 00:04:23:61:06:30
          inet6 addr: fe80::204:23ff:fe61:630/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:197115526 errors:0 dropped:0 overruns:0 frame:0
          TX packets:214218484 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2362929367 (2253.4 Mb)  TX bytes:3550735168 (3386.2 Mb)
          Base address:0xdc80 Memory:fcf80000-fcfa0000

In this example, we are using the fail-over mode. The eth device without NOARP is the current active SLAVE. You may notice that both ethX interfaces have high traffic counters. This is because the system has been up for around 200 days and at some point the interfaces swapped status.

For further reading, you should also read /usr/src/linux/Documentation/networking/bonding.txt which also gives the different bonding modes you can use. Some of these (like Etherchannel trunking) need compatible switches.





Updated: 22/11/2006. Copyright © Mark Watts 2003-2006

Valid XHTML 1.1! Valid CSS!

Creative Commons License

This work is licensed under a Creative Commons License.