Comment 12 for bug 1810583

Revision history for this message
Karl Stenerud (kstenerud) wrote :

There is a fix upstream for this issue in keepalived 2.0. I'm looking into what would be required to backport the fix. In the meantime, there is a workaround that I hope will be sufficient for your needs, as discovered by https://chr4.org/blog/2019/01/21/make-keepalived-play-nicely-with-netplan-slash-systemd-network/

You'll need to create a dummy interface, and then assign the virtual IP to that. Here's an example using a VM, which will generate a virtual ip of x.y.z.3. You can set your own last quad by changing the last part of the sed command '\1.3/g' to .4 or .215 or whatever:

multipass launch daily:bionic --name tester && multipass exec tester -- sudo su

Inside the VM:

apt update && apt dist-upgrade -y && apt install -y keepalived &&
echo "vrrp_instance VI_1 {
    virtual_router_id 33
    state MASTER
    interface ens3

    virtual_ipaddress {
        $(ip addr | grep 'inet ' | grep global | head -1 | sed 's/.*inet \([0-9]*\.[0-9]*\.[0-9]*\)\..*/\1.3/g') dev keepalived0
    }
}" >/etc/keepalived/keepalived.conf &&
echo "[NetDev]
Name=keepalived0
Kind=dummy" >/lib/systemd/network/90-keepalived.netdev &&
service systemd-networkd restart &&
service keepalived start

# There will be a new IP address x.y.z.3/32 added to keepalived0
ip addr

# Restart networkd. The IP address doesn't get destroyed like it did in the bug report
systemctl restart systemd-networkd
ip addr

# Restart keepalived. The IP address gets rebuild the same as before
systemctl restart keepalived
ip addr