[OpenBSD] Forcing CARP failover

To force a CARP failover from a master firewall/router to its slave, you can manually change the value of the demotion counter like this:

fw1:~# ifconfig -g carp carpdemote 50

This command will increase the advskew value of all CARP interface on the host by the demotion counter value. The interface with the lowest advskew value will be promoted ‘MASTER’. I use a base advskew value of 80 on the master host and 120 on the slave. The failover should be transparent to end users.

You can check the current interfaces states and their advskew values like this:

fw2:~# ifconfig carp | grep adv
        carp: MASTER carpdev em1 vhid 150 advbase 8 advskew 80
        carp: MASTER carpdev em1 vhid 151 advbase 8 advskew 80
        [...]

To switch back simply decrease the demotion counter in order to have a lower value on the master again:

fw1:~# ifconfig -g carp -carpdemote 50