From 22974fe7067012f367fbf0accb7c0df4dff8d28e Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sun, 28 Jul 2024 20:31:02 +0200 Subject: [PATCH] Values: Make generic network configs for openstack guests --- hosts/ildkule/configuration.nix | 28 ++++++---------------------- values.nix | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/hosts/ildkule/configuration.nix b/hosts/ildkule/configuration.nix index 1ef0c15..12ceaa2 100644 --- a/hosts/ildkule/configuration.nix +++ b/hosts/ildkule/configuration.nix @@ -21,35 +21,19 @@ networking.hostName = "ildkule"; # Define your hostname. - # Main connection for incoming and outgoing connections to the world, using the global ("floating") IP - systemd.network.networks."30-ntnu-global" = values.defaultNetworkConfig // { + # Main connection, using the global/floatig IP, for communications with the world + systemd.network.networks."30-ntnu-global" = values.openstackGlobalNetworkConfig // { matchConfig.Name = "ens4"; - DHCP = "yes"; - gateway = [ ]; + + # Add the global address in addition to the local address learned from DHCP addresses = [ - { - # Add the global address in addition to the local address learned from DHCP - addressConfig.Address = "129.241.153.213/32"; - } + { addressConfig.Address = "${values.hosts.ildkule.ipv4_global}/32"; } ]; }; # Secondary connection only for use within the university network - systemd.network.networks."40-ntnu-internal" = values.defaultNetworkConfig // { + systemd.network.networks."40-ntnu-internal" = values.openstackLocalNetworkConfig // { matchConfig.Name = "ens3"; - DHCP = "yes"; - gateway = [ ]; - routes = [ - { - routeConfig.Destination = "10.0.0.0/8"; - } - ]; - linkConfig.RequiredForOnline = "no"; - dhcpV4Config = { - # Do not use this interface as a default / global route - # Note: This does not remove the link-local route 192.168.11.0/24, as it is added by the kernel itself - UseRoutes = "no"; - }; }; # List packages installed in system profile diff --git a/values.nix b/values.nix index 0c68b65..ba335a3 100644 --- a/values.nix +++ b/values.nix @@ -73,4 +73,27 @@ in rec { DHCP = "no"; }; + openstackGlobalNetworkConfig = { + networkConfig.IPv6AcceptRA = "no"; + 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"; + routes = [ + { + routeConfig.Destination = "10.0.0.0/8"; + } + ]; + linkConfig.RequiredForOnline = "no"; + dhcpV4Config = { + # Only use this network for link-local networking, no global/default routes + UseRoutes = "no"; + }; + }; }