This commit is contained in:
2025-07-20 15:05:24 +02:00
parent d3f67a35b1
commit f227c5af1c

View File

@@ -48,11 +48,11 @@ in {
RemainAfterExit = true;
ExecStart = with pkgs;
writers.writeBash "wg-up" ''
set -e
set -eux
${iproute2}/bin/ip link add wg0 type wireguard
${iproute2}/bin/ip link set wg0 netns ${cfg.namespace}
${iproute2}/bin/ip -n ${cfg.namespace} address add ${cfg.privateIP} dev wg0
${iproute2}/bin/ip netns exec ${cfg.namespace}
${iproute2}/bin/ip netns exec ${cfg.namespace} \
${wireguard-tools}/bin/wg setconf wg0 ${cfg.configFile}
${iproute2}/bin/ip -n ${cfg.namespace} link set wg0 up
${iproute2}/bin/ip -n ${cfg.namespace} link set lo up
@@ -60,7 +60,7 @@ in {
'';
ExecStop = with pkgs;
writers.writeBash "wg-down" ''
set -e
set -eux
${iproute2}/bin/ip -n ${cfg.namespace} route del default dev wg0
${iproute2}/bin/ip -n ${cfg.namespace} link del wg0
'';