2024-01-25 11:31:05 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.networking.wireguard.interfaces."wg0";
|
|
|
|
in {
|
|
|
|
networking = {
|
|
|
|
nat = {
|
|
|
|
enable = true;
|
|
|
|
externalInterface = "enp3s0";
|
|
|
|
internalInterfaces = [ "wg0" ];
|
|
|
|
};
|
|
|
|
firewall.allowedUDPPorts = [ cfg.listenPort ];
|
|
|
|
|
|
|
|
wireguard.interfaces."wg0" = {
|
|
|
|
ips = [ "10.100.0.1/24" ];
|
|
|
|
listenPort = 51820;
|
|
|
|
privateKeyFile = "/etc/wireguard/defiant.private";
|
|
|
|
|
2024-01-25 13:25:05 +01:00
|
|
|
postSetup = ''
|
|
|
|
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -d 192.168.10.0/24 -o eth0 -j MASQUERADE
|
|
|
|
'';
|
|
|
|
postShutdown = ''
|
|
|
|
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -d 192.168.10.0/24 -o eth0 -j MASQUERADE
|
|
|
|
'';
|
|
|
|
|
2024-01-25 11:31:05 +01:00
|
|
|
peers = [
|
|
|
|
{ # Burnham
|
|
|
|
publicKey = "JcfyrMoZmnbibVLaIKuGSARAX2alFv4kwLbJaLBNbzo=";
|
2024-01-25 13:25:05 +01:00
|
|
|
persistentKeepalive = 60;
|
2024-01-25 11:31:05 +01:00
|
|
|
allowedIPs = [
|
|
|
|
"10.100.0.2/32"
|
2024-01-25 13:25:05 +01:00
|
|
|
"192.168.11.0/24"
|
2024-01-25 11:31:05 +01:00
|
|
|
];
|
2024-01-28 00:03:58 +01:00
|
|
|
endpoint = "site2.feal.no:51902";
|
2024-01-25 11:31:05 +01:00
|
|
|
}
|
|
|
|
{ # Sulu
|
|
|
|
publicKey = "j6YVekgGS4nhL5zUiOTeK2BVQkYGlTQaiUpwcqQyfRk=";
|
|
|
|
allowedIPs = [
|
|
|
|
"10.100.0.3/32"
|
|
|
|
];
|
|
|
|
}
|
2024-01-28 00:03:58 +01:00
|
|
|
{ # Worf
|
|
|
|
publicKey = "kW8SyzCh2tw8GzZV6bPn+IQVNUoUhseNfEm3rHnR1So=";
|
|
|
|
allowedIPs = [
|
|
|
|
"10.100.0.4/32"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
{ # Phone
|
|
|
|
publicKey = "axFXtcTYtW6m1FT9Czn9DRvG+b05D7j+0yRMjn/FJEk=";
|
|
|
|
allowedIPs = [
|
|
|
|
"10.100.0.5/32"
|
|
|
|
];
|
|
|
|
}
|
2024-02-08 17:56:51 +01:00
|
|
|
{ # Riker
|
|
|
|
publicKey = "r715vpgH1H0zvN+Z5wcNKcOo5e6UM3fBfh9BZwTBjmA=";
|
|
|
|
allowedIPs = [
|
|
|
|
"10.100.0.6/32"
|
|
|
|
];
|
|
|
|
}
|
2024-01-25 11:31:05 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|