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!" ''; }; };