Lampros - Weird Bricks

CARP on FreeBSD 10

21 March, 2015 | CARP

Some quick notes on setting up CARP on FreeBSD.

Most of this is based on the FreeBSD Handbook page

1. Add the carp kernel module - edit the file /boot/loader.conf and add the line

carp_load="YES"

^ Make sure that this is done on all hosts To load the module without rebooting:

kldload carp

2. Then on the host you want to act as the master edit the /etc/rc.conf and add:

hostname="freebsd10-master"
ifconfig_em0="inet 192.168.2.21 netmask 255.255.255.0"
ifconfig_em0_alias0="inet 192.168.2.50/32 vhid 100 advskew 100 pass lampros"
defaultrouter="192.168.2.1"

In the above the 192.168.2.50 is going to be the "floating IP" address.

3. On the host you want to act as a backup:

hostname="freebsd10-failover"
ifconfig_em0="inet 192.168.2.22 netmask 255.255.255.0"
ifconfig_em0_alias0="inet alias 192.168.2.50/32 vhid 100 advskew 200 pass lampros"
defaultrouter="192.168.2.1"

As you can see the alias is identical with the exception of the advskew - to quote the manual on what advskew is:

The advskew parameter stands for ``advertisement skew''.  It is measured in 1/256 of seconds.  It is added to the base advertisement interval	to make one host advertise a bit slower that the other does.

4. Reboot both hosts - now from a third host ping the floating IP - in this example I'm pinging from Windows - after a few seconds I rebooted the master:

C:Windowssystem32>ping 192.168.2.50 -t

Pinging 192.168.2.50 with 32 bytes of data:
Reply from 192.168.2.50: bytes=32 time<1ms TTL=64
Reply from 192.168.2.50: bytes=32 time<1ms TTL=64
Request timed out.
Reply from 192.168.2.50: bytes=32 time<1ms TTL=64
Reply from 192.168.2.50: bytes=32 time<1ms TTL=64
Reply from 192.168.2.50: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.2.50:
    Packets: Sent = 28, Received = 27, Lost = 1 (3% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

As you can see only one request timed out while the Virtual IP got moved to the backup host.

Note: If you are using VirtualBox make sure you've set both virtual machines Promiscuous Mode set to 'Allow All'.

To do this, go to the Settings of your virtual machine and click on 'Network'. The option for Promiscuous Mode is there.