Checking DNS Availability

2 Total views across this article’s versions; includes the historical baseline where available.

Compare all DNS policies.

A route can exist while a DNS service is not answering. Routing configuration and VPN operation have their own guides. This page supplies manual diagnostics and controlled fault exercises, not a polling daemon or automatic failover controller. Linux runtime validation remains pending.

Define What Is Being Checked

A routing lookup answers where Linux would send a packet under the supplied selectors. A VPN lifecycle event describes the client’s session. A DNS query tests a particular resolver operation through the currently permitted path. Keep those observations separate in the test record.

Use the selected routing guide’s existing resolver, variables, and account context. Observe a fresh query and response on the intended interface. Local cache hits and hosts-file results do not demonstrate upstream availability. Check UDP and TCP independently; a request to a local stub need not use the same transport upstream.

Record the query, response status, address, interface, source, and timing. A DNS error reply differs from a timeout; a command failure can also mean a local configuration or invocation error. Neither alone proves the VPN is down. Keep the existing path restrictions in place during diagnosis.

Keep the Outcome Within the Selected Policy

Scenario If the Selected Service Does Not Respond
1. Application-scoped DNS Selected applications’ upstream lookups fail; ordinary DNS retains its own policy
2A. Strict VPN DNS Fresh upstream lookups fail; no direct provider is authorized
2B. Permissive DNS fallback The current mode remains in force until an explicit approved transition; this guide does not select a trigger
3. Dedicated direct DNS Lookups fail; no substitution of VPN DNS
4A/4B. DNS on VPN 1 Lookups fail; no direct or VPN 2 fallback

An observer may report available, unavailable, or unknown. Before automating any policy transition, separately define which evidence triggers it, how repeated failures and recovery are handled, and what happens when the observer itself fails. No thresholds, scheduler, or production controller are supplied here.

Controlled DNS-Service Fault

The following exercise uses Example 3’s direct-DNS setup. Use a disposable lab host with independent recovery access and the verified DIRECT_IF, DIRECT_DNS, and test-name values from that guide. Record each successful rule insertion and remove only rules actually installed; do not leave a partial fault active if a command fails.

Keep the Existing Account and Shell Context

Continue in the selected walkthrough’s root Bash shell. If it was closed, open sudo -i once and recover the recorded ORDINARY_USER, interface and provider values before continuing. Do not silently accept empty or example values. Keep the same firewall backend and the application guards installed.

set -euo pipefail
test "$(id -u)" -eq 0
test -n "${ORDINARY_USER:-}"
test "$(id -u "$ORDINARY_USER")" -ne 0
test "$ORDINARY_USER" != newsvpn
test -n "${DIRECT_IF:-}"
test -n "${DIRECT_DNS:-}"
test -n "${TEST_NAME:-}"
iptables -w -S OUTPUT

Inspect the values and full rule order. The two fault-rule comments below must not already identify installed rules. Do not insert duplicates. Run each insertion and removal separately and record whether it succeeded. If the second insertion fails, stop the fault exercise and remove only the first successfully installed rule. Do not remove the baseline DNS chains or application guards.

Establish a Positive Control

Use a permitted, fully qualified test name with an expected answer, preferably a fresh name in a controlled lab zone. Run these commands as the ordinary account, which uses the direct route in Example 3. Preserve the complete response and inspect the packets and source on DIRECT_IF:

set +e
runuser -u "$ORDINARY_USER" -- dig -r -4 @"$DIRECT_DNS" +notcp +ignore +time=2 +tries=1 "$TEST_NAME" A
runuser -u "$ORDINARY_USER" -- dig -r -4 @"$DIRECT_DNS" +tcp +time=2 +tries=1 "$TEST_NAME" A

Require the expected answer over both transports before introducing a fault. dig can exit successfully after receiving an error response; inspect the DNS response status and answer, not just its shell status. A negative answer proves a response arrived but does not satisfy a test expecting an A record. The selected walkthrough’s separate client/stub checks still matter. dig options and return codes

set +e allows expected diagnostic failures; it does not excuse a failed insertion or restoration. Check administrative results explicitly from here onward. Do not start fault probes after any unexpected setup failure.

Check an Unresponsive DNS Path

To simulate loss of the selected provider while retaining the direct route, temporarily drop only its outbound port-53 requests. This is a fault injection, not a claim that the real provider is down:

iptables -w -I OUTPUT 1 -o "$DIRECT_IF" -d "$DIRECT_DNS" -p udp --dport 53 -m comment --comment dns-direct-test-udp -j DROP
iptables -w -I OUTPUT 1 -o "$DIRECT_IF" -d "$DIRECT_DNS" -p tcp --dport 53 -m comment --comment dns-direct-test-tcp -j DROP

Repeat the positive-control queries with fresh test names, then the selected walkthrough’s ordinary-client/stub checks. Fresh upstream lookups must time out or fail without switching provider or route. This demonstrates the local injected fault, not a diagnosis of the external provider. Inspect the fault rules’ counters as well as captures; dropped packets may never reach the egress capture point. Remove each exact test rule that was successfully installed, even if a probe fails. Run the deletions separately and inspect their results:

iptables -w -D OUTPUT -o "$DIRECT_IF" -d "$DIRECT_DNS" -p udp --dport 53 -m comment --comment dns-direct-test-udp -j DROP
iptables -w -D OUTPUT -o "$DIRECT_IF" -d "$DIRECT_DNS" -p tcp --dport 53 -m comment --comment dns-direct-test-tcp -j DROP

List OUTPUT again, require both exact fault rules to be absent, and repeat the original UDP/TCP positive controls and client/stub checks. Verify fresh DNS works again through the original provider and path. Do not clear the entire connection-tracking table or mistake cached answers for an upstream success. These checks have not been run on Linux.

For 2A or 2B in VPN mode, apply this same two-rule method to that example’s VPN_IF and VPN_DNS. For 4A/4B, use DNS_VPN_IF and DNS_UPSTREAM. Substitute the corresponding variables consistently in preflight, positive-control probes, inspection, insertion and removal commands. The blocks above use Example 3’s direct-path variables and must not be run unchanged for a VPN-path test. These are alternative lab exercises, not extra permissions or rules to leave installed. In 2B, a test timeout alone must not switch the mode.

For Example 1, run its DNS probes through the existing vpn_dns_run helper with verified absolute executable paths, so the private resolver environment and reader account are tested. An ordinary-account or host-stub query is not a substitute for that check.

Controlled Payload Fault for the Two-VPN Lab

Start from 4A or 4B with its verified variables and protections. Keep recovery access outside both test interfaces. These temporary drops simulate unresponsive payload paths while routes remain present; they do not disconnect the VPN clients or test their reconnect logic. Record successful insertions and remove each owned test rule before proceeding.

iptables -w -I OUTPUT 1 -o "$DNS_VPN_IF" -m comment --comment test-dns-vpn-payload -j DROP

Test fresh lookups, inspect the test rule’s counters, and confirm no DNS reaches VPN 2 or the direct provider. This models loss of outbound tunnel payload; it is not proof of a real transport outage. Remove the exact rule and confirm recovery:

iptables -w -D OUTPUT -o "$DNS_VPN_IF" -m comment --comment test-dns-vpn-payload -j DROP

Then simulate loss of the application tunnel separately:

iptables -w -I OUTPUT 1 -o "$VPN_IF" -m comment --comment test-app-vpn-payload -j DROP

DNS through VPN 1 must still work. A fresh reader connection using a known server IP must fail, so the connection test does not depend on a DNS cache. Remove the exact test rule afterward:

iptables -w -D OUTPUT -o "$VPN_IF" -m comment --comment test-app-vpn-payload -j DROP

After testing, verify all exact test rules are absent and repeat the baseline routing and service checks. Actual VPN lifecycle faults belong in the operation guide. None of these exercises creates a new permission to change provider or bypass a firewall restriction.

Review History

Preserved earlier draft (text). Source and local page review: November 26, 2026. The requests in this guide are diagnostic checks, not an automatic controller. The separate advanced Ubuntu walkthrough covers the completed local controller and integration source. Linux runtime validation remains deferred.

Primary references: iptables insert/delete and traversal semantics, dig diagnostics, and resolver configuration.