dot_testing/boxes/netbox/wireguard.nix

41 lines
984 B
Nix
Raw Normal View History

{ config, machines, pkgs, ... }:
2024-10-27 22:59:13 -05:00
{
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 = config.age.secrets.netbox-wg-priv.path;
2024-10-27 22:59:13 -05:00
peers = [
{ # copernicus
publicKey = machines.copernicus.wg-pubkey;
2024-10-27 22:59:13 -05:00
allowedIPs = [ "10.100.0.2/32" ];
}
2024-10-28 23:01:11 -05:00
{ # aristotle
publicKey = machines.aristotle.wg-pubkey;
2024-10-28 23:01:11 -05:00
allowedIPs = [ "10.100.0.3/32" ];
}
2024-10-27 22:59:13 -05:00
];
};
};
};
}