From 97d826ef89d9b29fe265135a618d22ccc64fbd3e Mon Sep 17 00:00:00 2001 From: clerie <git@clerie.de> Date: Thu, 13 Mar 2025 19:07:31 +0100 Subject: [PATCH] hosts/gatekeeper,hosts/mail-2,hosts/web-2: Migrate Hetzner VMs to systemd-networkd --- hosts/gatekeeper/configuration.nix | 11 ++++++++--- hosts/mail-2/configuration.nix | 10 ++++++++-- hosts/web-2/configuration.nix | 11 ++++++++--- profiles/hetzner-cloud/default.nix | 10 ++++++++-- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/hosts/gatekeeper/configuration.nix b/hosts/gatekeeper/configuration.nix index b097bd1..4c7eee9 100644 --- a/hosts/gatekeeper/configuration.nix +++ b/hosts/gatekeeper/configuration.nix @@ -13,9 +13,14 @@ boot.loader.grub.device = "/dev/sda"; networking.useDHCP = false; - # Network - networking.interfaces.ens3.ipv4.addresses = [ { address = "78.47.183.82"; prefixLength = 32; } ]; - networking.interfaces.ens3.ipv6.addresses = [ { address = "2a01:4f8:c0c:15f1::1"; prefixLength = 64; } ]; + systemd.network.enable = true; + + systemd.network.networks."10-wan" = { + address = [ + "2a01:4f8:c0c:15f1::1/64" + "78.47.183.82/32" + ]; + }; networking.nat = { enable = true; diff --git a/hosts/mail-2/configuration.nix b/hosts/mail-2/configuration.nix index e82f590..0086f74 100644 --- a/hosts/mail-2/configuration.nix +++ b/hosts/mail-2/configuration.nix @@ -14,8 +14,14 @@ boot.loader.grub.device = "/dev/sda"; networking.useDHCP = false; - networking.interfaces.ens3.ipv6.addresses = [ { address = "2a01:4f8:1c1c:9577::1"; prefixLength = 64; } ]; - networking.interfaces.ens3.ipv4.addresses = [ { address = "5.75.187.112"; prefixLength = 32; } ]; + systemd.network.enable = true; + + systemd.network.networks."10-wan" = { + address = [ + "2a01:4f8:1c1c:9577::1/64" + "5.75.187.112/32" + ]; + }; clerie.backup = { enable = true; diff --git a/hosts/web-2/configuration.nix b/hosts/web-2/configuration.nix index 609c385..93ea4f5 100644 --- a/hosts/web-2/configuration.nix +++ b/hosts/web-2/configuration.nix @@ -34,9 +34,14 @@ boot.loader.grub.device = "/dev/sda"; networking.useDHCP = false; - # Network - networking.interfaces.ens3.ipv4.addresses = [ { address = "88.99.187.135"; prefixLength = 32; } ]; - networking.interfaces.ens3.ipv6.addresses = [ { address = "2a01:4f8:c0c:c580::1"; prefixLength = 64; } ]; + systemd.network.enable = true; + + systemd.network.networks."10-wan" = { + address = [ + "2a01:4f8:c0c:c580::1/64" + "88.99.187.135/32" + ]; + }; services.nginx = { enable = true; diff --git a/profiles/hetzner-cloud/default.nix b/profiles/hetzner-cloud/default.nix index 32e1dcc..0de705b 100644 --- a/profiles/hetzner-cloud/default.nix +++ b/profiles/hetzner-cloud/default.nix @@ -12,8 +12,14 @@ with lib; services.qemuGuest.enable = true; - networking.defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; - networking.defaultGateway = { address = "172.31.1.1"; interface = "ens3"; }; + systemd.network.networks."10-wan" = { + matchConfig.Name = "ens3"; + routes = [ + { Gateway = "fe80::1"; } + { Gateway = "172.31.1.1"; GatewayOnLink = true; } + ]; + linkConfig.RequiredForOnline = "routable"; + }; networking.nameservers = [ # There are two different batches of DNS servers