Add ipv6 subnet to wireguard

This commit is contained in:
Clayton Hickey 2025-11-19 14:48:05 -05:00
parent f5c131c3ea
commit e68c98b63c
2 changed files with 17 additions and 2 deletions

View file

@ -203,6 +203,7 @@
dig dig
ncdu ncdu
servo servo
tcpdump
]; ];
sessionVariables = { sessionVariables = {
EDITOR = "${inputs.cnvim.packages.x86_64-linux.default}/bin/nvim"; EDITOR = "${inputs.cnvim.packages.x86_64-linux.default}/bin/nvim";

View file

@ -22,6 +22,9 @@ in
type = lib.types.str; type = lib.types.str;
default = "${cfg.baseIP}.${builtins.toString cfg.clientPubOptionsMap.${host}.clientNumber}"; default = "${cfg.baseIP}.${builtins.toString cfg.clientPubOptionsMap.${host}.clientNumber}";
}; };
ipv6 = lib.mkOption {
default = "${cfg.baseIPv6}${builtins.toString cfg.clientPubOptionsMap.${host}.clientNumber}";
};
port = lib.mkOption { port = lib.mkOption {
type = lib.types.port; type = lib.types.port;
default = 51820; default = 51820;
@ -39,10 +42,18 @@ in
type = lib.types.str; type = lib.types.str;
default = "10.100.0"; default = "10.100.0";
}; };
baseIPv6 = lib.mkOption {
type = lib.types.str;
default = "fc10::";
};
clientInternalIP = lib.mkOption { clientInternalIP = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = cfg.clientPubOptionsMap.${config.cos.hostName}.ip; default = cfg.clientPubOptionsMap.${config.cos.hostName}.ip;
}; };
clientInternalIPv6 = lib.mkOption {
type = lib.types.str;
default = cfg.clientPubOptionsMap.${config.cos.hostName}.ipv6;
};
clientInternalPort = lib.mkOption { clientInternalPort = lib.mkOption {
type = lib.types.port; type = lib.types.port;
default = cfg.clientPubOptionsMap.${config.cos.hostName}.port; default = cfg.clientPubOptionsMap.${config.cos.hostName}.port;
@ -74,7 +85,7 @@ in
enable = true; enable = true;
interfaces = { interfaces = {
${cfg.interface} = { ${cfg.interface} = {
ips = [ "${cfg.clientInternalIP}/24" ]; ips = [ "${cfg.clientInternalIP}/32" "${cfg.clientInternalIPv6}/128" ];
listenPort = cfg.clientInternalPort; listenPort = cfg.clientInternalPort;
privateKeyFile = cfg.privateKeyFile; privateKeyFile = cfg.privateKeyFile;
@ -82,7 +93,10 @@ in
peers = [ peers = [
{ {
publicKey = cfg.clientPubOptionsMap.loadedskypotato.publicKey; publicKey = cfg.clientPubOptionsMap.loadedskypotato.publicKey;
allowedIPs = [ "${cfg.baseIP}.0/24" ]; allowedIPs = [
"${cfg.baseIP}.0/24"
"${cfg.baseIPv6}/64"
];
endpoint = "${config.cos.knownPublicIPs.loadedskypotato}:${builtins.toString cfg.clientPubOptionsMap.loadedskypotato.port}"; endpoint = "${config.cos.knownPublicIPs.loadedskypotato}:${builtins.toString cfg.clientPubOptionsMap.loadedskypotato.port}";
persistentKeepalive = 25; persistentKeepalive = 25;
} }