Failover Network Interfaces in FreeBSD

Ok, so I wanted a way for my FreeBSD server to be unaffected during a switch failure.  In the past, I had used etherchannel to aggregate multiple ports together – but they had always been to the same switch (and involved switch configuration).  In FreeBSD 7, it’s pretty simple to setup a basic link-state failover connection.

In my configuration, I am using an Intel Pro/1000T Server card as my primary link (interface name “em0”), and a Broadcom Gigabit Ethernet onboard card as my backup link (interface name “bge0”).

To setup failover,we need to load the driver.  Edit /boot/loader.conf and add:

if_lagg_load=”YES”

Now we can do everything in /etc/rc.conf with the following configuration:

ifconfig_em0=”up”
ifconfig_bge0=”up”
cloned_interfaces=”lagg0″
ifconfig_lagg0=”laggproto failover laggport em0 laggport bge0″
ifconfig_lagg0_alias0=”inet 10.0.0.1 netmask 255.0.0.0″

The first interface listed for laggport becomes the primary.  When we check ifconfig, we can see:

bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
lagg: laggdev lagg0

em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
lagg: laggdev lagg0

lagg0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
inet 10.0.0.1 netmask 0xff000000 broadcast 10.0.0.255
media: Ethernet autoselect
status: active
laggproto failover
laggport: bge0 flags=0<>
laggport: em0 flags=5<MASTER,ACTIVE>

If you unplug the cable to em0, the server handles the failover automatically to bge0 with the loss of only a couple of packets – more than acceptable!

Leave a Reply

Your email address will not be published. Required fields are marked *