blob: 61f516b135b415986217f130fcadf064a6bf5c83 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002 Linux Ethernet Bonding Driver HOWTO
3
Jiri Pirkoa5499522009-09-25 03:28:09 +00004 Latest update: 23 September 2009
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6Initial release : Thomas Davis <tadavis at lbl.gov>
7Corrections, HA extensions : 2000/10/03-15 :
8 - Willy Tarreau <willy at meta-x.org>
9 - Constantine Gavrilov <const-g at xpert.com>
10 - Chad N. Tindel <ctindel at ieee dot org>
11 - Janice Girouard <girouard at us dot ibm dot com>
12 - Jay Vosburgh <fubar at us dot ibm dot com>
13
14Reorganized and updated Feb 2005 by Jay Vosburgh
Auke Kok6224e012006-06-08 11:15:35 -070015Added Sysfs information: 2006/04/24
16 - Mitch Williams <mitch.a.williams at intel.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Jay Vosburgh00354cf2005-07-21 12:18:02 -070018Introduction
19============
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Jay Vosburgh00354cf2005-07-21 12:18:02 -070021 The Linux bonding driver provides a method for aggregating
22multiple network interfaces into a single logical "bonded" interface.
23The behavior of the bonded interfaces depends upon the mode; generally
24speaking, modes provide either hot standby or load balancing services.
25Additionally, link integrity monitoring may be performed.
26
27 The bonding driver originally came from Donald Becker's
28beowulf patches for kernel 2.0. It has changed quite a bit since, and
29the original tools from extreme-linux and beowulf sites will not work
30with this version of the driver.
31
32 For new versions of the driver, updated userspace tools, and
33who to ask for help, please follow the links at the end of this file.
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35Table of Contents
36=================
37
381. Bonding Driver Installation
39
402. Bonding Driver Options
41
423. Configuring Bonding Devices
Auke Kok6224e012006-06-08 11:15:35 -0700433.1 Configuration with Sysconfig Support
443.1.1 Using DHCP with Sysconfig
453.1.2 Configuring Multiple Bonds with Sysconfig
463.2 Configuration with Initscripts Support
473.2.1 Using DHCP with Initscripts
483.2.2 Configuring Multiple Bonds with Initscripts
493.3 Configuring Bonding Manually with Ifenslave
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700503.3.1 Configuring Multiple Bonds Manually
Auke Kok6224e012006-06-08 11:15:35 -0700513.4 Configuring Bonding Manually via Sysfs
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Auke Kok6224e012006-06-08 11:15:35 -0700534. Querying Bonding Configuration
544.1 Bonding Configuration
554.2 Network Configuration
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Auke Kok6224e012006-06-08 11:15:35 -0700575. Switch Configuration
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Auke Kok6224e012006-06-08 11:15:35 -0700596. 802.1q VLAN Support
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Auke Kok6224e012006-06-08 11:15:35 -0700617. Link Monitoring
627.1 ARP Monitor Operation
637.2 Configuring Multiple ARP Targets
647.3 MII Monitor Operation
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Auke Kok6224e012006-06-08 11:15:35 -0700668. Potential Trouble Sources
678.1 Adventures in Routing
688.2 Ethernet Device Renaming
698.3 Painfully Slow Or No Failed Link Detection By Miimon
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Auke Kok6224e012006-06-08 11:15:35 -0700719. SNMP agents
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Auke Kok6224e012006-06-08 11:15:35 -07007310. Promiscuous mode
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Auke Kok6224e012006-06-08 11:15:35 -07007511. Configuring Bonding for High Availability
7611.1 High Availability in a Single Switch Topology
7711.2 High Availability in a Multiple Switch Topology
7811.2.1 HA Bonding Mode Selection for Multiple Switch Topology
7911.2.2 HA Link Monitoring for Multiple Switch Topology
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Auke Kok6224e012006-06-08 11:15:35 -07008112. Configuring Bonding for Maximum Throughput
8212.1 Maximum Throughput in a Single Switch Topology
8312.1.1 MT Bonding Mode Selection for Single Switch Topology
8412.1.2 MT Link Monitoring for Single Switch Topology
8512.2 Maximum Throughput in a Multiple Switch Topology
8612.2.1 MT Bonding Mode Selection for Multiple Switch Topology
8712.2.2 MT Link Monitoring for Multiple Switch Topology
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Auke Kok6224e012006-06-08 11:15:35 -07008913. Switch Behavior Issues
9013.1 Link Establishment and Failover Delays
9113.2 Duplicated Incoming Packets
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Auke Kok6224e012006-06-08 11:15:35 -07009314. Hardware Specific Considerations
9414.1 IBM BladeCenter
Jay Vosburgh00354cf2005-07-21 12:18:02 -070095
Auke Kok6224e012006-06-08 11:15:35 -07009615. Frequently Asked Questions
Jay Vosburgh00354cf2005-07-21 12:18:02 -070097
Auke Kok6224e012006-06-08 11:15:35 -07009816. Resources and Links
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100
1011. Bonding Driver Installation
102==============================
103
104 Most popular distro kernels ship with the bonding driver
105already available as a module and the ifenslave user level control
106program installed and ready for use. If your distro does not, or you
107have need to compile bonding from source (e.g., configuring and
108installing a mainline kernel from kernel.org), you'll need to perform
109the following steps:
110
1111.1 Configure and build the kernel with bonding
112-----------------------------------------------
113
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700114 The current version of the bonding driver is available in the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115drivers/net/bonding subdirectory of the most recent kernel source
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700116(which is available on http://kernel.org). Most users "rolling their
117own" will want to use the most recent kernel from kernel.org.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119 Configure kernel with "make menuconfig" (or "make xconfig" or
120"make config"), then select "Bonding driver support" in the "Network
121device support" section. It is recommended that you configure the
122driver as module since it is currently the only way to pass parameters
123to the driver or configure more than one bonding device.
124
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700125 Build and install the new kernel and modules, then continue
126below to install ifenslave.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
1281.2 Install ifenslave Control Utility
129-------------------------------------
130
131 The ifenslave user level control program is included in the
132kernel source tree, in the file Documentation/networking/ifenslave.c.
133It is generally recommended that you use the ifenslave that
134corresponds to the kernel that you are using (either from the same
135source tree or supplied with the distro), however, ifenslave
136executables from older kernels should function (but features newer
137than the ifenslave release are not supported). Running an ifenslave
138that is newer than the kernel is not supported, and may or may not
139work.
140
141 To install ifenslave, do the following:
142
143# gcc -Wall -O -I/usr/src/linux/include ifenslave.c -o ifenslave
144# cp ifenslave /sbin/ifenslave
145
146 If your kernel source is not in "/usr/src/linux," then replace
147"/usr/src/linux/include" in the above with the location of your kernel
148source include directory.
149
150 You may wish to back up any existing /sbin/ifenslave, or, for
151testing or informal use, tag the ifenslave to the kernel version
152(e.g., name the ifenslave executable /sbin/ifenslave-2.6.10).
153
154IMPORTANT NOTE:
155
156 If you omit the "-I" or specify an incorrect directory, you
157may end up with an ifenslave that is incompatible with the kernel
158you're trying to build it for. Some distros (e.g., Red Hat from 7.1
159onwards) do not have /usr/include/linux symbolically linked to the
160default kernel source include directory.
161
Auke Kok6224e012006-06-08 11:15:35 -0700162SECOND IMPORTANT NOTE:
163 If you plan to configure bonding using sysfs, you do not need
164to use ifenslave.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
1662. Bonding Driver Options
167=========================
168
Jay Vosburgh9a6c6862007-11-13 20:25:48 -0800169 Options for the bonding driver are supplied as parameters to the
170bonding module at load time, or are specified via sysfs.
171
172 Module options may be given as command line arguments to the
173insmod or modprobe command, but are usually specified in either the
174/etc/modules.conf or /etc/modprobe.conf configuration file, or in a
175distro-specific configuration file (some of which are detailed in the next
176section).
177
178 Details on bonding support for sysfs is provided in the
179"Configuring Bonding Manually via Sysfs" section, below.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181 The available bonding driver parameters are listed below. If a
182parameter is not specified the default value is used. When initially
183configuring a bond, it is recommended "tail -f /var/log/messages" be
184run in a separate window to watch for bonding driver error messages.
185
186 It is critical that either the miimon or arp_interval and
187arp_ip_target parameters be specified, otherwise serious network
188degradation will occur during link failures. Very few devices do not
189support at least miimon, so there is really no reason not to use it.
190
191 Options with textual values will accept either the text name
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700192or, for backwards compatibility, the option value. E.g.,
193"mode=802.3ad" and "mode=4" set the same mode.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195 The parameters are as follows:
196
Jay Vosburghfd989c82008-11-04 17:51:16 -0800197ad_select
198
199 Specifies the 802.3ad aggregation selection logic to use. The
200 possible values and their effects are:
201
202 stable or 0
203
204 The active aggregator is chosen by largest aggregate
205 bandwidth.
206
207 Reselection of the active aggregator occurs only when all
208 slaves of the active aggregator are down or the active
209 aggregator has no slaves.
210
211 This is the default value.
212
213 bandwidth or 1
214
215 The active aggregator is chosen by largest aggregate
216 bandwidth. Reselection occurs if:
217
218 - A slave is added to or removed from the bond
219
220 - Any slave's link state changes
221
222 - Any slave's 802.3ad association state changes
223
Matt LaPlante19f59462009-04-27 15:06:31 +0200224 - The bond's administrative state changes to up
Jay Vosburghfd989c82008-11-04 17:51:16 -0800225
226 count or 2
227
228 The active aggregator is chosen by the largest number of
229 ports (slaves). Reselection occurs as described under the
230 "bandwidth" setting, above.
231
232 The bandwidth and count selection policies permit failover of
233 802.3ad aggregations when partial failure of the active aggregator
234 occurs. This keeps the aggregator with the highest availability
235 (either in bandwidth or in number of ports) active at all times.
236
237 This option was added in bonding version 3.4.0.
238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239arp_interval
240
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700241 Specifies the ARP link monitoring frequency in milliseconds.
Jay Vosburghf5b2b962006-09-22 21:54:53 -0700242
243 The ARP monitor works by periodically checking the slave
244 devices to determine whether they have sent or received
245 traffic recently (the precise criteria depends upon the
246 bonding mode, and the state of the slave). Regular traffic is
247 generated via ARP probes issued for the addresses specified by
248 the arp_ip_target option.
249
250 This behavior can be modified by the arp_validate option,
251 below.
252
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700253 If ARP monitoring is used in an etherchannel compatible mode
254 (modes 0 and 2), the switch should be configured in a mode
255 that evenly distributes packets across all links. If the
256 switch is configured to distribute the packets in an XOR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 fashion, all replies from the ARP targets will be received on
258 the same link which could cause the other team members to
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700259 fail. ARP monitoring should not be used in conjunction with
260 miimon. A value of 0 disables ARP monitoring. The default
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 value is 0.
262
263arp_ip_target
264
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700265 Specifies the IP addresses to use as ARP monitoring peers when
266 arp_interval is > 0. These are the targets of the ARP request
267 sent to determine the health of the link to the targets.
268 Specify these values in ddd.ddd.ddd.ddd format. Multiple IP
269 addresses must be separated by a comma. At least one IP
270 address must be given for ARP monitoring to function. The
271 maximum number of targets that can be specified is 16. The
272 default value is no IP addresses.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Jay Vosburghf5b2b962006-09-22 21:54:53 -0700274arp_validate
275
276 Specifies whether or not ARP probes and replies should be
277 validated in the active-backup mode. This causes the ARP
278 monitor to examine the incoming ARP requests and replies, and
279 only consider a slave to be up if it is receiving the
280 appropriate ARP traffic.
281
282 Possible values are:
283
284 none or 0
285
286 No validation is performed. This is the default.
287
288 active or 1
289
290 Validation is performed only for the active slave.
291
292 backup or 2
293
294 Validation is performed only for backup slaves.
295
296 all or 3
297
298 Validation is performed for all slaves.
299
300 For the active slave, the validation checks ARP replies to
301 confirm that they were generated by an arp_ip_target. Since
302 backup slaves do not typically receive these replies, the
303 validation performed for backup slaves is on the ARP request
304 sent out via the active slave. It is possible that some
305 switch or network configurations may result in situations
306 wherein the backup slaves do not receive the ARP requests; in
307 such a situation, validation of backup slaves must be
308 disabled.
309
310 This option is useful in network configurations in which
311 multiple bonding hosts are concurrently issuing ARPs to one or
312 more targets beyond a common switch. Should the link between
313 the switch and target fail (but not the switch itself), the
314 probe traffic generated by the multiple bonding instances will
315 fool the standard ARP monitor into considering the links as
316 still up. Use of the arp_validate option can resolve this, as
317 the ARP monitor will only consider ARP requests and replies
318 associated with its own instance of bonding.
319
320 This option was added in bonding version 3.1.0.
321
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322downdelay
323
324 Specifies the time, in milliseconds, to wait before disabling
325 a slave after a link failure has been detected. This option
326 is only valid for the miimon link monitor. The downdelay
327 value should be a multiple of the miimon value; if not, it
328 will be rounded down to the nearest multiple. The default
329 value is 0.
330
Jay Vosburghdd957c52007-10-09 19:57:24 -0700331fail_over_mac
332
333 Specifies whether active-backup mode should set all slaves to
Jay Vosburgh3915c1e2008-05-17 21:10:14 -0700334 the same MAC address at enslavement (the traditional
335 behavior), or, when enabled, perform special handling of the
336 bond's MAC address in accordance with the selected policy.
Jay Vosburghdd957c52007-10-09 19:57:24 -0700337
Jay Vosburgh3915c1e2008-05-17 21:10:14 -0700338 Possible values are:
Jay Vosburghdd957c52007-10-09 19:57:24 -0700339
Jay Vosburgh3915c1e2008-05-17 21:10:14 -0700340 none or 0
Jay Vosburghdd957c52007-10-09 19:57:24 -0700341
Jay Vosburgh3915c1e2008-05-17 21:10:14 -0700342 This setting disables fail_over_mac, and causes
343 bonding to set all slaves of an active-backup bond to
344 the same MAC address at enslavement time. This is the
345 default.
Jay Vosburghdd957c52007-10-09 19:57:24 -0700346
Jay Vosburgh3915c1e2008-05-17 21:10:14 -0700347 active or 1
Jay Vosburghdd957c52007-10-09 19:57:24 -0700348
Jay Vosburgh3915c1e2008-05-17 21:10:14 -0700349 The "active" fail_over_mac policy indicates that the
350 MAC address of the bond should always be the MAC
351 address of the currently active slave. The MAC
352 address of the slaves is not changed; instead, the MAC
353 address of the bond changes during a failover.
354
355 This policy is useful for devices that cannot ever
356 alter their MAC address, or for devices that refuse
357 incoming broadcasts with their own source MAC (which
358 interferes with the ARP monitor).
359
360 The down side of this policy is that every device on
361 the network must be updated via gratuitous ARP,
362 vs. just updating a switch or set of switches (which
363 often takes place for any traffic, not just ARP
364 traffic, if the switch snoops incoming traffic to
365 update its tables) for the traditional method. If the
366 gratuitous ARP is lost, communication may be
367 disrupted.
368
369 When this policy is used in conjuction with the mii
370 monitor, devices which assert link up prior to being
371 able to actually transmit and receive are particularly
Matt LaPlante19f59462009-04-27 15:06:31 +0200372 susceptible to loss of the gratuitous ARP, and an
Jay Vosburgh3915c1e2008-05-17 21:10:14 -0700373 appropriate updelay setting may be required.
374
375 follow or 2
376
377 The "follow" fail_over_mac policy causes the MAC
378 address of the bond to be selected normally (normally
379 the MAC address of the first slave added to the bond).
380 However, the second and subsequent slaves are not set
381 to this MAC address while they are in a backup role; a
382 slave is programmed with the bond's MAC address at
383 failover time (and the formerly active slave receives
384 the newly active slave's MAC address).
385
386 This policy is useful for multiport devices that
387 either become confused or incur a performance penalty
388 when multiple ports are programmed with the same MAC
389 address.
390
391
392 The default policy is none, unless the first slave cannot
393 change its MAC address, in which case the active policy is
394 selected by default.
395
396 This option may be modified via sysfs only when no slaves are
397 present in the bond.
398
399 This option was added in bonding version 3.2.0. The "follow"
400 policy was added in bonding version 3.3.0.
Jay Vosburghdd957c52007-10-09 19:57:24 -0700401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402lacp_rate
403
404 Option specifying the rate in which we'll ask our link partner
405 to transmit LACPDU packets in 802.3ad mode. Possible values
406 are:
407
408 slow or 0
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700409 Request partner to transmit LACPDUs every 30 seconds
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
411 fast or 1
412 Request partner to transmit LACPDUs every 1 second
413
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700414 The default is slow.
415
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416max_bonds
417
418 Specifies the number of bonding devices to create for this
419 instance of the bonding driver. E.g., if max_bonds is 3, and
420 the bonding driver is not already loaded, then bond0, bond1
Jay Vosburghb8a97872008-06-13 18:12:04 -0700421 and bond2 will be created. The default value is 1. Specifying
422 a value of 0 will load bonding, but will not create any devices.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
424miimon
425
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700426 Specifies the MII link monitoring frequency in milliseconds.
427 This determines how often the link state of each slave is
428 inspected for link failures. A value of zero disables MII
429 link monitoring. A value of 100 is a good starting point.
430 The use_carrier option, below, affects how the link state is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 determined. See the High Availability section for additional
432 information. The default value is 0.
433
434mode
435
436 Specifies one of the bonding policies. The default is
437 balance-rr (round robin). Possible values are:
438
439 balance-rr or 0
440
441 Round-robin policy: Transmit packets in sequential
442 order from the first available slave through the
443 last. This mode provides load balancing and fault
444 tolerance.
445
446 active-backup or 1
447
448 Active-backup policy: Only one slave in the bond is
449 active. A different slave becomes active if, and only
450 if, the active slave fails. The bond's MAC address is
451 externally visible on only one port (network adapter)
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700452 to avoid confusing the switch.
453
454 In bonding version 2.6.2 or later, when a failover
455 occurs in active-backup mode, bonding will issue one
456 or more gratuitous ARPs on the newly active slave.
Auke Kok6224e012006-06-08 11:15:35 -0700457 One gratuitous ARP is issued for the bonding master
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700458 interface and each VLAN interfaces configured above
459 it, provided that the interface has at least one IP
460 address configured. Gratuitous ARPs issued for VLAN
461 interfaces are tagged with the appropriate VLAN id.
462
463 This mode provides fault tolerance. The primary
464 option, documented below, affects the behavior of this
465 mode.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466
467 balance-xor or 2
468
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700469 XOR policy: Transmit based on the selected transmit
470 hash policy. The default policy is a simple [(source
471 MAC address XOR'd with destination MAC address) modulo
472 slave count]. Alternate transmit policies may be
473 selected via the xmit_hash_policy option, described
474 below.
475
476 This mode provides load balancing and fault tolerance.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
478 broadcast or 3
479
480 Broadcast policy: transmits everything on all slave
481 interfaces. This mode provides fault tolerance.
482
483 802.3ad or 4
484
485 IEEE 802.3ad Dynamic link aggregation. Creates
486 aggregation groups that share the same speed and
487 duplex settings. Utilizes all slaves in the active
488 aggregator according to the 802.3ad specification.
489
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700490 Slave selection for outgoing traffic is done according
491 to the transmit hash policy, which may be changed from
492 the default simple XOR policy via the xmit_hash_policy
493 option, documented below. Note that not all transmit
494 policies may be 802.3ad compliant, particularly in
495 regards to the packet mis-ordering requirements of
496 section 43.2.4 of the 802.3ad standard. Differing
497 peer implementations will have varying tolerances for
498 noncompliance.
499
500 Prerequisites:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501
502 1. Ethtool support in the base drivers for retrieving
503 the speed and duplex of each slave.
504
505 2. A switch that supports IEEE 802.3ad Dynamic link
506 aggregation.
507
508 Most switches will require some type of configuration
509 to enable 802.3ad mode.
510
511 balance-tlb or 5
512
513 Adaptive transmit load balancing: channel bonding that
514 does not require any special switch support. The
515 outgoing traffic is distributed according to the
516 current load (computed relative to the speed) on each
517 slave. Incoming traffic is received by the current
518 slave. If the receiving slave fails, another slave
519 takes over the MAC address of the failed receiving
520 slave.
521
522 Prerequisite:
523
524 Ethtool support in the base drivers for retrieving the
525 speed of each slave.
526
527 balance-alb or 6
528
529 Adaptive load balancing: includes balance-tlb plus
530 receive load balancing (rlb) for IPV4 traffic, and
531 does not require any special switch support. The
532 receive load balancing is achieved by ARP negotiation.
533 The bonding driver intercepts the ARP Replies sent by
534 the local system on their way out and overwrites the
535 source hardware address with the unique hardware
536 address of one of the slaves in the bond such that
537 different peers use different hardware addresses for
538 the server.
539
540 Receive traffic from connections created by the server
541 is also balanced. When the local system sends an ARP
542 Request the bonding driver copies and saves the peer's
543 IP information from the ARP packet. When the ARP
544 Reply arrives from the peer, its hardware address is
545 retrieved and the bonding driver initiates an ARP
546 reply to this peer assigning it to one of the slaves
547 in the bond. A problematic outcome of using ARP
548 negotiation for balancing is that each time that an
549 ARP request is broadcast it uses the hardware address
550 of the bond. Hence, peers learn the hardware address
551 of the bond and the balancing of receive traffic
552 collapses to the current slave. This is handled by
553 sending updates (ARP Replies) to all the peers with
554 their individually assigned hardware address such that
555 the traffic is redistributed. Receive traffic is also
556 redistributed when a new slave is added to the bond
557 and when an inactive slave is re-activated. The
558 receive load is distributed sequentially (round robin)
559 among the group of highest speed slaves in the bond.
560
561 When a link is reconnected or a new slave joins the
562 bond the receive traffic is redistributed among all
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700563 active slaves in the bond by initiating ARP Replies
Auke Kok6224e012006-06-08 11:15:35 -0700564 with the selected MAC address to each of the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 clients. The updelay parameter (detailed below) must
566 be set to a value equal or greater than the switch's
567 forwarding delay so that the ARP Replies sent to the
568 peers will not be blocked by the switch.
569
570 Prerequisites:
571
572 1. Ethtool support in the base drivers for retrieving
573 the speed of each slave.
574
575 2. Base driver support for setting the hardware
576 address of a device while it is open. This is
577 required so that there will always be one slave in the
578 team using the bond hardware address (the
579 curr_active_slave) while having a unique hardware
580 address for each slave in the bond. If the
581 curr_active_slave fails its hardware address is
582 swapped with the new curr_active_slave that was
583 chosen.
584
Jay Vosburghb59f9f72008-06-13 18:12:03 -0700585num_grat_arp
586
587 Specifies the number of gratuitous ARPs to be issued after a
588 failover event. One gratuitous ARP is issued immediately after
589 the failover, subsequent ARPs are sent at a rate of one per link
590 monitor interval (arp_interval or miimon, whichever is active).
591
592 The valid range is 0 - 255; the default value is 1. This option
593 affects only the active-backup mode. This option was added for
594 bonding version 3.3.0.
595
Brian Haley305d5522008-11-04 17:51:14 -0800596num_unsol_na
597
598 Specifies the number of unsolicited IPv6 Neighbor Advertisements
599 to be issued after a failover event. One unsolicited NA is issued
600 immediately after the failover.
601
602 The valid range is 0 - 255; the default value is 1. This option
603 affects only the active-backup mode. This option was added for
604 bonding version 3.4.0.
605
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606primary
607
608 A string (eth0, eth2, etc) specifying which slave is the
609 primary device. The specified device will always be the
610 active slave while it is available. Only when the primary is
611 off-line will alternate devices be used. This is useful when
612 one slave is preferred over another, e.g., when one slave has
613 higher throughput than another.
614
615 The primary option is only valid for active-backup mode.
616
Jiri Pirkoa5499522009-09-25 03:28:09 +0000617primary_reselect
618
619 Specifies the reselection policy for the primary slave. This
620 affects how the primary slave is chosen to become the active slave
621 when failure of the active slave or recovery of the primary slave
622 occurs. This option is designed to prevent flip-flopping between
623 the primary slave and other slaves. Possible values are:
624
625 always or 0 (default)
626
627 The primary slave becomes the active slave whenever it
628 comes back up.
629
630 better or 1
631
632 The primary slave becomes the active slave when it comes
633 back up, if the speed and duplex of the primary slave is
634 better than the speed and duplex of the current active
635 slave.
636
637 failure or 2
638
639 The primary slave becomes the active slave only if the
640 current active slave fails and the primary slave is up.
641
642 The primary_reselect setting is ignored in two cases:
643
644 If no slaves are active, the first slave to recover is
645 made the active slave.
646
647 When initially enslaved, the primary slave is always made
648 the active slave.
649
650 Changing the primary_reselect policy via sysfs will cause an
651 immediate selection of the best active slave according to the new
652 policy. This may or may not result in a change of the active
653 slave, depending upon the circumstances.
654
655 This option was added for bonding version 3.6.0.
656
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657updelay
658
659 Specifies the time, in milliseconds, to wait before enabling a
660 slave after a link recovery has been detected. This option is
661 only valid for the miimon link monitor. The updelay value
662 should be a multiple of the miimon value; if not, it will be
663 rounded down to the nearest multiple. The default value is 0.
664
665use_carrier
666
667 Specifies whether or not miimon should use MII or ETHTOOL
668 ioctls vs. netif_carrier_ok() to determine the link
669 status. The MII or ETHTOOL ioctls are less efficient and
670 utilize a deprecated calling sequence within the kernel. The
671 netif_carrier_ok() relies on the device driver to maintain its
672 state with netif_carrier_on/off; at this writing, most, but
673 not all, device drivers support this facility.
674
675 If bonding insists that the link is up when it should not be,
676 it may be that your network device driver does not support
677 netif_carrier_on/off. The default state for netif_carrier is
678 "carrier on," so if a driver does not support netif_carrier,
679 it will appear as if the link is always up. In this case,
680 setting use_carrier to 0 will cause bonding to revert to the
681 MII / ETHTOOL ioctl method to determine the link state.
682
683 A value of 1 enables the use of netif_carrier_ok(), a value of
684 0 will use the deprecated MII / ETHTOOL ioctls. The default
685 value is 1.
686
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700687xmit_hash_policy
688
689 Selects the transmit hash policy to use for slave selection in
690 balance-xor and 802.3ad modes. Possible values are:
691
692 layer2
693
694 Uses XOR of hardware MAC addresses to generate the
695 hash. The formula is
696
697 (source MAC XOR destination MAC) modulo slave count
698
699 This algorithm will place all traffic to a particular
700 network peer on the same slave.
701
702 This algorithm is 802.3ad compliant.
703
Jay Vosburgh6f6652b2007-12-06 23:40:34 -0800704 layer2+3
705
706 This policy uses a combination of layer2 and layer3
707 protocol information to generate the hash.
708
709 Uses XOR of hardware MAC addresses and IP addresses to
710 generate the hash. The formula is
711
712 (((source IP XOR dest IP) AND 0xffff) XOR
713 ( source MAC XOR destination MAC ))
714 modulo slave count
715
716 This algorithm will place all traffic to a particular
717 network peer on the same slave. For non-IP traffic,
718 the formula is the same as for the layer2 transmit
719 hash policy.
720
721 This policy is intended to provide a more balanced
722 distribution of traffic than layer2 alone, especially
723 in environments where a layer3 gateway device is
724 required to reach most destinations.
725
Matt LaPlanted9195882008-07-25 19:45:33 -0700726 This algorithm is 802.3ad compliant.
Jay Vosburgh6f6652b2007-12-06 23:40:34 -0800727
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700728 layer3+4
729
730 This policy uses upper layer protocol information,
731 when available, to generate the hash. This allows for
732 traffic to a particular network peer to span multiple
733 slaves, although a single connection will not span
734 multiple slaves.
735
736 The formula for unfragmented TCP and UDP packets is
737
738 ((source port XOR dest port) XOR
739 ((source IP XOR dest IP) AND 0xffff)
740 modulo slave count
741
742 For fragmented TCP or UDP packets and all other IP
743 protocol traffic, the source and destination port
744 information is omitted. For non-IP traffic, the
745 formula is the same as for the layer2 transmit hash
746 policy.
747
748 This policy is intended to mimic the behavior of
749 certain switches, notably Cisco switches with PFC2 as
750 well as some Foundry and IBM products.
751
752 This algorithm is not fully 802.3ad compliant. A
753 single TCP or UDP conversation containing both
754 fragmented and unfragmented packets will see packets
755 striped across two interfaces. This may result in out
756 of order delivery. Most traffic types will not meet
757 this criteria, as TCP rarely fragments traffic, and
758 most UDP traffic is not involved in extended
759 conversations. Other implementations of 802.3ad may
760 or may not tolerate this noncompliance.
761
762 The default value is layer2. This option was added in bonding
Jay Vosburgh6f6652b2007-12-06 23:40:34 -0800763 version 2.6.3. In earlier versions of bonding, this parameter
764 does not exist, and the layer2 policy is the only policy. The
765 layer2+3 value was added for bonding version 3.2.2.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766
767
7683. Configuring Bonding Devices
769==============================
770
Auke Kok6224e012006-06-08 11:15:35 -0700771 You can configure bonding using either your distro's network
772initialization scripts, or manually using either ifenslave or the
773sysfs interface. Distros generally use one of two packages for the
774network initialization scripts: initscripts or sysconfig. Recent
775versions of these packages have support for bonding, while older
776versions do not.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777
778 We will first describe the options for configuring bonding for
779distros using versions of initscripts and sysconfig with full or
780partial support for bonding, then provide information on enabling
781bonding without support from the network initialization scripts (i.e.,
782older versions of initscripts or sysconfig).
783
784 If you're unsure whether your distro uses sysconfig or
785initscripts, or don't know if it's new enough, have no fear.
786Determining this is fairly straightforward.
787
788 First, issue the command:
789
790$ rpm -qf /sbin/ifup
791
792 It will respond with a line of text starting with either
793"initscripts" or "sysconfig," followed by some numbers. This is the
794package that provides your network initialization scripts.
795
796 Next, to determine if your installation supports bonding,
797issue the command:
798
799$ grep ifenslave /sbin/ifup
800
801 If this returns any matches, then your initscripts or
802sysconfig has support for bonding.
803
Auke Kok6224e012006-06-08 11:15:35 -07008043.1 Configuration with Sysconfig Support
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805----------------------------------------
806
807 This section applies to distros using a version of sysconfig
808with bonding support, for example, SuSE Linux Enterprise Server 9.
809
810 SuSE SLES 9's networking configuration system does support
811bonding, however, at this writing, the YaST system configuration
Auke Kok6224e012006-06-08 11:15:35 -0700812front end does not provide any means to work with bonding devices.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813Bonding devices can be managed by hand, however, as follows.
814
815 First, if they have not already been configured, configure the
816slave devices. On SLES 9, this is most easily done by running the
817yast2 sysconfig configuration utility. The goal is for to create an
818ifcfg-id file for each slave device. The simplest way to accomplish
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700819this is to configure the devices for DHCP (this is only to get the
820file ifcfg-id file created; see below for some issues with DHCP). The
821name of the configuration file for each device will be of the form:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822
823ifcfg-id-xx:xx:xx:xx:xx:xx
824
825 Where the "xx" portion will be replaced with the digits from
826the device's permanent MAC address.
827
828 Once the set of ifcfg-id-xx:xx:xx:xx:xx:xx files has been
829created, it is necessary to edit the configuration files for the slave
830devices (the MAC addresses correspond to those of the slave devices).
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700831Before editing, the file will contain multiple lines, and will look
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832something like this:
833
834BOOTPROTO='dhcp'
835STARTMODE='on'
836USERCTL='no'
837UNIQUE='XNzu.WeZGOGF+4wE'
838_nm_name='bus-pci-0001:61:01.0'
839
840 Change the BOOTPROTO and STARTMODE lines to the following:
841
842BOOTPROTO='none'
843STARTMODE='off'
844
845 Do not alter the UNIQUE or _nm_name lines. Remove any other
846lines (USERCTL, etc).
847
848 Once the ifcfg-id-xx:xx:xx:xx:xx:xx files have been modified,
849it's time to create the configuration file for the bonding device
850itself. This file is named ifcfg-bondX, where X is the number of the
851bonding device to create, starting at 0. The first such file is
852ifcfg-bond0, the second is ifcfg-bond1, and so on. The sysconfig
853network configuration system will correctly start multiple instances
854of bonding.
855
856 The contents of the ifcfg-bondX file is as follows:
857
858BOOTPROTO="static"
859BROADCAST="10.0.2.255"
860IPADDR="10.0.2.10"
861NETMASK="255.255.0.0"
862NETWORK="10.0.2.0"
863REMOTE_IPADDR=""
864STARTMODE="onboot"
865BONDING_MASTER="yes"
866BONDING_MODULE_OPTS="mode=active-backup miimon=100"
867BONDING_SLAVE0="eth0"
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700868BONDING_SLAVE1="bus-pci-0000:06:08.1"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869
870 Replace the sample BROADCAST, IPADDR, NETMASK and NETWORK
871values with the appropriate values for your network.
872
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 The STARTMODE specifies when the device is brought online.
874The possible values are:
875
876 onboot: The device is started at boot time. If you're not
877 sure, this is probably what you want.
878
879 manual: The device is started only when ifup is called
880 manually. Bonding devices may be configured this
881 way if you do not wish them to start automatically
882 at boot for some reason.
883
884 hotplug: The device is started by a hotplug event. This is not
885 a valid choice for a bonding device.
886
887 off or ignore: The device configuration is ignored.
888
889 The line BONDING_MASTER='yes' indicates that the device is a
890bonding master device. The only useful value is "yes."
891
892 The contents of BONDING_MODULE_OPTS are supplied to the
893instance of the bonding module for this device. Specify the options
894for the bonding mode, link monitoring, and so on here. Do not include
895the max_bonds bonding parameter; this will confuse the configuration
896system if you have multiple bonding devices.
897
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700898 Finally, supply one BONDING_SLAVEn="slave device" for each
899slave. where "n" is an increasing value, one for each slave. The
900"slave device" is either an interface name, e.g., "eth0", or a device
901specifier for the network device. The interface name is easier to
902find, but the ethN names are subject to change at boot time if, e.g.,
903a device early in the sequence has failed. The device specifiers
904(bus-pci-0000:06:08.1 in the example above) specify the physical
905network device, and will not change unless the device's bus location
906changes (for example, it is moved from one PCI slot to another). The
907example above uses one of each type for demonstration purposes; most
908configurations will choose one or the other for all slave devices.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909
910 When all configuration files have been modified or created,
911networking must be restarted for the configuration changes to take
912effect. This can be accomplished via the following:
913
914# /etc/init.d/network restart
915
916 Note that the network control script (/sbin/ifdown) will
917remove the bonding module as part of the network shutdown processing,
918so it is not necessary to remove the module by hand if, e.g., the
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700919module parameters have changed.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920
921 Also, at this writing, YaST/YaST2 will not manage bonding
922devices (they do not show bonding interfaces on its list of network
923devices). It is necessary to edit the configuration file by hand to
924change the bonding configuration.
925
926 Additional general options and details of the ifcfg file
927format can be found in an example ifcfg template file:
928
929/etc/sysconfig/network/ifcfg.template
930
931 Note that the template does not document the various BONDING_
932settings described above, but does describe many of the other options.
933
Auke Kok6224e012006-06-08 11:15:35 -07009343.1.1 Using DHCP with Sysconfig
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700935-------------------------------
936
937 Under sysconfig, configuring a device with BOOTPROTO='dhcp'
938will cause it to query DHCP for its IP address information. At this
939writing, this does not function for bonding devices; the scripts
940attempt to obtain the device address from DHCP prior to adding any of
941the slave devices. Without active slaves, the DHCP requests are not
942sent to the network.
943
Auke Kok6224e012006-06-08 11:15:35 -07009443.1.2 Configuring Multiple Bonds with Sysconfig
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700945-----------------------------------------------
946
947 The sysconfig network initialization system is capable of
948handling multiple bonding devices. All that is necessary is for each
949bonding instance to have an appropriately configured ifcfg-bondX file
950(as described above). Do not specify the "max_bonds" parameter to any
951instance of bonding, as this will confuse sysconfig. If you require
952multiple bonding devices with identical parameters, create multiple
953ifcfg-bondX files.
954
955 Because the sysconfig scripts supply the bonding module
956options in the ifcfg-bondX file, it is not necessary to add them to
957the system /etc/modules.conf or /etc/modprobe.conf configuration file.
958
Auke Kok6224e012006-06-08 11:15:35 -07009593.2 Configuration with Initscripts Support
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960------------------------------------------
961
Jay Vosburgh9a6c6862007-11-13 20:25:48 -0800962 This section applies to distros using a recent version of
963initscripts with bonding support, for example, Red Hat Enterprise Linux
964version 3 or later, Fedora, etc. On these systems, the network
965initialization scripts have knowledge of bonding, and can be configured to
966control bonding devices. Note that older versions of the initscripts
967package have lower levels of support for bonding; this will be noted where
968applicable.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969
970 These distros will not automatically load the network adapter
971driver unless the ethX device is configured with an IP address.
972Because of this constraint, users must manually configure a
973network-script file for all physical adapters that will be members of
974a bondX link. Network script files are located in the directory:
975
976/etc/sysconfig/network-scripts
977
978 The file name must be prefixed with "ifcfg-eth" and suffixed
979with the adapter's physical adapter number. For example, the script
980for eth0 would be named /etc/sysconfig/network-scripts/ifcfg-eth0.
981Place the following text in the file:
982
983DEVICE=eth0
984USERCTL=no
985ONBOOT=yes
986MASTER=bond0
987SLAVE=yes
988BOOTPROTO=none
989
990 The DEVICE= line will be different for every ethX device and
991must correspond with the name of the file, i.e., ifcfg-eth1 must have
992a device line of DEVICE=eth1. The setting of the MASTER= line will
993also depend on the final bonding interface name chosen for your bond.
994As with other network devices, these typically start at 0, and go up
995one for each device, i.e., the first bonding instance is bond0, the
996second is bond1, and so on.
997
998 Next, create a bond network script. The file name for this
999script will be /etc/sysconfig/network-scripts/ifcfg-bondX where X is
1000the number of the bond. For bond0 the file is named "ifcfg-bond0",
1001for bond1 it is named "ifcfg-bond1", and so on. Within that file,
1002place the following text:
1003
1004DEVICE=bond0
1005IPADDR=192.168.1.1
1006NETMASK=255.255.255.0
1007NETWORK=192.168.1.0
1008BROADCAST=192.168.1.255
1009ONBOOT=yes
1010BOOTPROTO=none
1011USERCTL=no
1012
1013 Be sure to change the networking specific lines (IPADDR,
1014NETMASK, NETWORK and BROADCAST) to match your network configuration.
1015
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001016 For later versions of initscripts, such as that found with Fedora
Andy Gospodarek3f8b4b12008-10-22 11:19:48 +000010177 (or later) and Red Hat Enterprise Linux version 5 (or later), it is possible,
1018and, indeed, preferable, to specify the bonding options in the ifcfg-bond0
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001019file, e.g. a line of the format:
1020
Andy Gospodarek3f8b4b12008-10-22 11:19:48 +00001021BONDING_OPTS="mode=active-backup arp_interval=60 arp_ip_target=192.168.1.254"
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001022
1023 will configure the bond with the specified options. The options
1024specified in BONDING_OPTS are identical to the bonding module parameters
Andy Gospodarek3f8b4b12008-10-22 11:19:48 +00001025except for the arp_ip_target field when using versions of initscripts older
1026than and 8.57 (Fedora 8) and 8.45.19 (Red Hat Enterprise Linux 5.2). When
1027using older versions each target should be included as a separate option and
1028should be preceded by a '+' to indicate it should be added to the list of
1029queried targets, e.g.,
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001030
1031 arp_ip_target=+192.168.1.1 arp_ip_target=+192.168.1.2
1032
1033 is the proper syntax to specify multiple targets. When specifying
1034options via BONDING_OPTS, it is not necessary to edit /etc/modules.conf or
1035/etc/modprobe.conf.
1036
Andy Gospodarek3f8b4b12008-10-22 11:19:48 +00001037 For even older versions of initscripts that do not support
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001038BONDING_OPTS, it is necessary to edit /etc/modules.conf (or
1039/etc/modprobe.conf, depending upon your distro) to load the bonding module
1040with your desired options when the bond0 interface is brought up. The
1041following lines in /etc/modules.conf (or modprobe.conf) will load the
1042bonding module, and select its options:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043
1044alias bond0 bonding
1045options bond0 mode=balance-alb miimon=100
1046
1047 Replace the sample parameters with the appropriate set of
1048options for your configuration.
1049
1050 Finally run "/etc/rc.d/init.d/network restart" as root. This
1051will restart the networking subsystem and your bond link should be now
1052up and running.
1053
Auke Kok6224e012006-06-08 11:15:35 -070010543.2.1 Using DHCP with Initscripts
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001055---------------------------------
1056
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001057 Recent versions of initscripts (the versions supplied with Fedora
1058Core 3 and Red Hat Enterprise Linux 4, or later versions, are reported to
1059work) have support for assigning IP information to bonding devices via
1060DHCP.
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001061
1062 To configure bonding for DHCP, configure it as described
1063above, except replace the line "BOOTPROTO=none" with "BOOTPROTO=dhcp"
1064and add a line consisting of "TYPE=Bonding". Note that the TYPE value
1065is case sensitive.
1066
Auke Kok6224e012006-06-08 11:15:35 -070010673.2.2 Configuring Multiple Bonds with Initscripts
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001068-------------------------------------------------
1069
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001070 Initscripts packages that are included with Fedora 7 and Red Hat
1071Enterprise Linux 5 support multiple bonding interfaces by simply
1072specifying the appropriate BONDING_OPTS= in ifcfg-bondX where X is the
1073number of the bond. This support requires sysfs support in the kernel,
1074and a bonding driver of version 3.0.0 or later. Other configurations may
1075not support this method for specifying multiple bonding interfaces; for
1076those instances, see the "Configuring Multiple Bonds Manually" section,
1077below.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078
Auke Kok6224e012006-06-08 11:15:35 -070010793.3 Configuring Bonding Manually with Ifenslave
1080-----------------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081
1082 This section applies to distros whose network initialization
1083scripts (the sysconfig or initscripts package) do not have specific
1084knowledge of bonding. One such distro is SuSE Linux Enterprise Server
1085version 8.
1086
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001087 The general method for these systems is to place the bonding
1088module parameters into /etc/modules.conf or /etc/modprobe.conf (as
1089appropriate for the installed distro), then add modprobe and/or
1090ifenslave commands to the system's global init script. The name of
1091the global init script differs; for sysconfig, it is
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092/etc/init.d/boot.local and for initscripts it is /etc/rc.d/rc.local.
1093
1094 For example, if you wanted to make a simple bond of two e100
1095devices (presumed to be eth0 and eth1), and have it persist across
1096reboots, edit the appropriate file (/etc/init.d/boot.local or
1097/etc/rc.d/rc.local), and add the following:
1098
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001099modprobe bonding mode=balance-alb miimon=100
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100modprobe e100
1101ifconfig bond0 192.168.1.1 netmask 255.255.255.0 up
1102ifenslave bond0 eth0
1103ifenslave bond0 eth1
1104
1105 Replace the example bonding module parameters and bond0
1106network configuration (IP address, netmask, etc) with the appropriate
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001107values for your configuration.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108
1109 Unfortunately, this method will not provide support for the
1110ifup and ifdown scripts on the bond devices. To reload the bonding
1111configuration, it is necessary to run the initialization script, e.g.,
1112
1113# /etc/init.d/boot.local
1114
1115 or
1116
1117# /etc/rc.d/rc.local
1118
1119 It may be desirable in such a case to create a separate script
1120which only initializes the bonding configuration, then call that
1121separate script from within boot.local. This allows for bonding to be
1122enabled without re-running the entire global init script.
1123
1124 To shut down the bonding devices, it is necessary to first
1125mark the bonding device itself as being down, then remove the
1126appropriate device driver modules. For our example above, you can do
1127the following:
1128
1129# ifconfig bond0 down
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001130# rmmod bonding
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131# rmmod e100
1132
1133 Again, for convenience, it may be desirable to create a script
1134with these commands.
1135
1136
Jay Vosburgh00354cf2005-07-21 12:18:02 -070011373.3.1 Configuring Multiple Bonds Manually
1138-----------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139
1140 This section contains information on configuring multiple
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001141bonding devices with differing options for those systems whose network
1142initialization scripts lack support for configuring multiple bonds.
1143
1144 If you require multiple bonding devices, but all with the same
1145options, you may wish to use the "max_bonds" module parameter,
1146documented above.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001148 To create multiple bonding devices with differing options, it is
1149preferrable to use bonding parameters exported by sysfs, documented in the
1150section below.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001152 For versions of bonding without sysfs support, the only means to
1153provide multiple instances of bonding with differing options is to load
1154the bonding driver multiple times. Note that current versions of the
1155sysconfig network initialization scripts handle this automatically; if
1156your distro uses these scripts, no special action is needed. See the
1157section Configuring Bonding Devices, above, if you're not sure about your
1158network initialization scripts.
1159
1160 To load multiple instances of the module, it is necessary to
1161specify a different name for each instance (the module loading system
1162requires that every loaded module, even multiple instances of the same
1163module, have a unique name). This is accomplished by supplying multiple
1164sets of bonding options in /etc/modprobe.conf, for example:
1165
1166alias bond0 bonding
1167options bond0 -o bond0 mode=balance-rr miimon=100
1168
1169alias bond1 bonding
1170options bond1 -o bond1 mode=balance-alb miimon=50
1171
1172 will load the bonding module two times. The first instance is
1173named "bond0" and creates the bond0 device in balance-rr mode with an
1174miimon of 100. The second instance is named "bond1" and creates the
1175bond1 device in balance-alb mode with an miimon of 50.
1176
1177 In some circumstances (typically with older distributions),
1178the above does not work, and the second bonding instance never sees
1179its options. In that case, the second options line can be substituted
1180as follows:
1181
1182install bond1 /sbin/modprobe --ignore-install bonding -o bond1 \
1183 mode=balance-alb miimon=50
1184
1185 This may be repeated any number of times, specifying a new and
1186unique name in place of bond1 for each subsequent instance.
1187
1188 It has been observed that some Red Hat supplied kernels are unable
1189to rename modules at load time (the "-o bond1" part). Attempts to pass
1190that option to modprobe will produce an "Operation not permitted" error.
1191This has been reported on some Fedora Core kernels, and has been seen on
1192RHEL 4 as well. On kernels exhibiting this problem, it will be impossible
1193to configure multiple bonds with differing parameters (as they are older
1194kernels, and also lack sysfs support).
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001195
Auke Kok6224e012006-06-08 11:15:35 -070011963.4 Configuring Bonding Manually via Sysfs
1197------------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001199 Starting with version 3.0.0, Channel Bonding may be configured
Auke Kok6224e012006-06-08 11:15:35 -07001200via the sysfs interface. This interface allows dynamic configuration
1201of all bonds in the system without unloading the module. It also
1202allows for adding and removing bonds at runtime. Ifenslave is no
1203longer required, though it is still supported.
1204
1205 Use of the sysfs interface allows you to use multiple bonds
1206with different configurations without having to reload the module.
1207It also allows you to use multiple, differently configured bonds when
1208bonding is compiled into the kernel.
1209
1210 You must have the sysfs filesystem mounted to configure
1211bonding this way. The examples in this document assume that you
1212are using the standard mount point for sysfs, e.g. /sys. If your
1213sysfs filesystem is mounted elsewhere, you will need to adjust the
1214example paths accordingly.
1215
1216Creating and Destroying Bonds
1217-----------------------------
1218To add a new bond foo:
1219# echo +foo > /sys/class/net/bonding_masters
1220
1221To remove an existing bond bar:
1222# echo -bar > /sys/class/net/bonding_masters
1223
1224To show all existing bonds:
1225# cat /sys/class/net/bonding_masters
1226
1227NOTE: due to 4K size limitation of sysfs files, this list may be
1228truncated if you have more than a few hundred bonds. This is unlikely
1229to occur under normal operating conditions.
1230
1231Adding and Removing Slaves
1232--------------------------
1233 Interfaces may be enslaved to a bond using the file
1234/sys/class/net/<bond>/bonding/slaves. The semantics for this file
1235are the same as for the bonding_masters file.
1236
1237To enslave interface eth0 to bond bond0:
1238# ifconfig bond0 up
1239# echo +eth0 > /sys/class/net/bond0/bonding/slaves
1240
1241To free slave eth0 from bond bond0:
1242# echo -eth0 > /sys/class/net/bond0/bonding/slaves
1243
Auke Kok6224e012006-06-08 11:15:35 -07001244 When an interface is enslaved to a bond, symlinks between the
1245two are created in the sysfs filesystem. In this case, you would get
1246/sys/class/net/bond0/slave_eth0 pointing to /sys/class/net/eth0, and
1247/sys/class/net/eth0/master pointing to /sys/class/net/bond0.
1248
1249 This means that you can tell quickly whether or not an
1250interface is enslaved by looking for the master symlink. Thus:
1251# echo -eth0 > /sys/class/net/eth0/master/bonding/slaves
1252will free eth0 from whatever bond it is enslaved to, regardless of
1253the name of the bond interface.
1254
1255Changing a Bond's Configuration
1256-------------------------------
1257 Each bond may be configured individually by manipulating the
1258files located in /sys/class/net/<bond name>/bonding
1259
1260 The names of these files correspond directly with the command-
Paolo Ornati670e9f32006-10-03 22:57:56 +02001261line parameters described elsewhere in this file, and, with the
Auke Kok6224e012006-06-08 11:15:35 -07001262exception of arp_ip_target, they accept the same values. To see the
1263current setting, simply cat the appropriate file.
1264
1265 A few examples will be given here; for specific usage
1266guidelines for each parameter, see the appropriate section in this
1267document.
1268
1269To configure bond0 for balance-alb mode:
1270# ifconfig bond0 down
1271# echo 6 > /sys/class/net/bond0/bonding/mode
1272 - or -
1273# echo balance-alb > /sys/class/net/bond0/bonding/mode
1274 NOTE: The bond interface must be down before the mode can be
1275changed.
1276
1277To enable MII monitoring on bond0 with a 1 second interval:
1278# echo 1000 > /sys/class/net/bond0/bonding/miimon
1279 NOTE: If ARP monitoring is enabled, it will disabled when MII
1280monitoring is enabled, and vice-versa.
1281
1282To add ARP targets:
1283# echo +192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
1284# echo +192.168.0.101 > /sys/class/net/bond0/bonding/arp_ip_target
Brian Haley5a31bec2009-04-13 00:11:30 -07001285 NOTE: up to 16 target addresses may be specified.
Auke Kok6224e012006-06-08 11:15:35 -07001286
1287To remove an ARP target:
1288# echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
1289
1290Example Configuration
1291---------------------
1292 We begin with the same example that is shown in section 3.3,
1293executed with sysfs, and without using ifenslave.
1294
1295 To make a simple bond of two e100 devices (presumed to be eth0
1296and eth1), and have it persist across reboots, edit the appropriate
1297file (/etc/init.d/boot.local or /etc/rc.d/rc.local), and add the
1298following:
1299
1300modprobe bonding
1301modprobe e100
1302echo balance-alb > /sys/class/net/bond0/bonding/mode
1303ifconfig bond0 192.168.1.1 netmask 255.255.255.0 up
1304echo 100 > /sys/class/net/bond0/bonding/miimon
1305echo +eth0 > /sys/class/net/bond0/bonding/slaves
1306echo +eth1 > /sys/class/net/bond0/bonding/slaves
1307
1308 To add a second bond, with two e1000 interfaces in
1309active-backup mode, using ARP monitoring, add the following lines to
1310your init script:
1311
1312modprobe e1000
1313echo +bond1 > /sys/class/net/bonding_masters
1314echo active-backup > /sys/class/net/bond1/bonding/mode
1315ifconfig bond1 192.168.2.1 netmask 255.255.255.0 up
1316echo +192.168.2.100 /sys/class/net/bond1/bonding/arp_ip_target
1317echo 2000 > /sys/class/net/bond1/bonding/arp_interval
1318echo +eth2 > /sys/class/net/bond1/bonding/slaves
1319echo +eth3 > /sys/class/net/bond1/bonding/slaves
1320
1321
13224. Querying Bonding Configuration
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323=================================
1324
Auke Kok6224e012006-06-08 11:15:35 -070013254.1 Bonding Configuration
Linus Torvalds1da177e2005-04-16 15:20:36 -07001326-------------------------
1327
1328 Each bonding device has a read-only file residing in the
1329/proc/net/bonding directory. The file contents include information
1330about the bonding configuration, options and state of each slave.
1331
1332 For example, the contents of /proc/net/bonding/bond0 after the
1333driver is loaded with parameters of mode=0 and miimon=1000 is
1334generally as follows:
1335
1336 Ethernet Channel Bonding Driver: 2.6.1 (October 29, 2004)
1337 Bonding Mode: load balancing (round-robin)
1338 Currently Active Slave: eth0
1339 MII Status: up
1340 MII Polling Interval (ms): 1000
1341 Up Delay (ms): 0
1342 Down Delay (ms): 0
1343
1344 Slave Interface: eth1
1345 MII Status: up
1346 Link Failure Count: 1
1347
1348 Slave Interface: eth0
1349 MII Status: up
1350 Link Failure Count: 1
1351
1352 The precise format and contents will change depending upon the
1353bonding configuration, state, and version of the bonding driver.
1354
Auke Kok6224e012006-06-08 11:15:35 -070013554.2 Network configuration
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356-------------------------
1357
1358 The network configuration can be inspected using the ifconfig
1359command. Bonding devices will have the MASTER flag set; Bonding slave
1360devices will have the SLAVE flag set. The ifconfig output does not
1361contain information on which slaves are associated with which masters.
1362
1363 In the example below, the bond0 interface is the master
1364(MASTER) while eth0 and eth1 are slaves (SLAVE). Notice all slaves of
1365bond0 have the same MAC address (HWaddr) as bond0 for all modes except
1366TLB and ALB that require a unique MAC address for each slave.
1367
1368# /sbin/ifconfig
1369bond0 Link encap:Ethernet HWaddr 00:C0:F0:1F:37:B4
1370 inet addr:XXX.XXX.XXX.YYY Bcast:XXX.XXX.XXX.255 Mask:255.255.252.0
1371 UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
1372 RX packets:7224794 errors:0 dropped:0 overruns:0 frame:0
1373 TX packets:3286647 errors:1 dropped:0 overruns:1 carrier:0
1374 collisions:0 txqueuelen:0
1375
1376eth0 Link encap:Ethernet HWaddr 00:C0:F0:1F:37:B4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001377 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
1378 RX packets:3573025 errors:0 dropped:0 overruns:0 frame:0
1379 TX packets:1643167 errors:1 dropped:0 overruns:1 carrier:0
1380 collisions:0 txqueuelen:100
1381 Interrupt:10 Base address:0x1080
1382
1383eth1 Link encap:Ethernet HWaddr 00:C0:F0:1F:37:B4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
1385 RX packets:3651769 errors:0 dropped:0 overruns:0 frame:0
1386 TX packets:1643480 errors:0 dropped:0 overruns:0 carrier:0
1387 collisions:0 txqueuelen:100
1388 Interrupt:9 Base address:0x1400
1389
Auke Kok6224e012006-06-08 11:15:35 -070013905. Switch Configuration
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391=======================
1392
1393 For this section, "switch" refers to whatever system the
1394bonded devices are directly connected to (i.e., where the other end of
1395the cable plugs into). This may be an actual dedicated switch device,
1396or it may be another regular system (e.g., another computer running
1397Linux),
1398
1399 The active-backup, balance-tlb and balance-alb modes do not
1400require any specific configuration of the switch.
1401
1402 The 802.3ad mode requires that the switch have the appropriate
1403ports configured as an 802.3ad aggregation. The precise method used
1404to configure this varies from switch to switch, but, for example, a
1405Cisco 3550 series switch requires that the appropriate ports first be
1406grouped together in a single etherchannel instance, then that
1407etherchannel is set to mode "lacp" to enable 802.3ad (instead of
1408standard EtherChannel).
1409
1410 The balance-rr, balance-xor and broadcast modes generally
1411require that the switch have the appropriate ports grouped together.
1412The nomenclature for such a group differs between switches, it may be
1413called an "etherchannel" (as in the Cisco example, above), a "trunk
1414group" or some other similar variation. For these modes, each switch
1415will also have its own configuration options for the switch's transmit
1416policy to the bond. Typical choices include XOR of either the MAC or
1417IP addresses. The transmit policy of the two peers does not need to
1418match. For these three modes, the bonding mode really selects a
1419transmit policy for an EtherChannel group; all three will interoperate
1420with another EtherChannel group.
1421
1422
Auke Kok6224e012006-06-08 11:15:35 -070014236. 802.1q VLAN Support
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424======================
1425
1426 It is possible to configure VLAN devices over a bond interface
1427using the 8021q driver. However, only packets coming from the 8021q
1428driver and passing through bonding will be tagged by default. Self
1429generated packets, for example, bonding's learning packets or ARP
1430packets generated by either ALB mode or the ARP monitor mechanism, are
1431tagged internally by bonding itself. As a result, bonding must
1432"learn" the VLAN IDs configured above it, and use those IDs to tag
1433self generated packets.
1434
1435 For reasons of simplicity, and to support the use of adapters
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001436that can do VLAN hardware acceleration offloading, the bonding
1437interface declares itself as fully hardware offloading capable, it gets
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438the add_vid/kill_vid notifications to gather the necessary
1439information, and it propagates those actions to the slaves. In case
1440of mixed adapter types, hardware accelerated tagged packets that
1441should go through an adapter that is not offloading capable are
1442"un-accelerated" by the bonding driver so the VLAN tag sits in the
1443regular location.
1444
1445 VLAN interfaces *must* be added on top of a bonding interface
1446only after enslaving at least one slave. The bonding interface has a
1447hardware address of 00:00:00:00:00:00 until the first slave is added.
1448If the VLAN interface is created prior to the first enslavement, it
1449would pick up the all-zeroes hardware address. Once the first slave
1450is attached to the bond, the bond device itself will pick up the
1451slave's hardware address, which is then available for the VLAN device.
1452
1453 Also, be aware that a similar problem can occur if all slaves
1454are released from a bond that still has one or more VLAN interfaces on
1455top of it. When a new slave is added, the bonding interface will
1456obtain its hardware address from the first slave, which might not
1457match the hardware address of the VLAN interfaces (which was
1458ultimately copied from an earlier slave).
1459
1460 There are two methods to insure that the VLAN device operates
1461with the correct hardware address if all slaves are removed from a
1462bond interface:
1463
1464 1. Remove all VLAN interfaces then recreate them
1465
1466 2. Set the bonding interface's hardware address so that it
1467matches the hardware address of the VLAN interfaces.
1468
1469 Note that changing a VLAN interface's HW address would set the
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001470underlying device -- i.e. the bonding interface -- to promiscuous
Linus Torvalds1da177e2005-04-16 15:20:36 -07001471mode, which might not be what you want.
1472
1473
Auke Kok6224e012006-06-08 11:15:35 -070014747. Link Monitoring
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475==================
1476
1477 The bonding driver at present supports two schemes for
1478monitoring a slave device's link state: the ARP monitor and the MII
1479monitor.
1480
1481 At the present time, due to implementation restrictions in the
1482bonding driver itself, it is not possible to enable both ARP and MII
1483monitoring simultaneously.
1484
Auke Kok6224e012006-06-08 11:15:35 -070014857.1 ARP Monitor Operation
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486-------------------------
1487
1488 The ARP monitor operates as its name suggests: it sends ARP
1489queries to one or more designated peer systems on the network, and
1490uses the response as an indication that the link is operating. This
1491gives some assurance that traffic is actually flowing to and from one
1492or more peers on the local network.
1493
1494 The ARP monitor relies on the device driver itself to verify
1495that traffic is flowing. In particular, the driver must keep up to
1496date the last receive time, dev->last_rx, and transmit start time,
1497dev->trans_start. If these are not updated by the driver, then the
1498ARP monitor will immediately fail any slaves using that driver, and
1499those slaves will stay down. If networking monitoring (tcpdump, etc)
1500shows the ARP requests and replies on the network, then it may be that
1501your device driver is not updating last_rx and trans_start.
1502
Auke Kok6224e012006-06-08 11:15:35 -070015037.2 Configuring Multiple ARP Targets
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504------------------------------------
1505
1506 While ARP monitoring can be done with just one target, it can
1507be useful in a High Availability setup to have several targets to
1508monitor. In the case of just one target, the target itself may go
1509down or have a problem making it unresponsive to ARP requests. Having
1510an additional target (or several) increases the reliability of the ARP
1511monitoring.
1512
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001513 Multiple ARP targets must be separated by commas as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514
1515# example options for ARP monitoring with three targets
1516alias bond0 bonding
1517options bond0 arp_interval=60 arp_ip_target=192.168.0.1,192.168.0.3,192.168.0.9
1518
1519 For just a single target the options would resemble:
1520
1521# example options for ARP monitoring with one target
1522alias bond0 bonding
1523options bond0 arp_interval=60 arp_ip_target=192.168.0.100
1524
1525
Auke Kok6224e012006-06-08 11:15:35 -070015267.3 MII Monitor Operation
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527-------------------------
1528
1529 The MII monitor monitors only the carrier state of the local
1530network interface. It accomplishes this in one of three ways: by
1531depending upon the device driver to maintain its carrier state, by
1532querying the device's MII registers, or by making an ethtool query to
1533the device.
1534
1535 If the use_carrier module parameter is 1 (the default value),
1536then the MII monitor will rely on the driver for carrier state
1537information (via the netif_carrier subsystem). As explained in the
1538use_carrier parameter information, above, if the MII monitor fails to
1539detect carrier loss on the device (e.g., when the cable is physically
1540disconnected), it may be that the driver does not support
1541netif_carrier.
1542
1543 If use_carrier is 0, then the MII monitor will first query the
1544device's (via ioctl) MII registers and check the link state. If that
1545request fails (not just that it returns carrier down), then the MII
1546monitor will make an ethtool ETHOOL_GLINK request to attempt to obtain
1547the same information. If both methods fail (i.e., the driver either
1548does not support or had some error in processing both the MII register
1549and ethtool requests), then the MII monitor will assume the link is
1550up.
1551
Auke Kok6224e012006-06-08 11:15:35 -070015528. Potential Sources of Trouble
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553===============================
1554
Auke Kok6224e012006-06-08 11:15:35 -070015558.1 Adventures in Routing
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556-------------------------
1557
1558 When bonding is configured, it is important that the slave
Auke Kok6224e012006-06-08 11:15:35 -07001559devices not have routes that supersede routes of the master (or,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560generally, not have routes at all). For example, suppose the bonding
1561device bond0 has two slaves, eth0 and eth1, and the routing table is
1562as follows:
1563
1564Kernel IP routing table
1565Destination Gateway Genmask Flags MSS Window irtt Iface
156610.0.0.0 0.0.0.0 255.255.0.0 U 40 0 0 eth0
156710.0.0.0 0.0.0.0 255.255.0.0 U 40 0 0 eth1
156810.0.0.0 0.0.0.0 255.255.0.0 U 40 0 0 bond0
1569127.0.0.0 0.0.0.0 255.0.0.0 U 40 0 0 lo
1570
1571 This routing configuration will likely still update the
1572receive/transmit times in the driver (needed by the ARP monitor), but
1573may bypass the bonding driver (because outgoing traffic to, in this
1574case, another host on network 10 would use eth0 or eth1 before bond0).
1575
1576 The ARP monitor (and ARP itself) may become confused by this
1577configuration, because ARP requests (generated by the ARP monitor)
1578will be sent on one interface (bond0), but the corresponding reply
1579will arrive on a different interface (eth0). This reply looks to ARP
1580as an unsolicited ARP reply (because ARP matches replies on an
1581interface basis), and is discarded. The MII monitor is not affected
1582by the state of the routing table.
1583
1584 The solution here is simply to insure that slaves do not have
1585routes of their own, and if for some reason they must, those routes do
Auke Kok6224e012006-06-08 11:15:35 -07001586not supersede routes of their master. This should generally be the
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587case, but unusual configurations or errant manual or automatic static
1588route additions may cause trouble.
1589
Auke Kok6224e012006-06-08 11:15:35 -070015908.2 Ethernet Device Renaming
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591----------------------------
1592
1593 On systems with network configuration scripts that do not
1594associate physical devices directly with network interface names (so
1595that the same physical device always has the same "ethX" name), it may
1596be necessary to add some special logic to either /etc/modules.conf or
1597/etc/modprobe.conf (depending upon which is installed on the system).
1598
1599 For example, given a modules.conf containing the following:
1600
1601alias bond0 bonding
1602options bond0 mode=some-mode miimon=50
1603alias eth0 tg3
1604alias eth1 tg3
1605alias eth2 e1000
1606alias eth3 e1000
1607
1608 If neither eth0 and eth1 are slaves to bond0, then when the
1609bond0 interface comes up, the devices may end up reordered. This
1610happens because bonding is loaded first, then its slave device's
1611drivers are loaded next. Since no other drivers have been loaded,
1612when the e1000 driver loads, it will receive eth0 and eth1 for its
1613devices, but the bonding configuration tries to enslave eth2 and eth3
1614(which may later be assigned to the tg3 devices).
1615
1616 Adding the following:
1617
1618add above bonding e1000 tg3
1619
1620 causes modprobe to load e1000 then tg3, in that order, when
1621bonding is loaded. This command is fully documented in the
1622modules.conf manual page.
1623
1624 On systems utilizing modprobe.conf (or modprobe.conf.local),
1625an equivalent problem can occur. In this case, the following can be
1626added to modprobe.conf (or modprobe.conf.local, as appropriate), as
1627follows (all on one line; it has been split here for clarity):
1628
1629install bonding /sbin/modprobe tg3; /sbin/modprobe e1000;
1630 /sbin/modprobe --ignore-install bonding
1631
1632 This will, when loading the bonding module, rather than
1633performing the normal action, instead execute the provided command.
1634This command loads the device drivers in the order needed, then calls
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001635modprobe with --ignore-install to cause the normal action to then take
Linus Torvalds1da177e2005-04-16 15:20:36 -07001636place. Full documentation on this can be found in the modprobe.conf
1637and modprobe manual pages.
1638
Auke Kok6224e012006-06-08 11:15:35 -070016398.3. Painfully Slow Or No Failed Link Detection By Miimon
Linus Torvalds1da177e2005-04-16 15:20:36 -07001640---------------------------------------------------------
1641
1642 By default, bonding enables the use_carrier option, which
1643instructs bonding to trust the driver to maintain carrier state.
1644
1645 As discussed in the options section, above, some drivers do
1646not support the netif_carrier_on/_off link state tracking system.
1647With use_carrier enabled, bonding will always see these links as up,
1648regardless of their actual state.
1649
1650 Additionally, other drivers do support netif_carrier, but do
1651not maintain it in real time, e.g., only polling the link state at
1652some fixed interval. In this case, miimon will detect failures, but
1653only after some long period of time has expired. If it appears that
1654miimon is very slow in detecting link failures, try specifying
1655use_carrier=0 to see if that improves the failure detection time. If
1656it does, then it may be that the driver checks the carrier state at a
1657fixed interval, but does not cache the MII register values (so the
1658use_carrier=0 method of querying the registers directly works). If
1659use_carrier=0 does not improve the failover, then the driver may cache
1660the registers, or the problem may be elsewhere.
1661
1662 Also, remember that miimon only checks for the device's
1663carrier state. It has no way to determine the state of devices on or
1664beyond other ports of a switch, or if a switch is refusing to pass
1665traffic while still maintaining carrier on.
1666
Auke Kok6224e012006-06-08 11:15:35 -070016679. SNMP agents
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668===============
1669
1670 If running SNMP agents, the bonding driver should be loaded
1671before any network drivers participating in a bond. This requirement
Tobias Klauserd533f672005-09-10 00:26:46 -07001672is due to the interface index (ipAdEntIfIndex) being associated to
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673the first interface found with a given IP address. That is, there is
1674only one ipAdEntIfIndex for each IP address. For example, if eth0 and
1675eth1 are slaves of bond0 and the driver for eth0 is loaded before the
1676bonding driver, the interface for the IP address will be associated
1677with the eth0 interface. This configuration is shown below, the IP
1678address 192.168.1.1 has an interface index of 2 which indexes to eth0
1679in the ifDescr table (ifDescr.2).
1680
1681 interfaces.ifTable.ifEntry.ifDescr.1 = lo
1682 interfaces.ifTable.ifEntry.ifDescr.2 = eth0
1683 interfaces.ifTable.ifEntry.ifDescr.3 = eth1
1684 interfaces.ifTable.ifEntry.ifDescr.4 = eth2
1685 interfaces.ifTable.ifEntry.ifDescr.5 = eth3
1686 interfaces.ifTable.ifEntry.ifDescr.6 = bond0
1687 ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.10.10.10.10 = 5
1688 ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.1.1 = 2
1689 ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.10.74.20.94 = 4
1690 ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
1691
1692 This problem is avoided by loading the bonding driver before
1693any network drivers participating in a bond. Below is an example of
1694loading the bonding driver first, the IP address 192.168.1.1 is
1695correctly associated with ifDescr.2.
1696
1697 interfaces.ifTable.ifEntry.ifDescr.1 = lo
1698 interfaces.ifTable.ifEntry.ifDescr.2 = bond0
1699 interfaces.ifTable.ifEntry.ifDescr.3 = eth0
1700 interfaces.ifTable.ifEntry.ifDescr.4 = eth1
1701 interfaces.ifTable.ifEntry.ifDescr.5 = eth2
1702 interfaces.ifTable.ifEntry.ifDescr.6 = eth3
1703 ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.10.10.10.10 = 6
1704 ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.1.1 = 2
1705 ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.10.74.20.94 = 5
1706 ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
1707
1708 While some distributions may not report the interface name in
1709ifDescr, the association between the IP address and IfIndex remains
1710and SNMP functions such as Interface_Scan_Next will report that
1711association.
1712
Auke Kok6224e012006-06-08 11:15:35 -0700171310. Promiscuous mode
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714====================
1715
1716 When running network monitoring tools, e.g., tcpdump, it is
1717common to enable promiscuous mode on the device, so that all traffic
1718is seen (instead of seeing only traffic destined for the local host).
1719The bonding driver handles promiscuous mode changes to the bonding
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001720master device (e.g., bond0), and propagates the setting to the slave
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721devices.
1722
1723 For the balance-rr, balance-xor, broadcast, and 802.3ad modes,
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001724the promiscuous mode setting is propagated to all slaves.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725
1726 For the active-backup, balance-tlb and balance-alb modes, the
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001727promiscuous mode setting is propagated only to the active slave.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728
1729 For balance-tlb mode, the active slave is the slave currently
1730receiving inbound traffic.
1731
1732 For balance-alb mode, the active slave is the slave used as a
1733"primary." This slave is used for mode-specific control traffic, for
1734sending to peers that are unassigned or if the load is unbalanced.
1735
1736 For the active-backup, balance-tlb and balance-alb modes, when
1737the active slave changes (e.g., due to a link failure), the
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001738promiscuous setting will be propagated to the new active slave.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739
Auke Kok6224e012006-06-08 11:15:35 -0700174011. Configuring Bonding for High Availability
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001741=============================================
Linus Torvalds1da177e2005-04-16 15:20:36 -07001742
1743 High Availability refers to configurations that provide
1744maximum network availability by having redundant or backup devices,
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001745links or switches between the host and the rest of the world. The
1746goal is to provide the maximum availability of network connectivity
1747(i.e., the network always works), even though other configurations
1748could provide higher throughput.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749
Auke Kok6224e012006-06-08 11:15:35 -0700175011.1 High Availability in a Single Switch Topology
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751--------------------------------------------------
1752
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001753 If two hosts (or a host and a single switch) are directly
1754connected via multiple physical links, then there is no availability
1755penalty to optimizing for maximum bandwidth. In this case, there is
1756only one switch (or peer), so if it fails, there is no alternative
1757access to fail over to. Additionally, the bonding load balance modes
1758support link monitoring of their members, so if individual links fail,
1759the load will be rebalanced across the remaining devices.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001761 See Section 13, "Configuring Bonding for Maximum Throughput"
1762for information on configuring bonding with one peer device.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763
Auke Kok6224e012006-06-08 11:15:35 -0700176411.2 High Availability in a Multiple Switch Topology
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765----------------------------------------------------
1766
1767 With multiple switches, the configuration of bonding and the
1768network changes dramatically. In multiple switch topologies, there is
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001769a trade off between network availability and usable bandwidth.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001770
1771 Below is a sample network, configured to maximize the
1772availability of the network:
1773
1774 | |
1775 |port3 port3|
1776 +-----+----+ +-----+----+
1777 | |port2 ISL port2| |
1778 | switch A +--------------------------+ switch B |
1779 | | | |
1780 +-----+----+ +-----++---+
1781 |port1 port1|
1782 | +-------+ |
1783 +-------------+ host1 +---------------+
1784 eth0 +-------+ eth1
1785
1786 In this configuration, there is a link between the two
1787switches (ISL, or inter switch link), and multiple ports connecting to
1788the outside world ("port3" on each switch). There is no technical
1789reason that this could not be extended to a third switch.
1790
Auke Kok6224e012006-06-08 11:15:35 -0700179111.2.1 HA Bonding Mode Selection for Multiple Switch Topology
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001792-------------------------------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -07001793
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001794 In a topology such as the example above, the active-backup and
1795broadcast modes are the only useful bonding modes when optimizing for
1796availability; the other modes require all links to terminate on the
1797same peer for them to behave rationally.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001798
1799active-backup: This is generally the preferred mode, particularly if
1800 the switches have an ISL and play together well. If the
1801 network configuration is such that one switch is specifically
1802 a backup switch (e.g., has lower capacity, higher cost, etc),
1803 then the primary option can be used to insure that the
1804 preferred link is always used when it is available.
1805
1806broadcast: This mode is really a special purpose mode, and is suitable
1807 only for very specific needs. For example, if the two
1808 switches are not connected (no ISL), and the networks beyond
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001809 them are totally independent. In this case, if it is
Linus Torvalds1da177e2005-04-16 15:20:36 -07001810 necessary for some specific one-way traffic to reach both
1811 independent networks, then the broadcast mode may be suitable.
1812
Auke Kok6224e012006-06-08 11:15:35 -0700181311.2.2 HA Link Monitoring Selection for Multiple Switch Topology
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001814----------------------------------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815
1816 The choice of link monitoring ultimately depends upon your
1817switch. If the switch can reliably fail ports in response to other
1818failures, then either the MII or ARP monitors should work. For
1819example, in the above example, if the "port3" link fails at the remote
1820end, the MII monitor has no direct means to detect this. The ARP
1821monitor could be configured with a target at the remote end of port3,
1822thus detecting that failure without switch support.
1823
1824 In general, however, in a multiple switch topology, the ARP
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001825monitor can provide a higher level of reliability in detecting end to
1826end connectivity failures (which may be caused by the failure of any
1827individual component to pass traffic for any reason). Additionally,
1828the ARP monitor should be configured with multiple targets (at least
1829one for each switch in the network). This will insure that,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830regardless of which switch is active, the ARP monitor has a suitable
1831target to query.
1832
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001833 Note, also, that of late many switches now support a functionality
1834generally referred to as "trunk failover." This is a feature of the
1835switch that causes the link state of a particular switch port to be set
1836down (or up) when the state of another switch port goes down (or up).
Matt LaPlante19f59462009-04-27 15:06:31 +02001837Its purpose is to propagate link failures from logically "exterior" ports
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001838to the logically "interior" ports that bonding is able to monitor via
1839miimon. Availability and configuration for trunk failover varies by
1840switch, but this can be a viable alternative to the ARP monitor when using
1841suitable switches.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842
Auke Kok6224e012006-06-08 11:15:35 -0700184312. Configuring Bonding for Maximum Throughput
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001844==============================================
Linus Torvalds1da177e2005-04-16 15:20:36 -07001845
Auke Kok6224e012006-06-08 11:15:35 -0700184612.1 Maximizing Throughput in a Single Switch Topology
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001847------------------------------------------------------
1848
1849 In a single switch configuration, the best method to maximize
1850throughput depends upon the application and network environment. The
1851various load balancing modes each have strengths and weaknesses in
1852different environments, as detailed below.
1853
1854 For this discussion, we will break down the topologies into
1855two categories. Depending upon the destination of most traffic, we
1856categorize them into either "gatewayed" or "local" configurations.
1857
1858 In a gatewayed configuration, the "switch" is acting primarily
1859as a router, and the majority of traffic passes through this router to
1860other networks. An example would be the following:
1861
1862
1863 +----------+ +----------+
1864 | |eth0 port1| | to other networks
1865 | Host A +---------------------+ router +------------------->
1866 | +---------------------+ | Hosts B and C are out
1867 | |eth1 port2| | here somewhere
1868 +----------+ +----------+
1869
1870 The router may be a dedicated router device, or another host
1871acting as a gateway. For our discussion, the important point is that
1872the majority of traffic from Host A will pass through the router to
1873some other network before reaching its final destination.
1874
1875 In a gatewayed network configuration, although Host A may
1876communicate with many other systems, all of its traffic will be sent
1877and received via one other peer on the local network, the router.
1878
1879 Note that the case of two systems connected directly via
1880multiple physical links is, for purposes of configuring bonding, the
1881same as a gatewayed configuration. In that case, it happens that all
1882traffic is destined for the "gateway" itself, not some other network
1883beyond the gateway.
1884
1885 In a local configuration, the "switch" is acting primarily as
1886a switch, and the majority of traffic passes through this switch to
1887reach other stations on the same network. An example would be the
1888following:
1889
1890 +----------+ +----------+ +--------+
1891 | |eth0 port1| +-------+ Host B |
1892 | Host A +------------+ switch |port3 +--------+
1893 | +------------+ | +--------+
1894 | |eth1 port2| +------------------+ Host C |
1895 +----------+ +----------+port4 +--------+
1896
1897
1898 Again, the switch may be a dedicated switch device, or another
1899host acting as a gateway. For our discussion, the important point is
1900that the majority of traffic from Host A is destined for other hosts
1901on the same local network (Hosts B and C in the above example).
1902
1903 In summary, in a gatewayed configuration, traffic to and from
1904the bonded device will be to the same MAC level peer on the network
1905(the gateway itself, i.e., the router), regardless of its final
1906destination. In a local configuration, traffic flows directly to and
1907from the final destinations, thus, each destination (Host B, Host C)
1908will be addressed directly by their individual MAC addresses.
1909
1910 This distinction between a gatewayed and a local network
1911configuration is important because many of the load balancing modes
1912available use the MAC addresses of the local network source and
1913destination to make load balancing decisions. The behavior of each
1914mode is described below.
1915
1916
Auke Kok6224e012006-06-08 11:15:35 -0700191712.1.1 MT Bonding Mode Selection for Single Switch Topology
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001918-----------------------------------------------------------
1919
1920 This configuration is the easiest to set up and to understand,
1921although you will have to decide which bonding mode best suits your
1922needs. The trade offs for each mode are detailed below:
1923
1924balance-rr: This mode is the only mode that will permit a single
1925 TCP/IP connection to stripe traffic across multiple
1926 interfaces. It is therefore the only mode that will allow a
1927 single TCP/IP stream to utilize more than one interface's
1928 worth of throughput. This comes at a cost, however: the
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001929 striping generally results in peer systems receiving packets out
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001930 of order, causing TCP/IP's congestion control system to kick
1931 in, often by retransmitting segments.
1932
1933 It is possible to adjust TCP/IP's congestion limits by
1934 altering the net.ipv4.tcp_reordering sysctl parameter. The
1935 usual default value is 3, and the maximum useful value is 127.
1936 For a four interface balance-rr bond, expect that a single
1937 TCP/IP stream will utilize no more than approximately 2.3
1938 interface's worth of throughput, even after adjusting
1939 tcp_reordering.
1940
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08001941 Note that the fraction of packets that will be delivered out of
1942 order is highly variable, and is unlikely to be zero. The level
1943 of reordering depends upon a variety of factors, including the
1944 networking interfaces, the switch, and the topology of the
1945 configuration. Speaking in general terms, higher speed network
1946 cards produce more reordering (due to factors such as packet
1947 coalescing), and a "many to many" topology will reorder at a
1948 higher rate than a "many slow to one fast" configuration.
1949
1950 Many switches do not support any modes that stripe traffic
1951 (instead choosing a port based upon IP or MAC level addresses);
1952 for those devices, traffic for a particular connection flowing
1953 through the switch to a balance-rr bond will not utilize greater
1954 than one interface's worth of bandwidth.
Jay Vosburgh00354cf2005-07-21 12:18:02 -07001955
1956 If you are utilizing protocols other than TCP/IP, UDP for
1957 example, and your application can tolerate out of order
1958 delivery, then this mode can allow for single stream datagram
1959 performance that scales near linearly as interfaces are added
1960 to the bond.
1961
1962 This mode requires the switch to have the appropriate ports
1963 configured for "etherchannel" or "trunking."
1964
1965active-backup: There is not much advantage in this network topology to
1966 the active-backup mode, as the inactive backup devices are all
1967 connected to the same peer as the primary. In this case, a
1968 load balancing mode (with link monitoring) will provide the
1969 same level of network availability, but with increased
1970 available bandwidth. On the plus side, active-backup mode
1971 does not require any configuration of the switch, so it may
1972 have value if the hardware available does not support any of
1973 the load balance modes.
1974
1975balance-xor: This mode will limit traffic such that packets destined
1976 for specific peers will always be sent over the same
1977 interface. Since the destination is determined by the MAC
1978 addresses involved, this mode works best in a "local" network
1979 configuration (as described above), with destinations all on
1980 the same local network. This mode is likely to be suboptimal
1981 if all your traffic is passed through a single router (i.e., a
1982 "gatewayed" network configuration, as described above).
1983
1984 As with balance-rr, the switch ports need to be configured for
1985 "etherchannel" or "trunking."
1986
1987broadcast: Like active-backup, there is not much advantage to this
1988 mode in this type of network topology.
1989
1990802.3ad: This mode can be a good choice for this type of network
1991 topology. The 802.3ad mode is an IEEE standard, so all peers
1992 that implement 802.3ad should interoperate well. The 802.3ad
1993 protocol includes automatic configuration of the aggregates,
1994 so minimal manual configuration of the switch is needed
1995 (typically only to designate that some set of devices is
1996 available for 802.3ad). The 802.3ad standard also mandates
1997 that frames be delivered in order (within certain limits), so
1998 in general single connections will not see misordering of
1999 packets. The 802.3ad mode does have some drawbacks: the
2000 standard mandates that all devices in the aggregate operate at
2001 the same speed and duplex. Also, as with all bonding load
2002 balance modes other than balance-rr, no single connection will
2003 be able to utilize more than a single interface's worth of
2004 bandwidth.
2005
2006 Additionally, the linux bonding 802.3ad implementation
2007 distributes traffic by peer (using an XOR of MAC addresses),
2008 so in a "gatewayed" configuration, all outgoing traffic will
2009 generally use the same device. Incoming traffic may also end
2010 up on a single device, but that is dependent upon the
2011 balancing policy of the peer's 8023.ad implementation. In a
2012 "local" configuration, traffic will be distributed across the
2013 devices in the bond.
2014
2015 Finally, the 802.3ad mode mandates the use of the MII monitor,
2016 therefore, the ARP monitor is not available in this mode.
2017
2018balance-tlb: The balance-tlb mode balances outgoing traffic by peer.
2019 Since the balancing is done according to MAC address, in a
2020 "gatewayed" configuration (as described above), this mode will
2021 send all traffic across a single device. However, in a
2022 "local" network configuration, this mode balances multiple
2023 local network peers across devices in a vaguely intelligent
2024 manner (not a simple XOR as in balance-xor or 802.3ad mode),
2025 so that mathematically unlucky MAC addresses (i.e., ones that
2026 XOR to the same value) will not all "bunch up" on a single
2027 interface.
2028
2029 Unlike 802.3ad, interfaces may be of differing speeds, and no
2030 special switch configuration is required. On the down side,
2031 in this mode all incoming traffic arrives over a single
2032 interface, this mode requires certain ethtool support in the
2033 network device driver of the slave interfaces, and the ARP
2034 monitor is not available.
2035
2036balance-alb: This mode is everything that balance-tlb is, and more.
2037 It has all of the features (and restrictions) of balance-tlb,
2038 and will also balance incoming traffic from local network
2039 peers (as described in the Bonding Module Options section,
2040 above).
2041
2042 The only additional down side to this mode is that the network
2043 device driver must support changing the hardware address while
2044 the device is open.
2045
Auke Kok6224e012006-06-08 11:15:35 -0700204612.1.2 MT Link Monitoring for Single Switch Topology
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002047----------------------------------------------------
2048
2049 The choice of link monitoring may largely depend upon which
2050mode you choose to use. The more advanced load balancing modes do not
2051support the use of the ARP monitor, and are thus restricted to using
2052the MII monitor (which does not provide as high a level of end to end
2053assurance as the ARP monitor).
2054
Auke Kok6224e012006-06-08 11:15:35 -0700205512.2 Maximum Throughput in a Multiple Switch Topology
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002056-----------------------------------------------------
2057
2058 Multiple switches may be utilized to optimize for throughput
2059when they are configured in parallel as part of an isolated network
2060between two or more systems, for example:
2061
2062 +-----------+
2063 | Host A |
2064 +-+---+---+-+
2065 | | |
2066 +--------+ | +---------+
2067 | | |
2068 +------+---+ +-----+----+ +-----+----+
2069 | Switch A | | Switch B | | Switch C |
2070 +------+---+ +-----+----+ +-----+----+
2071 | | |
2072 +--------+ | +---------+
2073 | | |
2074 +-+---+---+-+
2075 | Host B |
2076 +-----------+
2077
2078 In this configuration, the switches are isolated from one
2079another. One reason to employ a topology such as this is for an
2080isolated network with many hosts (a cluster configured for high
2081performance, for example), using multiple smaller switches can be more
2082cost effective than a single larger switch, e.g., on a network with 24
2083hosts, three 24 port switches can be significantly less expensive than
2084a single 72 port switch.
2085
2086 If access beyond the network is required, an individual host
2087can be equipped with an additional network device connected to an
2088external network; this host then additionally acts as a gateway.
2089
Auke Kok6224e012006-06-08 11:15:35 -0700209012.2.1 MT Bonding Mode Selection for Multiple Switch Topology
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002091-------------------------------------------------------------
2092
2093 In actual practice, the bonding mode typically employed in
2094configurations of this type is balance-rr. Historically, in this
2095network configuration, the usual caveats about out of order packet
2096delivery are mitigated by the use of network adapters that do not do
2097any kind of packet coalescing (via the use of NAPI, or because the
2098device itself does not generate interrupts until some number of
2099packets has arrived). When employed in this fashion, the balance-rr
2100mode allows individual connections between two hosts to effectively
2101utilize greater than one interface's bandwidth.
2102
Auke Kok6224e012006-06-08 11:15:35 -0700210312.2.2 MT Link Monitoring for Multiple Switch Topology
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002104------------------------------------------------------
2105
2106 Again, in actual practice, the MII monitor is most often used
2107in this configuration, as performance is given preference over
2108availability. The ARP monitor will function in this topology, but its
2109advantages over the MII monitor are mitigated by the volume of probes
2110needed as the number of systems involved grows (remember that each
2111host in the network is configured with bonding).
2112
Auke Kok6224e012006-06-08 11:15:35 -0700211313. Switch Behavior Issues
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002114==========================
2115
Auke Kok6224e012006-06-08 11:15:35 -0700211613.1 Link Establishment and Failover Delays
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002117-------------------------------------------
2118
2119 Some switches exhibit undesirable behavior with regard to the
2120timing of link up and down reporting by the switch.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121
2122 First, when a link comes up, some switches may indicate that
2123the link is up (carrier available), but not pass traffic over the
2124interface for some period of time. This delay is typically due to
2125some type of autonegotiation or routing protocol, but may also occur
2126during switch initialization (e.g., during recovery after a switch
2127failure). If you find this to be a problem, specify an appropriate
2128value to the updelay bonding module option to delay the use of the
2129relevant interface(s).
2130
2131 Second, some switches may "bounce" the link state one or more
2132times while a link is changing state. This occurs most commonly while
2133the switch is initializing. Again, an appropriate updelay value may
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002134help.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002135
2136 Note that when a bonding interface has no active links, the
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002137driver will immediately reuse the first link that goes up, even if the
2138updelay parameter has been specified (the updelay is ignored in this
2139case). If there are slave interfaces waiting for the updelay timeout
2140to expire, the interface that first went into that state will be
2141immediately reused. This reduces down time of the network if the
2142value of updelay has been overestimated, and since this occurs only in
2143cases with no connectivity, there is no additional penalty for
2144ignoring the updelay.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145
2146 In addition to the concerns about switch timings, if your
2147switches take a long time to go into backup mode, it may be desirable
2148to not activate a backup interface immediately after a link goes down.
2149Failover may be delayed via the downdelay bonding module option.
2150
Auke Kok6224e012006-06-08 11:15:35 -0700215113.2 Duplicated Incoming Packets
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002152--------------------------------
2153
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08002154 NOTE: Starting with version 3.0.2, the bonding driver has logic to
2155suppress duplicate packets, which should largely eliminate this problem.
2156The following description is kept for reference.
2157
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002158 It is not uncommon to observe a short burst of duplicated
2159traffic when the bonding device is first used, or after it has been
2160idle for some period of time. This is most easily observed by issuing
2161a "ping" to some other host on the network, and noticing that the
2162output from ping flags duplicates (typically one per slave).
2163
2164 For example, on a bond in active-backup mode with five slaves
2165all connected to one switch, the output may appear as follows:
2166
2167# ping -n 10.0.4.2
2168PING 10.0.4.2 (10.0.4.2) from 10.0.3.10 : 56(84) bytes of data.
216964 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.7 ms
217064 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)
217164 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)
217264 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)
217364 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)
217464 bytes from 10.0.4.2: icmp_seq=2 ttl=64 time=0.216 ms
217564 bytes from 10.0.4.2: icmp_seq=3 ttl=64 time=0.267 ms
217664 bytes from 10.0.4.2: icmp_seq=4 ttl=64 time=0.222 ms
2177
2178 This is not due to an error in the bonding driver, rather, it
2179is a side effect of how many switches update their MAC forwarding
2180tables. Initially, the switch does not associate the MAC address in
2181the packet with a particular switch port, and so it may send the
2182traffic to all ports until its MAC forwarding table is updated. Since
2183the interfaces attached to the bond may occupy multiple ports on a
2184single switch, when the switch (temporarily) floods the traffic to all
2185ports, the bond device receives multiple copies of the same packet
2186(one per slave device).
2187
2188 The duplicated packet behavior is switch dependent, some
2189switches exhibit this, and some do not. On switches that display this
2190behavior, it can be induced by clearing the MAC forwarding table (on
2191most Cisco switches, the privileged command "clear mac address-table
2192dynamic" will accomplish this).
2193
Auke Kok6224e012006-06-08 11:15:35 -0700219414. Hardware Specific Considerations
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195====================================
2196
2197 This section contains additional information for configuring
2198bonding on specific hardware platforms, or for interfacing bonding
2199with particular switches or other devices.
2200
Auke Kok6224e012006-06-08 11:15:35 -0700220114.1 IBM BladeCenter
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202--------------------
2203
2204 This applies to the JS20 and similar systems.
2205
2206 On the JS20 blades, the bonding driver supports only
2207balance-rr, active-backup, balance-tlb and balance-alb modes. This is
2208largely due to the network topology inside the BladeCenter, detailed
2209below.
2210
2211JS20 network adapter information
2212--------------------------------
2213
2214 All JS20s come with two Broadcom Gigabit Ethernet ports
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002215integrated on the planar (that's "motherboard" in IBM-speak). In the
2216BladeCenter chassis, the eth0 port of all JS20 blades is hard wired to
2217I/O Module #1; similarly, all eth1 ports are wired to I/O Module #2.
2218An add-on Broadcom daughter card can be installed on a JS20 to provide
2219two more Gigabit Ethernet ports. These ports, eth2 and eth3, are
2220wired to I/O Modules 3 and 4, respectively.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221
2222 Each I/O Module may contain either a switch or a passthrough
2223module (which allows ports to be directly connected to an external
2224switch). Some bonding modes require a specific BladeCenter internal
2225network topology in order to function; these are detailed below.
2226
2227 Additional BladeCenter-specific networking information can be
2228found in two IBM Redbooks (www.ibm.com/redbooks):
2229
2230"IBM eServer BladeCenter Networking Options"
2231"IBM eServer BladeCenter Layer 2-7 Network Switching"
2232
2233BladeCenter networking configuration
2234------------------------------------
2235
2236 Because a BladeCenter can be configured in a very large number
2237of ways, this discussion will be confined to describing basic
2238configurations.
2239
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002240 Normally, Ethernet Switch Modules (ESMs) are used in I/O
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241modules 1 and 2. In this configuration, the eth0 and eth1 ports of a
2242JS20 will be connected to different internal switches (in the
2243respective I/O modules).
2244
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002245 A passthrough module (OPM or CPM, optical or copper,
2246passthrough module) connects the I/O module directly to an external
2247switch. By using PMs in I/O module #1 and #2, the eth0 and eth1
2248interfaces of a JS20 can be redirected to the outside world and
2249connected to a common external switch.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002251 Depending upon the mix of ESMs and PMs, the network will
2252appear to bonding as either a single switch topology (all PMs) or as a
2253multiple switch topology (one or more ESMs, zero or more PMs). It is
2254also possible to connect ESMs together, resulting in a configuration
2255much like the example in "High Availability in a Multiple Switch
2256Topology," above.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002258Requirements for specific modes
2259-------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002261 The balance-rr mode requires the use of passthrough modules
2262for devices in the bond, all connected to an common external switch.
2263That switch must be configured for "etherchannel" or "trunking" on the
Linus Torvalds1da177e2005-04-16 15:20:36 -07002264appropriate ports, as is usual for balance-rr.
2265
2266 The balance-alb and balance-tlb modes will function with
2267either switch modules or passthrough modules (or a mix). The only
2268specific requirement for these modes is that all network interfaces
2269must be able to reach all destinations for traffic sent over the
2270bonding device (i.e., the network must converge at some point outside
2271the BladeCenter).
2272
2273 The active-backup mode has no additional requirements.
2274
2275Link monitoring issues
2276----------------------
2277
2278 When an Ethernet Switch Module is in place, only the ARP
2279monitor will reliably detect link loss to an external switch. This is
2280nothing unusual, but examination of the BladeCenter cabinet would
2281suggest that the "external" network ports are the ethernet ports for
2282the system, when it fact there is a switch between these "external"
2283ports and the devices on the JS20 system itself. The MII monitor is
2284only able to detect link failures between the ESM and the JS20 system.
2285
2286 When a passthrough module is in place, the MII monitor does
2287detect failures to the "external" port, which is then directly
2288connected to the JS20 system.
2289
2290Other concerns
2291--------------
2292
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002293 The Serial Over LAN (SoL) link is established over the primary
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294ethernet (eth0) only, therefore, any loss of link to eth0 will result
2295in losing your SoL connection. It will not fail over with other
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002296network traffic, as the SoL system is beyond the control of the
2297bonding driver.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298
2299 It may be desirable to disable spanning tree on the switch
2300(either the internal Ethernet Switch Module, or an external switch) to
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002301avoid fail-over delay issues when using bonding.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302
2303
Auke Kok6224e012006-06-08 11:15:35 -0700230415. Frequently Asked Questions
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305==============================
2306
23071. Is it SMP safe?
2308
2309 Yes. The old 2.0.xx channel bonding patch was not SMP safe.
2310The new driver was designed to be SMP safe from the start.
2311
23122. What type of cards will work with it?
2313
2314 Any Ethernet type cards (you can even mix cards - a Intel
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002315EtherExpress PRO/100 and a 3com 3c905b, for example). For most modes,
2316devices need not be of the same speed.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08002318 Starting with version 3.2.1, bonding also supports Infiniband
2319slaves in active-backup mode.
2320
Linus Torvalds1da177e2005-04-16 15:20:36 -070023213. How many bonding devices can I have?
2322
2323 There is no limit.
2324
23254. How many slaves can a bonding device have?
2326
2327 This is limited only by the number of network interfaces Linux
2328supports and/or the number of network cards you can place in your
2329system.
2330
23315. What happens when a slave link dies?
2332
2333 If link monitoring is enabled, then the failing device will be
2334disabled. The active-backup mode will fail over to a backup link, and
2335other modes will ignore the failed link. The link will continue to be
2336monitored, and should it recover, it will rejoin the bond (in whatever
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002337manner is appropriate for the mode). See the sections on High
2338Availability and the documentation for each mode for additional
2339information.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340
2341 Link monitoring can be enabled via either the miimon or
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002342arp_interval parameters (described in the module parameters section,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002343above). In general, miimon monitors the carrier state as sensed by
2344the underlying network device, and the arp monitor (arp_interval)
2345monitors connectivity to another host on the local network.
2346
2347 If no link monitoring is configured, the bonding driver will
2348be unable to detect link failures, and will assume that all links are
2349always available. This will likely result in lost packets, and a
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002350resulting degradation of performance. The precise performance loss
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351depends upon the bonding mode and network configuration.
2352
23536. Can bonding be used for High Availability?
2354
2355 Yes. See the section on High Availability for details.
2356
23577. Which switches/systems does it work with?
2358
2359 The full answer to this depends upon the desired mode.
2360
2361 In the basic balance modes (balance-rr and balance-xor), it
2362works with any system that supports etherchannel (also called
2363trunking). Most managed switches currently available have such
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002364support, and many unmanaged switches as well.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365
2366 The advanced balance modes (balance-tlb and balance-alb) do
2367not have special switch requirements, but do need device drivers that
2368support specific features (described in the appropriate section under
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002369module parameters, above).
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370
Auke Kok6224e012006-06-08 11:15:35 -07002371 In 802.3ad mode, it works with systems that support IEEE
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372802.3ad Dynamic Link Aggregation. Most managed and many unmanaged
2373switches currently available support 802.3ad.
2374
2375 The active-backup mode should work with any Layer-II switch.
2376
23778. Where does a bonding device get its MAC address from?
2378
Jay Vosburgh9a6c6862007-11-13 20:25:48 -08002379 When using slave devices that have fixed MAC addresses, or when
2380the fail_over_mac option is enabled, the bonding device's MAC address is
2381the MAC address of the active slave.
2382
2383 For other configurations, if not explicitly configured (with
2384ifconfig or ip link), the MAC address of the bonding device is taken from
2385its first slave device. This MAC address is then passed to all following
2386slaves and remains persistent (even if the first slave is removed) until
2387the bonding device is brought down or reconfigured.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388
2389 If you wish to change the MAC address, you can set it with
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002390ifconfig or ip link:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391
2392# ifconfig bond0 hw ether 00:11:22:33:44:55
2393
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002394# ip link set bond0 address 66:77:88:99:aa:bb
2395
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396 The MAC address can be also changed by bringing down/up the
2397device and then changing its slaves (or their order):
2398
2399# ifconfig bond0 down ; modprobe -r bonding
2400# ifconfig bond0 .... up
2401# ifenslave bond0 eth...
2402
2403 This method will automatically take the address from the next
2404slave that is added.
2405
2406 To restore your slaves' MAC addresses, you need to detach them
2407from the bond (`ifenslave -d bond0 eth0'). The bonding driver will
2408then restore the MAC addresses that the slaves had before they were
2409enslaved.
2410
Jay Vosburgh00354cf2005-07-21 12:18:02 -0700241116. Resources and Links
Linus Torvalds1da177e2005-04-16 15:20:36 -07002412=======================
2413
2414The latest version of the bonding driver can be found in the latest
2415version of the linux kernel, found on http://kernel.org
2416
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002417The latest version of this document can be found in either the latest
2418kernel source (named Documentation/networking/bonding.txt), or on the
2419bonding sourceforge site:
2420
2421http://www.sourceforge.net/projects/bonding
2422
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423Discussions regarding the bonding driver take place primarily on the
2424bonding-devel mailing list, hosted at sourceforge.net. If you have
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002425questions or problems, post them to the list. The list address is:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002426
2427bonding-devel@lists.sourceforge.net
2428
Jay Vosburgh00354cf2005-07-21 12:18:02 -07002429 The administrative interface (to subscribe or unsubscribe) can
2430be found at:
2431
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432https://lists.sourceforge.net/lists/listinfo/bonding-devel
2433
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434Donald Becker's Ethernet Drivers and diag programs may be found at :
2435 - http://www.scyld.com/network/
2436
2437You will also find a lot of information regarding Ethernet, NWay, MII,
2438etc. at www.scyld.com.
2439
2440-- END --