diff --git a/configuration.nix b/configuration.nix index 6719a58..e87acb0 100644 --- a/configuration.nix +++ b/configuration.nix @@ -180,13 +180,13 @@ dns = [ "10.0.1.65" ]; privateKeyFile = "/etc/wireguard/private.key"; - postUp = '' + preUp = '' ENDPOINT_IP=$(${pkgs.dig}/bin/dig +short vpn.leeworks.dev @1.1.1.1 | head -1) GATEWAY=$(${pkgs.iproute2}/bin/ip route show default | ${pkgs.gawk}/bin/awk '{print $3}') DEV=$(${pkgs.iproute2}/bin/ip route show default | ${pkgs.gawk}/bin/awk '{print $5}') ${pkgs.iproute2}/bin/ip route add "$ENDPOINT_IP" via "$GATEWAY" dev "$DEV" ''; - preDown = '' + postDown = '' ENDPOINT_IP=$(${pkgs.dig}/bin/dig +short vpn.leeworks.dev @1.1.1.1 | head -1) ${pkgs.iproute2}/bin/ip route del "$ENDPOINT_IP" || true '';