This page aims to show you how to configure your FreeBSD systems to be L2 fault tolerant.
Here is our example setup:
In modern versions of FreeBSD 7+ we have two options on how to implement this type of failover:
Contents |
With lagg(4) we can do the following in rc.conf to enable a failover interface:
cloned_interfaces="lagg0" ifconfig_em0="UP" ifconfig_em1="UP" ifconfig_lagg0="up laggproto failover laggport em0 laggport em1 10.123.123.123/24"
Now you can start the interface using the following command or reboot:
ifconfig em0 up ifconfig em1 up ifconfig lagg0 create
Now your ifconfig output should look like this:
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM>
ether 00:1e:c9:f2:90:a0
media: Ethernet autoselect (1000baseTX <full-duplex>)
status: active
lagg: laggdev lagg0
em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM>
ether 00:1e:c9:f2:90:a0
media: Ethernet autoselect (1000baseTX <full-duplex>)
status: active
lagg: laggdev lagg0
lagg0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM>
ether 00:1e:c9:f2:90:a0
inet 10.123.123.123 netmask 0xffffff00 broadcast 10.123.123.255
media: Ethernet autoselect
status: active
laggproto failover
laggport: em0 flags=4<ACTIVE>
laggport: em1 flags=1<MASTER>
There are some issues with failover mode if you run spanning tree on your switches and don't enable portfast on the ports your server is connected to. See the follow 2 tables for why.
| Event | em0 | em1 | switch(em0) | switch(em1) |
|---|---|---|---|---|
| Start | UP | UP | UP+Forwarding | UP+Forwarding |
| Down em0 | DOWN | UP | DOWN | UP+Forwarding |
| UP em0 | UP | UP | UP+Learning | UP+Forwarding |
| STP Learning complete | UP | UP | UP+Forwarding | UP+Forwarding |
| Event | em0 | em1 | switch(em0) | switch(em1) |
|---|---|---|---|---|
| Start | UP | UP | UP+Forwarding | UP+Forwarding |
| Down em0 | DOWN | UP | DOWN | UP+Forwarding |
| UP em0 | UP | UP | UP+Forwarding | UP+Forwarding |
Bridge mode has some advantages over lagg. Consider that the link fails between Sw1 and Sw2 with lagg this would result in all the hosts on SW1 and SW3 being unreachable if em1 was the master interface and hosts on SW2 being unreachable if em0 was the master. With bridge you participate in the spanning tree and this would mean that all hosts are still reachable.
Some times you will not be able to use the bridge method, one such sinario is if you have dual hand off's from an ISP. They will not want you to talk spanning tree to their L2 infrastructure, and will probably filter out all STP traffic. Worse still they may use portfast on your access ports which will cause them to get disabled the first time you try to speak STP on the ports.
With bridge(4) we can do the following in rc.conf to enable a failover interface:
cloned_interfaces="bridge0" ifconfig_em0="UP" ifconfig_em1="UP" ifconfig_bridge0="up addm em0 stp em0 addm em1 stp em1 10.123.123.123/24"
Now you can start the interface using the following command or reboot:
ifconfig em0 up ifconfig em1 up ifconfig bridge0 create
Now your ifconfig output should look like this:
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM> ether 00:1e:c9:f2:90:a0 media: Ethernet autoselect (1000baseTX <full-duplex>) status: active lagg: laggdev lagg0 em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM> ether 00:1e:c9:f2:90:a0 media: Ethernet autoselect (1000baseTX <full-duplex>) status: active lagg: laggdev lagg0 bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 ether 00:1e:c9:f2:90:a0 id 00:04:23:e5:61:0c priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200 root id 00:1c:23:5c:92:c0 priority 4096 ifcost 2000004 port 1 member: em1 flags=1c7<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP> ifmaxaddr 0 port 2 priority 128 path cost 2000000 proto rstp role alternate state discarding member: em0 flags=1c7<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP> ifmaxaddr 0 port 1 priority 128 path cost 2000000 proto rstp role root state forwarding