d-h-n.de
Blog about Oracle, Linux..

Bonding on Debian

November 22nd, 2010 . by admin

Test Bonding on Debian(Lenny) using VMWare Workstation

First create a Linux(Debian) host with 3 NICs:

  • 1.NIC: NAT (eth0 for Internet connect)
  • 2.NIC: Brigded (eth1 bonding slave)
  • 3.NIC: Bridged (eth1 bonding slave)

 

Install virtual network device e1000

Power on ther virtual machine then run:

deb5:~# mii-tool
SIOCGMIIPHY on 'eth0' failed: Operation not supported
SIOCGMIIPHY on 'eth1' failed: Operation not supported
SIOCGMIIPHY on 'eth2' failed: Operation not supported
no MII interfaces found

TODO: load module e1000

deb5:~# lsmod | egrep 'pcnet32|vmxnet|e1000'
vmxnet                 18100  0
deb5:~# modprobe e1000
deb5:~# lsmod | egrep 'pcnet32|vmxnet|e1000'
e1000                 102656  0
vmxnet                 18100  0

Add to file bonding.vmx:

..
ethernet0.present = "TRUE"
ethernet0.virtualDev = "e1000"
..
ethernet1.present = "TRUE"
ethernet1.virtualDev = "e1000" 
..
ethernet2.present = "TRUE"
ethernet2.virtualDev = "e1000" 
..

Power on the client, run mii-tool

deb5:~# mii-tool
eth0: negotiated 1000baseT-FD flow-control, link ok
eth1: negotiated 1000baseT-FD flow-control, link ok
eth2: negotiated 1000baseT-FD flow-control, link ok

 

Load kernel modul bonding

First check and load kernel module bonding:

deb5:~# lsmod | grep bonding

also, kernel module bonding is not loaded. We want to load it

If nonding module exists

deb5:~# modprobe -l bonding
/lib/modules/2.6.26-2-686/kernel/drivers/net/bonding/bonding.ko

Load it

deb5:~# modprobe bonding

Check if module bonding loaded?

deb5:~# lsmod | grep bonding
bonding                69604  0
deb5:~# cat /proc/modules | grep bonding
bonding 69604 0 - Live 0xf0bcb000

- On debian ifenslave must be installed
what is ifenslave?
ifenslave is a program to attach and detach slave network devices to a bonding device.

# apt-get install ifenslave-2.6

see: man ifenslave

 

Config bonding

Edit file /etc/modprobe.conf (Create if not exists)

alias bond0 bonding
options bonding mode=1 miimon=100
include /etc/modprobe.d/ 

How to read this:
- bond0 is a alias name for module bonding
- options for bonding/bond0 is: mode=1, miimon=100
- miimon: specifies the MII link monitoring frequency in milliseconds.
This determines how often the link state of each slave is inspected for link failures. A value of zero disables MII link monitoring. A value of 100 is a good starting point.

more see:
man modprobe.conf
modinfo bonding

Bonding parameter:

deb5:~# modinfo bonding
filename:       /lib/modules/2.6.26-2-686/kernel/drivers/net/bonding/bonding.ko
author:         Thomas Davis, tadavis@lbl.gov and many others
description:    Ethernet Channel Bonding Driver, v3.2.5
version:        3.2.5
license:        GPL
srcversion:     8020E5C15A155D4B4664A91
depends:
vermagic:       2.6.26-2-686 SMP mod_unload modversions 686
parm:           max_bonds:Max number of bonded devices (int)
parm:           miimon:Link check interval in milliseconds (int)
parm:           updelay:Delay before considering link up, in milliseconds (int)
parm:           downdelay:Delay before considering link down, in milliseconds (int)
parm:           use_carrier:Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default) (int)
parm:           mode:Mode of operation : 0 for balance-rr, 1 for active-backup, 2 for balance-xor, 3 for broadcast,
                4 for 802.3ad, 5 for balance-tlb, 6 for balance-alb (charp)
parm:           primary:Primary network device to use (charp)
parm:           lacp_rate:LACPDU tx rate to request from 802.3ad partner (slow/fast) (charp)
parm:           xmit_hash_policy:XOR hashing method: 0 for layer 2 (default), 1 for layer 3+4 (charp)
parm:           arp_interval:arp interval in milliseconds (int)
parm:           arp_ip_target:arp targets in n.n.n.n form (array of charp)
parm:           arp_validate:validate src/dst of ARP probes: none (default), active, backup or all (charp)
parm:           fail_over_mac:For active-backup, do not set all slaves to the same MAC.  0 of off (default), 1 for on. (int)

Edit file /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
       address 192.168.37.55
       netmask 255.255.255.0
       network 192.168.37.0
       broadcast 192.168.37.255
       gateway 192.168.37.2

auto bond0
iface bond0 inet static
        address 192.168.1.25
        netmask 255.255.255.0
        network 192.168.1.0
        gateway 192.168.1.1
        up /sbin/ifenslave bond0 eth1 eth2
        down /sbin/ifenslave -d bond0 eth1 eth2

Reboot or run:

/etc/init.d/networking restart

 

Check

deb5:~# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.2.5 (March 21, 2008)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:32:f5:02

Slave Interface: eth2
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:32:f5:0c
deb5:~# ifconfig
bond0     Link encap:Ethernet  HWaddr 00:0c:29:32:f5:02
          inet addr:192.168.1.25  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe32:f502/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:556 (556.0 B)  TX bytes:510 (510.0 B)

eth0      Link encap:Ethernet  HWaddr 00:0c:29:32:f5:f8
          inet addr:192.168.37.55  Bcast:192.168.37.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe32:f5f8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:364 (364.0 B)  TX bytes:814 (814.0 B)

eth1      Link encap:Ethernet  HWaddr 00:0c:29:32:f5:02
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:308 (308.0 B)  TX bytes:0 (0.0 B)

eth2      Link encap:Ethernet  HWaddr 00:0c:29:32:f5:02
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:1 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:248 (248.0 B)  TX bytes:510 (510.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:860 (860.0 B)  TX bytes:860 (860.0 B)

 

Testing

Test bonding per Nagios check check_linux_bonding
Download check-linux-bonding_1.3.0-1_all.deb and install the package:

# dpkg -i check-linux-bonding_1.3.0-1_all.deb

 

Test
eth1 is active, eth2 is passiv
deb5:~# /usr/lib/nagios/plugins/check_linux_bonding
Interface bond0 is up: mode=1 (active-backup), 2 slaves: eth1!, eth2
Switch eth2 to active
deb5:~# ifenslave --change-active bond0 eth2
deb5:~# /usr/lib/nagios/plugins/check_linux_bonding
Interface bond0 is up: mode=1 (active-backup), 2 slaves: eth1, eth2!
Down a NIC
deb5:~# ifconfig eth1 down
deb5:~# /usr/lib/nagios/plugins/check_linux_bonding
Bonding interface bond0 [mode=1 (active-backup)]: Slave eth1 is down
Down 2 NICs
deb5:~# ifconfig eth2 down
deb5:~# /usr/lib/nagios/plugins/check_linux_bonding
Bonding interface bond0 [mode=1 (active-backup)] is down
Up 2 NICs again
deb5:~# ifconfig eth2 up
deb5:~# ifconfig eth1 up
deb5:~# /usr/lib/nagios/plugins/check_linux_bonding
Interface bond0 is up: mode=1 (active-backup), 2 slaves: eth1, eth2!
deb5:~#

 

 

Which NIC is the active, which is passiv by mode=1?

# cat /etc/proc/bonding/bond0

Which bonding mode is running?

# cat /sys/class/net/bond0/bonding/mode

Switch other NIC active, exm eth2

# ifenslave --change-active bond0 eth2

 


Leave a Reply

Name

Mail (never published)

Website