vpn v17
This commit is contained in:
@@ -48,11 +48,11 @@ in {
|
|||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
ExecStart = with pkgs;
|
ExecStart = with pkgs;
|
||||||
writers.writeBash "wg-up" ''
|
writers.writeBash "wg-up" ''
|
||||||
set -e
|
set -eux
|
||||||
${iproute2}/bin/ip link add wg0 type wireguard
|
${iproute2}/bin/ip link add wg0 type wireguard
|
||||||
${iproute2}/bin/ip link set wg0 netns ${cfg.namespace}
|
${iproute2}/bin/ip link set wg0 netns ${cfg.namespace}
|
||||||
${iproute2}/bin/ip -n ${cfg.namespace} address add ${cfg.privateIP} dev wg0
|
${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}
|
${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 wg0 up
|
||||||
${iproute2}/bin/ip -n ${cfg.namespace} link set lo up
|
${iproute2}/bin/ip -n ${cfg.namespace} link set lo up
|
||||||
@@ -60,7 +60,7 @@ in {
|
|||||||
'';
|
'';
|
||||||
ExecStop = with pkgs;
|
ExecStop = with pkgs;
|
||||||
writers.writeBash "wg-down" ''
|
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} route del default dev wg0
|
||||||
${iproute2}/bin/ip -n ${cfg.namespace} link del wg0
|
${iproute2}/bin/ip -n ${cfg.namespace} link del wg0
|
||||||
'';
|
'';
|
||||||
|
|||||||
Reference in New Issue
Block a user