From 0f6eb8c599ed07327694dd54fca0553bc0a7ea9a Mon Sep 17 00:00:00 2001 From: lilly <li@lly.sh> Date: Fri, 7 Mar 2025 21:00:30 +0100 Subject: [PATCH] sketchy-router: give interfaces proper names --- systems/auth-dns.noc.eh22.intern.nix | 13 +++++ systems/sketchy-router.noc.eh22.intern.nix | 55 +++++++++++++--------- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/systems/auth-dns.noc.eh22.intern.nix b/systems/auth-dns.noc.eh22.intern.nix index 153c5b2..e730cbd 100644 --- a/systems/auth-dns.noc.eh22.intern.nix +++ b/systems/auth-dns.noc.eh22.intern.nix @@ -34,6 +34,19 @@ in { imports = [ ]; + # configure static IP address + networking.useDHCP = false; + systemd.network = { + enable = true; + networks = { + "10-mgmtNet" = { + matchConfig.MACAddress = "bc:24:11:c1:8a:a4"; + address = [ "10.20.25.3/24" ]; + gateway = [ "10.20.25.2" ]; + }; + }; + }; + # enable knot authorative dns server # ref: https://search.nüschtos.de/?query=services.knot # https://www.knot-dns.cz/docs/3.4/html/configuration.html diff --git a/systems/sketchy-router.noc.eh22.intern.nix b/systems/sketchy-router.noc.eh22.intern.nix index feeba88..caf27b5 100644 --- a/systems/sketchy-router.noc.eh22.intern.nix +++ b/systems/sketchy-router.noc.eh22.intern.nix @@ -2,6 +2,17 @@ pkgs, ... }: +let + renameLink = macAddr: newName: { + matchConfig = { + MACAddress = macAddr; + Type = "ether"; + }; + linkConfig = { + Name = newName; + }; + }; +in { imports = [ ]; @@ -14,14 +25,18 @@ networking.nftables.enable = true; systemd.network = { enable = true; + links = { + "10-ethUpstream" = renameLink "BC:24:11:D2:69:8D" "ethUpstream"; + "10-ethMgmt" = renameLink "BC:24:11:A3:38:4E" "ethMgmt"; + }; networks = { "10-ethUpstream" = { - matchConfig.MACAddress = "BC:24:11:D2:69:8D"; + matchConfig.Name = "ethUpstream"; address = [ "10.31.245.2/24" ]; gateway = [ "10.31.245.1" ]; }; "10-ethMgmt" = { - matchConfig.MACAddress = "BC:24:11:A3:38:4E"; + matchConfig.Name = "ethMgmt"; address = [ "10.20.25.2/24" ]; }; }; @@ -29,7 +44,7 @@ networking.nat = { enable = true; - externalInterface = "ens18"; + externalInterface = "ethUpstream"; internalIPs = [ "10.20.25.0/24" ]; }; @@ -38,7 +53,7 @@ settings = { interfaces-config = { interfaces = [ - "ens19" + "ethMgmt" ]; }; lease-database = { @@ -50,31 +65,29 @@ renew-timer = 1000; valid-lifetime = 4000; authoritative = true; - option-data = [ - { - name = "domain-name-servers"; - data = "9.9.9.9"; - } - { - name = "routers"; - data = "10.20.25.2"; - } - ]; shared-networks = [ { name = "mgmtNet"; - interface = "ens19"; + interface = "ethMgmt"; + option-data = [ + { + name = "domain-name-servers"; + data = "10.20.25.5"; + } + { + name = "domain-search"; + data = "noc.eh22.intern."; + } + { + name = "routers"; + data = "10.20.25.2"; + } + ]; subnet4 = [ { id = 300; subnet = "10.20.25.0/24"; pools = [ { pool = "10.20.25.100 - 10.20.25.254"; } ]; - reservations = [ - { - hw-address = "bc:24:11:c1:8a:a4"; - ip-address = "10.20.25.3"; - } - ]; } ]; }