Tuesday, March 26, 2024

How to give your Scaleway Stardust VPS a custom* IPv6 address

(*by "custom" I mean any address you want within the /64 block that Scaleway gives you.)

So I got myself a €0.43/month Scaleway Stardust IPv6-only instance, and I wanted to attach it to a permanent IPv6 address.

Scaleway generously gives you 40 free flexible IPv6 addresses. Each of these is a /64 block! So you actually can add any of the IP in the /64 block and attach to your VM. And you can have multiple IPv6 addresses from multiple of those blocks attached to your VPS at the same time, so you can access your VPS from all those IPs simultaneously! (I tried this, it works - pretty cool!)

Anyway, so my Stardust instance is running Debian 12, and I initially thought that to add my own custom IPv6 address I just had to edit /etc/network/interfaces, because that is what the Debian manual says: https://wiki.debian.org/NetworkConfiguration

# systemctl status networking
# systemctl restart networking

However, when I run that command, I get this result:

# systemctl status networking
Unit networking.service could not be found.

So then I listed all of the running systemd services and looking at the list, it looked like my VPS is using systemd-networkd for configuration. 

Doing systemctl status systemd-networkd gave this kind of message:

if1: Configuring with /run/systemd/network/if1.network.

So I thought I just needed to edit that file. So I went ahead and edited it but upon reboot the changes were not persisted. 

It turns out the /run/systemd/network files are volatile files as explained in the Arch wiki:

The global configuration file in /etc/systemd/networkd.conf may be used to override some defaults only. The main configuration is performed per network device. Configuration files are located in /usr/lib/systemd/network/, the volatile runtime network directory /run/systemd/network/ and the local administration network directory /etc/systemd/network/. Files in /etc/systemd/network/ have the highest priority.

So then I created the file with the same name in /etc/systemd/network/ and now the IP address is restored on reboot.


No comments:

Post a Comment