dot_testing/boxes/netbox/wireguard.nix

41 lines
1004 B
Nix
Raw Permalink Normal View History

2024-10-27 22:59:13 -05:00
{ lib, config, pkgs, ... }:
{
networking = {
nat = {
enable = true;
externalInterface = "eth0";
internalInterfaces = [ "wg0" ];
};
2024-11-09 21:35:11 -06:00
firewall.allowedUDPPorts = [ 50000 ];
2024-10-27 22:59:13 -05:00
wireguard.interfaces = {
wg0 = {
ips = [ "10.100.0.1/24" ];
2024-11-09 21:35:11 -06:00
listenPort = 50000;
2024-10-27 22:59:13 -05:00
postSetup = ''
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
'';
postShutdown = ''
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
'';
privateKeyFile = "/home/ryan/wg-keys/private";
peers = [
{ # copernicus
publicKey = "JlH1X4KRT+B8Uau+qTLtBqyapkbGClIj1db7znU77kc=";
allowedIPs = [ "10.100.0.2/32" ];
}
2024-10-28 23:01:11 -05:00
{ # aristotle
publicKey = "Sw2yyMhyS8GOCWm1VuGn3Y7cfx606dXOGK5mux8ckQU=";
allowedIPs = [ "10.100.0.3/32" ];
}
2024-10-27 22:59:13 -05:00
];
};
};
};
}