On an Ubuntu 20.04 server, netplan is used to configure the network. It can configure ordinary static IP addresses but I need additional IPv6 addresses with preferred_lft=0. Netplan can't do that (there's an open bug for that). So I found out that it actually goes like this:

  • Netplan reads its own limited config and transforms it into a config for the more powerful systemd-network.
  • systemd-network probably passes on its data to things like the ip command when a network device appears.
  • The network device then applies the actual configuration. Down here everything is possible.

If netplan can't help me, I tried to move on to systemd. Since I don't want to remove the apparently widely used and highly praised netplan entirely, I just need to add my additional addresses besides the basic netplan config.

I tried to create the file /etc/systemd/network/web-ipv6.conf with this content:

Name=ens33 (this is the name from the existing netplan file)


The address fd9e:21a7:a92c:2323::1 is configured statically via netplan. In this demo it's a local address, in reality it's my server's main IPv6 address. Additional addresses have a different interface value, like this ...::2.

I guess I have to apply my config with systemctl restart systemd-networkd but I'm not sure. The log says things I'd consider a success. But the new IPv6 address ...::2 doesn't show up in ip addr.

In the man page for systemd.network I've read that only a single file for a [Match] will be used. I clearly have two files now: one from netplan (/run/systemd/network/10-netplan-ens33.network) and my other one. So this doesn't seem to work. But I don't want to edit netplan's file as it will surely be overwritten sometime.

How should I continue with this? I'd like to have a separate and persistent file that only adds my additional addresses. I'm going to manage that file in a custom script.

Should I go back to ifupdown or what it was in the old days? In a previous server setup I use a file named /etc/network/if-up.d/dynamic6 that contains all the ip addr add ... dev ... preferred_lft 0 commands. From what I've seen this is today considered deprecated.

  • Is your NIC actually named ens33? If not, then it won't match. As for netplan, I prefer to dump it and configure networking directly. – Michael Hampton Jun 30 at 21:04
  • Yes, the name is correct. ip link shows that. (That dev system is a VMware guest machine if that's interesting.) – ygoe Jul 1 at 7:03

Seems the old ifupdown functionality has been recreated for systemd-networkd. The package networkd-dispatcher, pre-installed on Ubuntu Server 20.04, lets me add a script to /etc/networkd-dispatcher/routable.d/ that is executed when a device comes up. In that script I can run ip addr add commands as I need. It is called on netplan apply, systemctl restart systemd-networkd and on system boot. In all cases, my additional IPv6 addresses were added as "deprecated" when they'd otherwise be missing.

Here's an article that explains it, with a short sample script: https://andreas.scherbaum.la/blog/archives/963-if-up-and-if-down-scripts-with-systemd.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.