CARP and DHCP on FreeBSD

Set up CARP on an interface that is set by DHCP on FreeBSD leaves the carp interface locked in INIT state after reboot:

hostname="server.exemple.com"
ifconfig_bce0="DHCP"

# CARP
cloned_interfaces="carp0"
ifconfig_carp0="vhid 1 pass i-am-carp 10.10.10.2 netmask 255.255.255.0"

results in:

# ifconfig carp0
carp0: flags=8<LOOPBACK> metric 0 mtu 1500
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        carp: INIT vhid 66 advbase 1 advskew 0

No IP on carp0, the interface isn’t working.

Solution: add synchronous_dhclient="YES":

synchronous_dhclient="YES"
hostname="server.exemple.com"
ifconfig_bce0="DHCP"

# CARP
cloned_interfaces="carp0"
ifconfig_carp0="vhid 1 pass i-am-carp 10.10.10.2 netmask 255.255.255.0"

Alternatively:

hostname="server.exemple.com"
ifconfig_bce0="SYNCDHCP"

# CARP
cloned_interfaces="carp0"
ifconfig_carp0="vhid 1 pass i-am-carp 10.10.10.2 netmask 255.255.255.0"

RTFM: “By default, DHCP configuration on FreeBSD runs in the background, or asynchronously. Other startup scripts continue to run while DHCP completes, speeding up system startup.”