WG range added

This commit is contained in:
2026-01-06 14:31:34 +01:00
parent 2bbd83627c
commit 1bca75bc09
3 changed files with 9 additions and 7 deletions
+1 -2
View File
@@ -25,6 +25,7 @@ with lib;
# WIREGUARD
vars.wg_adress = "";
vars.wg_range = "";
vars.wg_privateKey = "";
vars.wg_publicKey = "";
vars.wg_presharedKey = "";
@@ -43,6 +44,4 @@ with lib;
vars.nfs_volume = "";
vars.nfs_mount = "";
}
+3
View File
@@ -7,6 +7,9 @@ with lib;
wg_adress = mkOption {
type = types.str;
};
wg_range = mkOption {
type = types.str;
};
wg_privateKey = mkOption {
type = types.str;
};
+3 -3
View File
@@ -11,16 +11,16 @@
autostart = true;
postUp = ''
${pkgs.procps}/bin/sysctl -w net.ipv4.conf.wg0.rp_filter=2
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -o wg0 -d 10.6.0.1 -j SNAT --to-source ${config.vars.local_ip}
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -o wg0 -d ${config.vars.wg_range} -j SNAT --to-source ${config.vars.local_ip}
'';
postDown = ''
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -o wg0 -d 10.6.0.1 -j SNAT --to-source ${config.vars.local_ip}
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -o wg0 -d ${config.vars.wg_range} -j SNAT --to-source ${config.vars.local_ip}
'';
privateKey = config.vars.wg_privateKey;
peers = [{
publicKey = config.vars.wg_publicKey;
presharedKey = config.vars.wg_presharedKey;
allowedIPs = [ "10.6.0.0/24" ];
allowedIPs = [ config.vars.wg_range ];
endpoint = config.vars.wg_endpoint;
persistentKeepalive = 25;
}];