System: Debian Sarge 3.1 (vanilla kernel 2.6.12.4)
Modules Involved: bonding, mii, nic_module (e100 in this example)
Utilities: ifenslave, mii-tool
Preparation:
Before attempting to bond two NICs, it is highly recommended that you verify the integrity and functionality of each NIC on its own. This document assumes that you've already done that. Using 'mii-tool' you should see something like the following:
testbox:/# mii-tool
eth0: negotiated 100baseTx-FD, link ok
eth1: negotiated 100baseTx-FD, link ok
In order for this to work, the kernel must have support for bonding
devices. A few ways to check would be:
testbox:/# modprobe --list | grep bonding/lib/modules/2.6.12.4-vs2.0/kernel/drivers/net/bonding/bonding.ko
testbox:/# cat /boot/config-2.6.12.4-vs2.0 | grep -i bonding
CONFIG_BONDING=m
We use the mii-tool (mii.o module) to monitor the interfaces for
failover... though, as most ethernet adapters use an MII (Media
Independant Interface) to autonegotiate link speeds, its pretty standard
that you'd have this.
testbox:/# cat /boot/config-2.6.12.4-vs2.0 | grep -i mii# CONFIG_MPENTIUMII is not set
# CONFIG_MPENTIUMIII is not set
CONFIG_MII=y
testbox:/# modprobe --list | grep -i mii
/lib/modules/2.4.26-2-686/kernel/drivers/net/mii.ko
Second, your going to need to install the ifenslave utility.
testbox:/# apt-get update && apt-get install ifenslave
.......... removed standard output (nothing interesting)
Theres no configuration here, so that is that. Now we are ready for
the configuration files.
Configuration Files:
There are many different variations of this, but for now... this is how I did it to get it working.
vi /etc/modutils/aliases and add/edit the following:
alias bond0 bonding
alias eth0 e100
alias eth1 e100
options bonding mode=0 miimon=100
vi /etc/modutils/actions and add/edit the following:
probeall bond0 eth0 eth1 bonding
After editing the modprobe config files you need to run the command:
testbox# update-modules
vi /etc/network/interfaces and add/edit the following:
auto bond0
iface bond0 inet static
address 10.1.100.63
netmask 255.255.255.0
hwaddress ether 00:02:B3:48:50:2C
gateway 10.1.100.1
up ifenslave bond0 eth0 eth1
down ifenslave -d bond0 eth0 eth1
You do NOT set up entries for 'eth0' or 'eth1' outside of whats listed above under the 'bond0' entry. Bond0 will now be the interface that the kernel works with. running an 'ifconfig' will show all three interface (bond0,eth0,eth1), all with the same MAC and IP addresses.
And thats basically it. Now, all you should need to do is load the 'bonding' module and stop/start networking... and the apropriate modules should load automagically:
testbox:/# modprobe bonding
testbox:/# /etc/init.d/networking stoptestbox:/# /etc/init.d/networking start
You might have to play around with this part for a bit. For me I had to manually ifconfig up the bond0 device:
testbox:/# ifconfig bond0 10.1.15.63 netmask 255.255.255.0 up
In a higher end environment, you could plug each NIC into a separate switch (staying on the same VLAN) and further improve your high availability config... and so on and so forth.
Source from : http://www.howtoforge.com/nic_bonding
1 則留言:
[1] Network Bonding supported modes
You can set up your bond interface according to your needs. In order to do this, you simply change the mode type depicted in the examples below (mode=X). There are seven mode types available. They are as follows:
mode=0
This mode uses the Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
mode=1
This mode uses an 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.
mode=2
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.
mode=3
Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.
mode=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:
1. Ethtool support in the base drivers for retrieving the speed and duplex of each slave.
2. A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will require some type of configuration to enable 802.3ad mode
mode=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.
*Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.
mode=6
Adaptive load balancing: includes balance-transmit load balancing plus receive load balancing 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.
發佈留言