1
0
Fork 0

mediaserver: wg0

This commit is contained in:
Daniel Kempkens 2023-04-15 00:17:41 +02:00
parent 36c7e12d69
commit 65296cf6c1
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM

View file

@ -24,7 +24,9 @@
RemainAfterExit = true;
ExecStart = with pkgs; writers.writeBash "wg-up" ''
set -e
echo "Creating interface ..."
${iproute}/bin/ip link add wg0 type wireguard
echo "Configuring wg0 ..."
${wireguard-tools}/bin/wg setconf wg0 ${config.age.secrets.wireguard-config.path}
${iproute}/bin/ip link set wg0 netns wg
${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 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" ''
echo "Tearing down 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 link del wg0
${iproute}/bin/ip -n wg link set lo down
echo "Done!"
'';
};
};