diff --git a/src/lifecycle/egress.ts b/src/lifecycle/egress.ts index 386018b..e2b4995 100644 --- a/src/lifecycle/egress.ts +++ b/src/lifecycle/egress.ts @@ -131,19 +131,28 @@ async function reaches(name: string, waitSeconds: number): Promise { await incus([ "exec", name, "--", "sh", "-c", - `via=$(ip -4 route show default | awk '{print $3}' | head -n1); ` + - `{ [ -n "$via" ] && printf 'nameserver %s\\n' "$via"; ` + - `printf 'nameserver 1.1.1.1\\nnameserver 8.8.8.8\\n'; ` + - `printf 'options timeout:2 attempts:3\\n'; } > /etc/resolv.conf; true`, + `link=$(ip -4 route show default | awk '{print $5}' | head -n1); ` + + `via=$(ip -4 route show default | awk '{print $3}' | head -n1); ` + + `if [ -n "$link" ] && command -v resolvectl >/dev/null 2>&1; then ` + + `resolvectl dns "$link" $via 1.1.1.1 8.8.8.8 >/dev/null 2>&1 || true; fi; true`, ], 30_000); }