Nowadays most of servers come with two or more network interfaces to allow load balancing or fault tolerance. Debian supports bonding interfaces in the next way. Is recommended running these commands from the console.
Install first ifenslave utilities
# apt get install ifenslave-2.6
Stop networking running:
# /etc/init.d/networking stop
Now add the modules to be loaded editing the file /etc/modprobe.d/bonding with next lines
alias bond0 bonding options bonding mode=1 miimon=100 downdelay=200 updelay=200 arp_ip_target=192.168.3.1
Mode options can be changed to change bonding behavior, like double bandwith or fault tolerance:
- Mode 0 (balance-rr)
This mode transmits packets in a sequential order from the first available slave through the last. If two real interfaces are slaves in the bond and two packets arrive destined out of the bonded interface the first will be transmitted on the first slave and the second frame will be transmitted on the second slave. The third packet will be sent on the first and so on. This provides load balancing and fault tolerance.
- Mode 1 (active-backup)
This mode places one of the interfaces into a backup state and will only make it active if the link is lost by the active interface. Only one slave in the bond is active at an instance of time. A different slave becomes active only when the active slave fails. This mode provides fault tolerance.
- Mode 2 (balance-xor)
Transmits based on XOR formula. (Source MAC address is XOR’d with destination MAC address) modula slave count. This selects the same slave for each destination MAC address and provides load balancing and fault tolerance.
- Mode 3 (broadcast)
This mode transmits everything on all slave interfaces. This mode is least used (only for specific purpose) and provides only fault tolerance.
- Mode 4 (802.3ad)
This mode is known as Dynamic Link Aggregation mode. It creates aggregation groups that share the same speed and duplex settings. This mode requires a switch that supports IEEE 802.3ad Dynamic link.
- Mode 5 (balance-tlb)
This is called as Adaptive transmit load balancing. The outgoing traffic is distributed according to the current load and queue on each slave interface. Incoming traffic is received by the current slave.
- Mode 6 (balance-alb)
This is Adaptive load balancing mode. This includes balance-tlb + receive load balancing (rlb) for IPV4 traffic. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the server on their way out and overwrites the src hw address with the unique hw address of one of the slaves in the bond such that different clients use different hw addresses for the server.
Now fill /etc/network/interfaces configuration file with the correct devices (always backup this file before modify anything :), comment or delete current eth0 and eth1 configuration and add next lines:
auto bond0 iface bond0 inet static address 172.25.88.20 netmask 255.255.255.0 broadcast 172.25.88.255 gateway 172.25.88.1 slaves eth0 eth1
Instead of create /etc/modprobe.d/bonding file, you can add same parameters inside above interfaces file, after slaves eth0 eth1 like:
auto bond0 iface bond0 inet static address 172.25.88.20 netmask 255.255.255.0 broadcast 172.25.88.255 gateway 172.25.88.1 slaves eth0 eth1 bond-mode active-backup bond-miimon 100 bond-downdelay 200 bond-updelay 200
Now reboot the server and check your configuration is working properly. Remember always to have access to the console, just in case of problems.