From 65296cf6c16d47383040a9a612021768b6735f24 Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Sat, 15 Apr 2023 00:17:41 +0200 Subject: [PATCH] mediaserver: wg0 --- system/nixos/wireguard-netns.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/system/nixos/wireguard-netns.nix b/system/nixos/wireguard-netns.nix index 282de04..6990cb2 100644 --- a/system/nixos/wireguard-netns.nix +++ b/system/nixos/wireguard-netns.nix @@ -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!" ''; }; };