diff options
| author | Mathias Magnusson <mathias@magnusson.space> | 2025-10-19 16:32:35 +0200 |
|---|---|---|
| committer | Mathias Magnusson <mathias@magnusson.space> | 2025-10-19 16:32:35 +0200 |
| commit | 1544ace9cf9a08df4429848a9afe2dd2cd451151 (patch) | |
| tree | ec88817fdfd5f08c3793985f7536effe22815730 /router.nix | |
| parent | 6f18b00b3880e94528bc1ba112d7316af5d72fe1 (diff) | |
| download | oden-1544ace9cf9a08df4429848a9afe2dd2cd451151.tar.gz | |
Add dynamic dns
Diffstat (limited to 'router.nix')
| -rw-r--r-- | router.nix | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -1,5 +1,6 @@ -{ config, ... }: +{ config, pkgs, ... }: let + wanInterface = "enp8s0"; lanInterface = "enp5s0f0u2"; wifiInterface = "wlp9s0"; in @@ -11,7 +12,7 @@ in firewall.filterForward = true; nat = { enable = true; - externalInterface = "enp8s0"; + externalInterface = wanInterface; internalInterfaces = [ "br0" ]; # forwardPorts = [{ sourcePort = 1234; destination = "10.69.0.2:12345"; }]; }; @@ -23,6 +24,17 @@ in networkmanager = { enable = true; unmanaged = [ "interface-name:${lanInterface}" "interface-name:${wifiInterface}" ]; + dispatcherScripts = [ { + type = "basic"; + source = pkgs.writeScript "dynamic-dns-on-ipv4-change" '' + #!/bin/sh + + [ "$1" = "${wanInterface}" ] || exit + [ "$2" = dhcp4-change ] || exit + ${pkgs.curl}/bin/curl "$(cat "${config.age.secrets."dyndns-url.txt".path}")" + date >> /home/mathias/networkmanager-dispatcherScripts-run + ''; + } ]; }; }; services.hostapd = { @@ -42,7 +54,6 @@ in }; }; }; - age.secrets."wifi-password.txt".file = ./secrets/wifi-password.txt.age; services.dnsmasq = { enable = true; @@ -69,4 +80,7 @@ in networking.firewall.allowedUDPPorts = [ 53 67 ]; networking.firewall.allowedTCPPorts = [ 53 ]; oden.persist.directories = [ "/var/lib/dnsmasq" ]; + + age.secrets."wifi-password.txt".file = ./secrets/wifi-password.txt.age; + age.secrets."dyndns-url.txt".file = ./secrets/dyndns-url.txt.age; } |
