Ethernet bonding is sweet to have when you want failover and/or increase throughput. In Linux, there are a few different setups that you can choose from to suit your requirements. But the switch or router must support link aggregation!
Using ifenslave, you can bond two ethernets together. When two network devices are bonded, both of them will take on the master’s MAC address (or you can predefine it in /etc/network/interfaces). Now, this is not interesting when your server reboots for some reason. The secondary NIC will not be able to be bonded again because it won’t be called eth1 when rebooted but rather aliased with a different name due to how the udev rules are generated.
In Debian Lenny, /etc/udev/rules.d/75-persistent-net-generator.rules will generate the necessary ruleset, depending on your network hardware configuration, to /etc/udev/rules.d/70-persistent-net.rules. By default, the following exists in 70-persistent-net.rules…
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:19:db:f7:00:b7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:19:db:f6:7a:d5", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
75-persistent-net-generator.rules will generate the above rule to add a network device based on its MAC address. This is definitely not interesting for us.
We can start writing udev rules after finding out the info we need using udevinfo -a -p /sys/class/net/[device name]. Instead of using MAC address to determine our NIC alias, we’ll use the driver, vendor and device id to be 100% sure. With those info, we can create the following udev rules…
SUBSYSTEM=="pci", ACTION=="add", DRIVERS=="r8169", ATTR{vendor}=="0x10ec", ATTR{device}="0x8168", NAME=="eth0"
SUBSYSTEM=="pci", ACTION=="add", DRIVERS=="r8169", ATTR{vendor}=="0x10ec", ATTR{device}="0x8167", NAME=="eth1"
We can be pretty certain that both these NICs will be bonded regardless of the MAC changes.
Am sure we can also change the way 75-persistent-net-generator.rules generates the ruleset. But it’s pretty pointless to do it when you already know which devices you have.
This method would be a good direct solution.