From 2030d4de3970c6401a71322fc7964d6b7e5a3f05 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Wed, 31 Jul 2024 11:23:00 +0200 Subject: [PATCH] fix-openstack-networking (!47) Fix networking in Openstack. This rewrites the systemd-networkd config, fixing both dhcp and manual address/route configurations. Now, everything should behave predictably, routing NTNU-internal and NTNU-global addresses separately and properly across both ipv4 and ipv6. Reviewed-on: https://git.pvv.ntnu.no/Drift/pvv-nixos-config/pulls/47 --- hosts/ildkule/configuration.nix | 24 ++++++++++++++++++++---- values.nix | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/hosts/ildkule/configuration.nix b/hosts/ildkule/configuration.nix index 99e14bf..276af5a 100644 --- a/hosts/ildkule/configuration.nix +++ b/hosts/ildkule/configuration.nix @@ -20,10 +20,26 @@ zramSwap.enable = true; networking.hostName = "ildkule"; # Define your hostname. - systemd.network.networks."30-all" = values.defaultNetworkConfig // { - matchConfig.Name = "en*"; - DHCP = "yes"; - gateway = [ ]; + + # Main connection, using the global/floatig IP, for communications with the world + systemd.network.networks."30-ntnu-global" = values.openstackGlobalNetworkConfig // { + matchConfig.Name = "ens4"; + + # Add the global addresses in addition to the local address learned from DHCP + addresses = [ + { addressConfig.Address = "${values.hosts.ildkule.ipv4_global}/32"; } + { addressConfig.Address = "${values.hosts.ildkule.ipv6_global}/128"; } + ]; + }; + + # Secondary connection only for use within the university network + systemd.network.networks."40-ntnu-internal" = values.openstackLocalNetworkConfig // { + matchConfig.Name = "ens3"; + # Add the ntnu-internal addresses in addition to the local address learned from DHCP + addresses = [ + { addressConfig.Address = "${values.hosts.ildkule.ipv4}/32"; } + { addressConfig.Address = "${values.hosts.ildkule.ipv6}/128"; } + ]; }; # List packages installed in system profile diff --git a/values.nix b/values.nix index 0c68b65..2e11f4f 100644 --- a/values.nix +++ b/values.nix @@ -73,4 +73,25 @@ in rec { DHCP = "no"; }; + openstackGlobalNetworkConfig = { + networkConfig.IPv6AcceptRA = "yes"; + dns = [ "129.241.0.200" "129.241.0.201" ]; + domains = [ "pvv.ntnu.no" "pvv.org" ]; + DHCP = "yes"; + }; + + openstackLocalNetworkConfig = { + networkConfig.IPv6AcceptRA = "no"; + dns = [ "129.241.0.200" "129.241.0.201" ]; + domains = [ "pvv.ntnu.no" "pvv.org" ]; + DHCP = "yes"; + + # Only use this network for link-local networking, not global/default routes + dhcpV4Config.UseRoutes = "no"; + routes = [ + { routeConfig = { Destination = "10.0.0.0/8"; Gateway = "_dhcp4"; }; } + ]; + + linkConfig.RequiredForOnline = "no"; + }; }