{ pkgs, ... }: { # Allow these hosts to directly communicate with their hostnames networking.extraHosts = '' 10.100.0.1 osaka-linode-01 10.100.0.3 backups-rpi4 10.100.0.2 headscale.sysctl.io ''; # 10.100.0.2 framework-server # 10.100.0.2 git.sysctl.io # 10.100.0.2 loki.sysctl.io # 10.100.0.2 telegraf.sysctl.io # ''; networking.firewall.allowedUDPPorts = [ 51820 ]; networking.firewall.interfaces.wireguard0.allowedTCPPorts = [ 22 ]; # Set up the secrets file: sops.secrets."wireguard_key" = { owner = "root"; sopsFile = ../../../secrets/hosts/osaka-linode-01.yaml; }; sops.secrets."preshared_key" = { owner = "root"; sopsFile = ../../../secrets/wireguard.yaml; }; # Wireguard Forwarder boot.kernel.sysctl = { "net.ipv4.ip_forward" = true; "net.ipv4.conf.all.forwarding" = 1; "net.ipv4.conf.default.forwarding" = 1; }; networking.wireguard = { enable = true; interfaces = { "wireguard0" = { ips = [ "10.100.0.1/24" ]; listenPort = 51820; privateKeyFile = "/run/secrets/wireguard_key"; postSetup = ''${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o enp0s4 -j MASQUERADE''; postShutdown = ''${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o enp0s4 -j MASQUERADE''; peers = [ { # framework-server publicKey = "trHvfNtQ7HKMiJjxEXo2Iubq5G6egjx7gHiBlDmJ5Ek="; presharedKeyFile = "/run/secrets/preshared_key"; persistentKeepalive = 5; allowedIPs = [ "10.100.0.2/32" ]; } { # backups-rpi4 publicKey = "cqocpMyY8Z0Jl0hoAdghn3dR3VhkkOYyeSwW6UKk9Fs="; presharedKeyFile = "/run/secrets/preshared_key"; persistentKeepalive = 5; allowedIPs = [ "10.100.0.3/32" ]; } ]; }; }; }; }