Moritz Kraus
4 years
Emma Heinle
4 years
Andreas Vöst
5 years
Emma Heinle
5 years
Claus-Theodor Riegg
5 years
Claus-Theodor Riegg
5 years
Andreas Vöst
6 years
Claus-Theodor Riegg
10 years
Claus-Theodor Riegg
10 years
Marius Schuller
7 years
Marius Schuller
7 years

Prevent systemd from dropping IP-Addresses configured from other processes

Updated . Posted . Visible to the public.

Systemd's networkd will drop IP-Addresses configured by other processes like Keepalived's VRRP, when it is restarted. This may happen on updates.

To prevent this following settings are required in /run/systemd/network/10-netplan-eth0.network

v242 or earlier (even if you do not use DHCP client in networkd)

[DHCP]
CriticalConnection=yes

v243 or newer

[Network]
KeepConfiguration=yes

If there is netplan in place these files will be generated.

Add critical: yes to /etc/netplan/50-cloud-init.yaml

eth1:
  addresses:
    - 192.0.2.67/24
  gateway4: 192.0.2.1
  nameservers:
    addresses:
      - 198.51.100.42
      - 198.51.100.53
    search:
      - example.lcal
  critical: yes

run netplan generate

This will add the CriticalConnection to your networkd configuration.

Caveat for systemd 251–256

In systemd versions 251 through 256, KeepConfiguration=yes may still remove IP addresses configured by other processes, such as Keepalived VRRP addresses, during a networkd restart.

Netplan's critical: yes generates KeepConfiguration=true.

In these systemd versions, link_drop_foreign_addresses() only explicitly preserves foreign addresses for KeepConfiguration=dhcp or KeepConfiguration=static. This was reworked in systemd v257.

As a workaround for static addresses such as VRRP VIPs, add a networkd drop-in:

# /etc/systemd/network/10-netplan-eth0.network.d/keep-configuration.conf

[Network]
KeepConfiguration=static
Profile picture of Moritz Kraus
Moritz Kraus
Last edit
Fabian Spannagel
Keywords
ip, address, lost
License
Source code in this card is licensed under the MIT License.