NixOS-Config/nixos/server/wireguard.nix

37 lines
944 B
Nix
Raw Normal View History

2024-09-06 01:18:21 -04:00
{outputs, ...}: let
ips = import ../modules/ips.nix;
in {
2024-09-10 21:39:12 -04:00
# Enable NAT
networking = {
nat = {
enable = true;
externalInterface = "${ips.netInt}";
2024-09-12 01:31:59 -04:00
internalInterfaces = [ "${ips.wgInt}" ];
};
firewall.allowedUDPPorts = [ 51820 ];
};
2024-09-06 01:18:21 -04:00
networking.wireguard = {
enable = true;
interfaces = {
# Wireguard interface name can be arbitrary
wg0 = {
# Determines the IP address and subnet of the server's end of the tunnel interface.
2024-09-12 01:31:59 -04:00
ips = [ "${ips.wgSpan}.1/24" ];
2024-09-06 01:18:21 -04:00
listenPort = 51820;
privateKey = outputs.secrets.wireguardPriv;
peers = [
2024-09-08 10:30:01 -04:00
{ # Jimbo Pixel 9
publicKey = outputs.secrets.wirePixel9Pub;
2024-09-12 01:31:59 -04:00
allowedIPs = [ "${ips.wgSpan}.2/32" ];
2024-09-06 01:18:21 -04:00
}
2024-09-11 21:58:40 -04:00
{ # Oracle VM
publicKey = outputs.secrets.wireOraclePub;
2024-09-12 01:31:59 -04:00
allowedIPs = [ "${ips.wgSpan}.3/32" ];
2024-09-11 21:58:40 -04:00
}
2024-09-06 01:18:21 -04:00
];
};
};
};
}