nixos-config/nixos/machines/cream/wireguard.nix

27 lines
909 B
Nix
Raw Normal View History

2024-06-05 09:16:01 +02:00
{ config, factsGenerator, ... }:
2023-02-13 18:40:56 +01:00
{
networking.firewall.allowedUDPPorts = [ 51820 ];
clanCore.facts.services.wireguard = factsGenerator.wireguard { name = "wg0"; };
2023-02-13 18:40:56 +01:00
# Enable WireGuard
networking.wg-quick.interfaces = {
# Hub and Spoke Setup
# https://www.procustodibus.com/blog/2020/11/wireguard-hub-and-spoke-config/
wg0 = {
address = [ "10.100.0.6/32" ];
listenPort = 51820; # to match firewall allowedUDPPorts (without this wg uses random port numbers)
privateKeyFile = config.clanCore.facts.services.wireguard.secret."wireguard.wg0.key".path;
2023-02-13 18:40:56 +01:00
mtu = 1280;
peers = [
{
2024-06-05 12:51:38 +02:00
publicKey = (builtins.readFile "${config.clanCore.clanDir}/machines/orbi/facts/wireguard.wg0.pub");
2023-02-13 18:40:56 +01:00
allowedIPs = [ "10.100.0.1/24" ];
#endpoint = "ingolf-wagner.de:51820";
endpoint = "95.216.66.212:51820";
2023-02-13 18:40:56 +01:00
}
];
};
};
}