- Balance-rr (mode 0)
- Active-backup (mode 1)
- Balance-xor (mode 2)
- Broadcast (mode 3)
- 802.3ad (mode4)
- Balance-tlb (mode 5)
- Balance-alb (mode 6)
For this example we will use a basic mode 1, using eth0 and eth1 to generate bond0. First, we create the module configuration we need in the folder /etc/modprobe.d:
Note that miimon parameter is the link monitoring frequency in milliseconds (how often the link will be inspected to check if its failing or its busy).# vim bonding.conf
alias netdev-bond0 bonding
options bond0 miimon=100 mode=1
When we create a bonding, we need to put the teamed interfaces in slave mode. For making this easy we will install the package ifenslave:
$ sudo apt-get install ifenslave
This package will generate some scripts in the /etc/network/if-up.d and /etc/network/if-pre-up.d directories that will configure the slaves to serve the master (bonding interface).
Now, we configure the file /etc/network/interfaces. We comment the entries for our defined interfaces and specify the configuration for the bond0 interfaces:
$ sudo vim /etc/network/interfaces
auto lo
iface lo inet loopback
# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp
auto bond0
iface bond0 inet dhcp
slaves eth0 eth1
bond-mode 1bond-miimon 100
In this case we have duplicated the information already passed to the module. If we need multiple bondX interfaces, we need to declare the configuration in this file.
Now we restart the networking service and we get our interface working:
$ sudo service networking stop
$ sudo service networking start
Let's check:
$ /sbin/ifconfig bond0
bond0 Link encap:Ethernet HWaddr 08:00:27:e1:89:77
inet addr:10.65.17.158 Bcast:10.65.17.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fee1:8977/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:27926 errors:0 dropped:0 overruns:0 frame:0
TX packets:599 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2230068 (2.1 MiB) TX bytes:40408 (39.4 KiB)
If we have issues getting up the bond0 interface, it could be that the slaves are not well defined or not set as slaves. We can check with mii-tool:
# mii-tool bond0
bond0: 10 Mbit, half duplex, link ok
If we don't get a message similar to the one above and similar to "No Mii transceivers found" most likely there's an issue with the slaves.
For a full list of options available have a look at the kernel documentation for bonding.
No comments:
Post a Comment