nixfiles/hosts/dyon/wireguard.nix
2021-03-13 16:10:13 +01:00

35 lines
1.1 KiB
Nix

{ config, pkgs, ...}:
{
environment.systemPackages = with pkgs; [
wireguard
wireguard-tools
];
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1;
networking = {
firewall.allowedUDPPorts = [ 51820 ];
firewall.trustedInterfaces = [ "server"];
wireguard.enable = true;
wireguard.interfaces = {
server = {
ips = [ "fd33:ab07:ff00:2342::1/64"];
listenPort = 51820;
privateKeyFile = "/run/keys/wg-dyon_priv";
allowedIPsAsRoutes = false;
postSetup = ''
ip route add 2a01:4f8:c010:61dc:200::0/72 via fd33:ab07:ff00:2342:200::1 dev server
'';
peers = [{
publicKey = "PQW2/P7wozf8pmpWxCDofT7AwqkPjc5kq8qQigZoUjo=";
allowedIPs = [ "2a01:4f8:c010:61dc:200::0/72" "fd33:ab07:ff00:2342:200::1/72" ];
endpoint = "scotty-router:52820";
persistentKeepalive = 25;
}];
};
};
};
}