Fix keepalived error: bind unicast_src - 99 cannot assign requested address
TL;DR: The configured unicast_src IP isn't present on any network interface. In my case DHCPv6 was to blame.
I accidentally unplugged the power cable from my RaspberryPi 4 today. Due to this I learned a few things today.
- First that my home DSL router (a FritzBox) doesn't always honor the preferred IPv4/v6 addresses send in DHCP-Request
/etc/dhcpcd.confdid containstatic ip_address=... andstatic ip6_address=...
- The FritzBox can't set DHCP reservations for IPv6 addresses - only IPv4 - WHY!?
- I have to read the
keepalivederror message with my head turned on- I stumbled across the
cannot assign requested addressand thought of DHCP and was confused why the hell keepalived does DHCP things (the word requested mislead me) - In the following line the reason is written in plain text...
entering FAULT state (src address not configured)
- I stumbled across the
- Static IP-configuration for servers was, is and will always be the best
- A mixed static & dynamic IPv6 configuration isn't hard at all once you read a bit about SLAAC
- I went with DHCP for IPv4/IPv6 first as this is simply the Raspbian default and hey, it worked for some years..
- I made that into a separate blogpost: Configuring an mixed IPv6 setup - static ULA, dynamic GLA
Long story short, this was the keepalived error I got. The VRRP-Instance immediately went into FAULT state and stayed there.
root@raspi:~# systemctl status keepalived.service
[...]
Feb 05 13:14:22 raspi Keepalived_vrrp[1279]: Delaying startup for 5 seconds
Feb 05 13:14:22 raspi Keepalived[1278]: Startup complete
Feb 05 13:14:22 raspi systemd[1]: Started keepalived.service - Keepalive Daemon (LVS and VRRP).
Feb 05 13:14:22 raspi Keepalived_vrrp[1279]: bind unicast_src fd87:f53:25b4:0:231d:4cbb:bca7:10 failed 99 - Cannot assign requested address
Feb 05 13:14:22 raspi Keepalived_vrrp[1279]: (VI_2): entering FAULT state (src address not configured)
Feb 05 13:14:22 raspi Keepalived_vrrp[1279]: (VI_2) Entering FAULT STATE
Feb 05 13:14:22 raspi Keepalived_vrrp[1279]: VRRP_Group(ALL) Syncing instances to FAULT state
At first I skipped the following line:
Feb 05 13:14:22 raspi Keepalived_vrrp[1279]: (VI_2): entering FAULT state (src address not configured)
Hence I searched a bit and found an older GitHub issue where this problem was explained with VRRP trying to do stuff to fast, while the interface wasn't ready. The solution mentioned in keepalived issue #2237: Keepalived entering fault state on reboot was to set vrrp_startup_delay inside the global_defs section of /etc/keepalived/keepalived.conf. However this was already the present in my case.
Yeah, turns out the configured unicast_src IP wasn't present on any interface. As the FritzBox deemed it fit to assign a random one from the configured DHCP-Range. We can verify this quickly by grep'ing for the IPv6 address.
root@raspi:~ # ip -6 a | grep fd87:f53:25b4:0:231d:4cbb:bca7:10
root@raspi:~ #
The solution
In my case I finally switched to a mixed static and dynamic IPv6 setup. Configuring the local ULA address as a static one, but still receive and apply the router advertisement (RA) to get a global IPv6 so my RaspberryPi can still connect to the Internet.
Then it showed up on the interface.
root@raspi:~ # ip -6 a | grep fd87:f53:25b4:0:231d:4cbb:bca7:10
inet6 fd87:f53:25b4:0:231d:4cbb:bca7:10/64 scope global
root@raspi:~ #
Another viable solution would of course be to just reboot the RaspberryPi and hope your DHCP-Server now assigns the correct IP. However my FritzBox only allows to set an IPv4 reservation in the DHCP settings. IPv6 addresses can't be used for DHCP reservations at all. So this was no solution for me.
If you want to know how to configured a mixed static and dynamic IPv6 read here: Configuring an mixed IPv6 setup - static ULA, dynamic GLA
