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
+2 -3
View File
@@ -25,6 +25,7 @@ with lib;
# WIREGUARD # WIREGUARD
vars.wg_adress = ""; vars.wg_adress = "";
vars.wg_range = "";
vars.wg_privateKey = ""; vars.wg_privateKey = "";
vars.wg_publicKey = ""; vars.wg_publicKey = "";
vars.wg_presharedKey = ""; vars.wg_presharedKey = "";
@@ -41,8 +42,6 @@ with lib;
# NFS # NFS
vars.nfs_server = ""; vars.nfs_server = "";
vars.nfs_volume = ""; vars.nfs_volume = "";
vars.nfs_mount = ""; vars.nfs_mount = "";
} }
+4 -1
View File
@@ -7,6 +7,9 @@ with lib;
wg_adress = mkOption { wg_adress = mkOption {
type = types.str; type = types.str;
}; };
wg_range = mkOption {
type = types.str;
};
wg_privateKey = mkOption { wg_privateKey = mkOption {
type = types.str; type = types.str;
}; };
@@ -75,4 +78,4 @@ with lib;
type = types.str; type = types.str;
}; };
}; };
} }
+3 -3
View File
@@ -11,16 +11,16 @@
autostart = true; autostart = true;
postUp = '' postUp = ''
${pkgs.procps}/bin/sysctl -w net.ipv4.conf.wg0.rp_filter=2 ${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 = '' 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; privateKey = config.vars.wg_privateKey;
peers = [{ peers = [{
publicKey = config.vars.wg_publicKey; publicKey = config.vars.wg_publicKey;
presharedKey = config.vars.wg_presharedKey; presharedKey = config.vars.wg_presharedKey;
allowedIPs = [ "10.6.0.0/24" ]; allowedIPs = [ config.vars.wg_range ];
endpoint = config.vars.wg_endpoint; endpoint = config.vars.wg_endpoint;
persistentKeepalive = 25; persistentKeepalive = 25;
}]; }];