NixOS-Config/modules/system/devices/networking/wireguard/server/default.nix
2024-10-20 13:58:14 -04:00

33 lines
801 B
Nix

{ config, ... }:
{
networking = {
nat = {
enable = true;
externalInterface = "${config.ips.netInt}";
internalInterfaces = [ "${config.ips.wgInt}" ];
};
firewall.allowedUDPPorts = [ 51820 ];
};
networking.wireguard = {
enable = true;
interfaces = {
"${config.ips.wgInt}" = {
ips = [ "${config.ips.wgSpan}.1/24" ];
listenPort = 51820;
privateKey = config.secrets.wgServerPriv;
peers = [
{ # Jimbo Pixel 9
publicKey = config.secrets.wgPixel9Pub;
allowedIPs = [ "${config.ips.wgSpan}.2/32" ];
}
{ # General Nix
publicKey = config.secrets.wgClientPub;
allowedIPs = [ "${config.ips.wgSpan}.16/28" ];
}
];
};
};
};
}