Channel Bonding en mode 802.3ad (redondance de lien + équilibrage de charge)

On utilise pour ça le mode 802.3ad.

Installation de ifenslave :

apt-get install ifenslave-2.6

Fichier /etc/network/interfaces :

auto bond0
iface bond0 inet static
    slaves eth0 eth1
    bond-mode 802.3ad
    bond-miimon 100
    bond-downdelay 200
    bond-updelay 200
    address 192.168.0.1
    network 255.255.255.0
    gateway 192.168.0.254
Il peut être nécessaire de forcer le mode de bonding au moment du chargement du module kernel (rencontré avec un switch Cisco notamment et le mode 802.3ad). Dans ce cas, éditer le fichier /etc/modprobe.d/bonding.conf et ajouter :
options bonding mode=4 miimon=100

Utilisation avec des VLANs

auto bond0
iface bond0 inet manual
    slaves eth0 eth1
    bond-mode 802.3ad
    bond-miimon 100
    bond-downdelay 200
    bond-updelay 200

auto vlan1
iface vlan1 inet static
    vlan-raw-device bond0    
    address 192.168.0.1
    network 255.255.255.0
    gateway 192.168.0.254
    
auto vlan2
iface vlan2 inet static
    vlan-raw-device bond0    
    address 192.168.1.1
    network 255.255.255.0

Mode de bonding supporté par le kernel Linux

Nom ID Description
balance-rr 0 Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
active-backup 1  Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.
balance-xor XOR policy: Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.
broadcast 3 Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.
802.3ad 4 IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification. Pre-requisites : Ethtool support in the base drivers for retrieving the speed and duplex of each slave. The switch must supports IEEE 802.3ad Dynamic link aggregation. Most switches will require some type of configuration to enable 802.3ad mode.
balance-tlb 5 Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave. Pré-requis : Ethtool support in the base drivers for retrieving the speed of each slave.
balance-alb 6 Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.

Procédures

Changer d'interface active

  • Lister les interfaces :
    cat /sys/devices/virtual/net/bond0/bonding/slaves
  • Voir l'interface active :
    cat /sys/devices/virtual/net/bond0/bonding/primary
  • Changer d'interface active :
    echo eth1 > /sys/devices/virtual/net/bond0/bonding/primary