From 3993b526a589e0d6f375111353ddd9723d5ab036 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Wed, 22 Jan 2025 00:40:43 -0700 Subject: [PATCH] Convert from cloud-init networking to static networking This is honestly pretty ugly. The issue is that I want two different IPv6 addresses on this server. I get one address for free as part of my hosting agreement. The other I have to pay $0.01 per month for. The address is routable, but it's not provided via cloud-init like the initial address. I therefore took the data from /var/lib/cloud/instance/network-config.json and translated it into this configuration manually. It's dangerous - I don't know when any of this information may change. However, it works, and both addresses are now bound to eth0. Notice that I set the network configuration name to "09-wan". This is because the previous configuration using cloud-init created a network configuration at /etc/systemd/network/10-cloud-init that has to be manually removed or superseded. --- sovr/etc/nixos/configuration.nix | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/sovr/etc/nixos/configuration.nix b/sovr/etc/nixos/configuration.nix index 4f15581..1f473c3 100644 --- a/sovr/etc/nixos/configuration.nix +++ b/sovr/etc/nixos/configuration.nix @@ -63,7 +63,7 @@ services.cloud-init = { enable = true; - network.enable = true; + network.enable = false; }; services.openssh = { enable = true; @@ -77,7 +77,29 @@ sessionSecret = "secret"; }; - systemd.network.enable = true; + systemd.network = { + enable = true; + networks."09-wan" = { + address = [ + "194.135.104.85/24" + "2605:e440::2:1d5/64" + "2605:e440::2:3e/64" + ]; + dns = [ + "8.8.8.8" + "8.8.4.4" + "2001:4860:4860::8888" + "2001:4860::8844" + ]; + linkConfig.RequiredForOnline = "routable"; + matchConfig.Name = "eth0"; + routes = [ + { Gateway = "194.135.104.1"; } + { Gateway = "2605:e440::1"; } + ]; + }; + }; + # Set your time zone. time.timeZone = "America/Phoenix";