os/hosts/frikandel/wireguard.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
1.8 KiB
Nix
Raw Normal View History

2023-10-19 18:55:56 +00:00
{
flake,
config,
pkgs,
...
}: {
2023-10-24 15:56:14 +00:00
age.secrets.wg-private-key-server.file = "${flake.self}/secrets/wg-private-frikandel-server.age";
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = 1;
2023-10-26 13:10:54 +00:00
"net.ipv6.conf.wg0.forwarding" = 1;
"net.ipv6.conf.wg0.accept_ra" = 1;
"net.ipv6.conf.wg0.accept_ra_pinfo" = 1;
2023-10-24 15:56:14 +00:00
};
2023-10-19 18:55:56 +00:00
networking.nat = {
enable = true;
enableIPv6 = true;
2023-10-28 21:16:15 +00:00
internalInterfaces = [ "wg0" ];
2023-10-19 18:55:56 +00:00
};
2023-10-24 15:56:14 +00:00
networking.firewall.allowedUDPPorts = [ 51899 ];
networking.firewall.extraForwardRules = [
"iifname wg0 accept"
"iifname enp1s0 reject"
];
2023-10-19 18:55:56 +00:00
# Enable WireGuard
networking.wg-quick.interfaces = {
2023-10-24 15:56:14 +00:00
wg0 = {
listenPort = 51899;
address = [
"10.0.1.7/32"
"fd00:b12f:acab:1312:acab:7::/32"
];
2023-10-19 18:55:56 +00:00
privateKeyFile = "/run/agenix/wg-private-key-server";
peers = [
2023-10-24 15:56:14 +00:00
{ # pie
publicKey = "hPTXEqQ2GYEywdPNdZBacwB9KKcoFZ/heClxnqmizyw=";
allowedIPs = [
"10.0.1.2/32"
"fd00:b12f:acab:1312:acab:2::/32"
];
2023-10-24 15:56:14 +00:00
persistentKeepalive = 25;
}
{ # droppie
2023-10-19 18:55:56 +00:00
publicKey = "qsnBMoj9Z16D8PJ5ummRtIfT5AiMpoF3SoOCo4sbyiw=";
allowedIPs = [
"10.0.1.3/32"
"fd00:b12f:acab:1312:acab:3::/32"
];
2023-10-19 18:55:56 +00:00
persistentKeepalive = 25;
}
2023-10-24 15:56:14 +00:00
{ # chocolatebar
2023-10-19 18:55:56 +00:00
publicKey = "nk8EtGE/QsnSEm1lhLS3/w83nOBD2OGYhODIf92G91A=";
allowedIPs = [
"10.0.1.5/32"
"fd00:b12f:acab:1312:acab:5::/32"
];
2023-10-19 18:55:56 +00:00
persistentKeepalive = 25;
}
2023-10-24 15:56:14 +00:00
{ # biolimo
2023-10-19 18:55:56 +00:00
publicKey = "4ymN7wwBuhF+h+5fFN0TqXmVyOe1AsWiTqRL0jJ3CDc=";
allowedIPs = [
"10.0.1.6/32"
"fd00:b12f:acab:1312:acab:6::/32"
];
2023-10-19 18:55:56 +00:00
persistentKeepalive = 25;
}
];
};
};
}