mediaserver: wg0
This commit is contained in:
parent
36c7e12d69
commit
65296cf6c1
1 changed files with 5 additions and 0 deletions
|
@ -24,7 +24,9 @@
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
ExecStart = with pkgs; writers.writeBash "wg-up" ''
|
ExecStart = with pkgs; writers.writeBash "wg-up" ''
|
||||||
set -e
|
set -e
|
||||||
|
echo "Creating interface ..."
|
||||||
${iproute}/bin/ip link add wg0 type wireguard
|
${iproute}/bin/ip link add wg0 type wireguard
|
||||||
|
echo "Configuring wg0 ..."
|
||||||
${wireguard-tools}/bin/wg setconf wg0 ${config.age.secrets.wireguard-config.path}
|
${wireguard-tools}/bin/wg setconf wg0 ${config.age.secrets.wireguard-config.path}
|
||||||
${iproute}/bin/ip link set wg0 netns wg
|
${iproute}/bin/ip link set wg0 netns wg
|
||||||
${iproute}/bin/ip -n wg address add 10.66.10.158/32 dev wg0
|
${iproute}/bin/ip -n wg address add 10.66.10.158/32 dev wg0
|
||||||
|
@ -33,12 +35,15 @@
|
||||||
${iproute}/bin/ip -n wg link set wg0 up
|
${iproute}/bin/ip -n wg link set wg0 up
|
||||||
${iproute}/bin/ip -n wg route add default dev wg0
|
${iproute}/bin/ip -n wg route add default dev wg0
|
||||||
${iproute}/bin/ip -n wg -6 route add default dev wg0
|
${iproute}/bin/ip -n wg -6 route add default dev wg0
|
||||||
|
echo "Done!"
|
||||||
'';
|
'';
|
||||||
ExecStop = with pkgs; writers.writeBash "wg-down" ''
|
ExecStop = with pkgs; writers.writeBash "wg-down" ''
|
||||||
|
echo "Tearing down wg0 ..."
|
||||||
${iproute}/bin/ip -n wg route del default dev wg0
|
${iproute}/bin/ip -n wg route del default dev wg0
|
||||||
${iproute}/bin/ip -n wg -6 route del default dev wg0
|
${iproute}/bin/ip -n wg -6 route del default dev wg0
|
||||||
${iproute}/bin/ip -n wg link del wg0
|
${iproute}/bin/ip -n wg link del wg0
|
||||||
${iproute}/bin/ip -n wg link set lo down
|
${iproute}/bin/ip -n wg link set lo down
|
||||||
|
echo "Done!"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue