fix(wireguard): use public DNS to resolve endpoint before tunnel is up
Query @1.1.1.1 explicitly in postUp/preDown hooks since the VPN DNS (10.0.1.65) is unreachable before the tunnel establishes.
This commit is contained in:
+2
-2
@@ -181,13 +181,13 @@
|
||||
privateKeyFile = "/etc/wireguard/private.key";
|
||||
|
||||
postUp = ''
|
||||
ENDPOINT_IP=$(${pkgs.dig}/bin/dig +short vpn.leeworks.dev | head -1)
|
||||
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 = ''
|
||||
ENDPOINT_IP=$(${pkgs.dig}/bin/dig +short vpn.leeworks.dev | head -1)
|
||||
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
|
||||
'';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user