Working with systemd-networkd
Changing network settings in systemd-networkd
I mentioned previously that I've been migrating LXC under Proxmox to Incus (formerly LXD) and this has been going well. Of course, there are certain minor config issues to work out here and there, particularly with unfamiliar tech.
My Incus containers are by default configured to set their IPs by DHCP, and since they are bound to an unmanaged bridge, they get an IP from my router. Most of my services need to be at a static IP address, and I'm fine with setting DHCP reservations for most of these.
However, one of my migrated containers is Technitium. In times of trouble, like a failed router or some other issue that might make DHCP unavailable, it would be better to have DNS servers be configured to have actual static IPs and not simply DHCP reservations. I couldn't actually figure out how to assign an Incus container a static IP from the orchestration side, so I decided to configure the IP within the container itself, which led me to realize that a default Debian 12 non-cloudinit Incus container uses systemd-networkd.
systemd-networkd
Somehow, I have never manually configured a network interface using systemd-networkd. In the end, it's not that tricky:
In /etc/systemd/network/eth0.network, make the following changes, similar to the old /etc/network/interfaces:
[Match]
Name=eth0
[Network]
Description=Local network
Address=<classC>/24
Gateway=<gatewayip>
DNS=<dns 1> <dns 2>
Domains=<search domain>
LinkLocalAddressing=no
NTP=time.nist.gov
#[DHCPv4]
#UseDomains=true
#[DHCP]
#ClientIdentifier=mac
Then simply restart the service:
systemctl restart systemd-networkd.service