os/modules/wireguard/ehex.nix

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

54 lines
1.5 KiB
Nix
Raw Normal View History

2024-06-11 12:57:33 +00:00
{
lib,
config,
...
2024-08-18 22:22:59 +00:00
}: let
2024-06-11 12:57:33 +00:00
cfg = config.pub-solar.wireguard.ehex;
in {
options.pub-solar.wireguard.ehex = {
ownIPs = lib.mkOption {
2024-06-11 12:57:33 +00:00
description = "Internal ips in wireguard used for cluster control-plane communication.";
type = lib.types.listOf lib.types.str;
2024-06-11 12:57:33 +00:00
default = [];
};
privateKeyFile = lib.mkOption {
2024-06-11 12:57:33 +00:00
description = "Location of private key file";
type = lib.types.path;
2024-06-11 12:57:33 +00:00
};
};
2024-08-18 22:22:59 +00:00
config = lib.mkIf (lib.length cfg.ownIPs != 0) {
2024-06-11 12:57:33 +00:00
networking.firewall.allowedUDPPorts = [51822];
2024-08-18 22:22:59 +00:00
systemd.network.wait-online.ignoredInterfaces = ["wg-ehex"];
2024-06-11 12:57:33 +00:00
systemd.services.wireguard-wg-ehex = import ./service-override.nix lib;
2024-06-11 12:57:33 +00:00
networking.wireguard.interfaces = {
wg-ehex = {
listenPort = 51822;
2024-06-11 12:57:33 +00:00
mtu = 1300;
ips = cfg.ownIPs;
privateKeyFile = cfg.privateKeyFile;
postSetup = ''
2024-06-11 12:57:33 +00:00
printf "nameserver 10.0.66.10\nnameserver 10.0.66.12" | resolvconf -a wg-ehex -m 0 -x
'';
postShutdown = ''
resolvconf -d wg-ehex -f
'';
peers = [
{
endpoint = "vpn-gateway.ehex.de:4242";
publicKey = "Fsg4KEyDEvQEt/1cVWU9xa/k9x/3UhONDj61aXZ7tys=";
2024-08-18 22:22:59 +00:00
presharedKey = "tQy7B5R3wOgWwIKFDcEr4WZIqCrwG+9UgPRIQx/5xso=";
allowedIPs = ["10.42.0.0/22" "10.0.66.0/24"];
2024-06-11 12:57:33 +00:00
persistentKeepalive = 15;
dynamicEndpointRefreshSeconds = 30;
}
];
};
};
};
}