2 gateways on one NIC - auto fallover

Ok basically I have 2 load balancer servers in front of a load of FreeBSD servers. All the FreeBSD servers connect to the net via nat so one of the lb servers is the active gateway. What I need to do is have it so when the first lb server goes down, the FreeBSD servers automatically start using the 2nd lb server as the nat gateway without intervention from me. I am assuming I can add a second gateway/router with a lower priority than the default. As I can on windows machines. Is this possible and if so how? thanks.
 
FreeBSD does not allow two routes to the same destination at the same time.
A routing protocol should be useful (bgpd, ospfd) if the gateways configuration do not use pfsync and doesn't allow transparent failover.
 
CARP
Heartbeat

Both available on FreeBSD AFAIK.

Heartbeat is more tailored to building redundant application servers, while CARP seems to be more tailored to building redundant firewalls. I'm sure either can serve both purposes though.
 
You should look into using Heartbeat on both gateways. Configure with a virtual ip resource that fails over between them. You would configure your servers to use the virtual ip for the gateway, which will bounce between both gateways. The beauty out of using heartbeat, is that you can also have it run other apps/tasks/scripts during the failover.
 
I ended up using keepalived, heartbeat has horrific documentation and looks over complicated.

It's odd that FreeBSD has no native dual gateway function though, seems a very basic omission.

thanks.
 
Unless I've not understood what you've outlined, this is easily doable using Common Address Redundancy Protocol (CARP), which is build into the kernel. CARP will do the heartbeat monitoring as well and fail over automatically when required.

Check out the Handbook section and also CARP(4).

You may also want to check PFSYNC(4) which provides automatic pf state syncing between gateways.
 
Back
Top