--- title: "Separate VPNs, Using an Independent DNS Provider" description: "Reach an independent DNS provider through VPN 1 while selected application traffic uses VPN 2." url: /tutorials/networking/vpn-dns/vpn1-independent-dns-apps-on-vpn2/ article_id: vpn-dns-4b content_kind: tutorials categories: [Networking] tags: [tutorial, networking, DNS, VPN, iproute2, iptables] noindex: true sitemap: disable: true --- [Compare all DNS policies](/reference/networking/vpn-dns-policies/). You may want to choose your own DNS provider without sending queries through your direct Internet connection. As in Example 4A, DNS uses **VPN 1**, your newsgroup reader uses **VPN 2**, and ordinary application connections remain direct. These are separate paths from the same host, not one VPN inside another. The second variation uses a DNS provider you choose separately, reached through VPN 1. For example, you may prefer a particular resolver regardless of which VPN service carries the connection. Choose this variation if you want to control the DNS provider independently of the VPN provider. The DNS route still requires VPN 1; choosing a public resolver does not mean reaching it over the direct Internet connection. {{% callout style="note" %}} This is an integrated review draft. The commands and verification procedures have not been run on a Linux host. VPN operation and availability monitoring remain separate from this routing walkthrough. {{% /callout %}} ## Open the Walkthrough Shell {#walkthrough-shell} From your ordinary administrator account, open a root login shell first: ```bash sudo -i ``` Use Bash in that root shell for the remaining setup, checks, and withdrawal. Do not nest another root shell when following a shared section. Confirm root access and retain the original account for comparison tests: ```bash set -euo pipefail test "$(id -u)" -eq 0 ORDINARY_USER="${SUDO_USER:-}" test -n "$ORDINARY_USER" test "$ORDINARY_USER" != root test "$ORDINARY_USER" != newsvpn test "$(id -u "$ORDINARY_USER")" -ne 0 id "$ORDINARY_USER" ``` Stop if the account is not your intended ordinary user. Administrative commands now run without repeated `sudo`. `runuser -u ... --` deliberately runs a test under the named account; testing as root would not exercise the reader's UID guard. When following a linked foundation check, keep its ordinary-user tests under `ORDINARY_USER` too; a root request is not the ordinary-account comparison. The examples require `runuser` as well as the tools listed below. [Root login shells](https://man7.org/linux/man-pages/man8/sudo.8.html), [account-specific commands](https://man7.org/linux/man-pages/man1/runuser.1.html) ## 1. Choose the Provider {#provider} Obtain a supported public IPv4 resolver address from your chosen provider. Confirm that VPN 1 permits access to it. The provider's validity, trust, and availability are your responsibility; this guide does not test or select a provider for you. Use the [same starting topology and application foundation as 4A](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#starting-point), including its recovery access, existing shared resolver, IPv6 boundaries, and Ubuntu 24.04 lab baseline. Begin without another DNS example active. This is an alternative configuration, not an additional layer over an installed 4A policy. {{% callout style="important" %}} A public resolver address does not authorize direct DNS. If VPN 1's usable route disappears, fresh upstream DNS must stop. VPN 2 continues to protect application connections; neither path takes over the other's role. {{% /callout %}} ## 2. Apply the Shared Configuration {#configuration} Use **4A's command blocks** in the order below. You already opened the root shell above; skip 4A's “Open the Walkthrough Shell” section and keep `ORDINARY_USER` unchanged. Substitute your independent provider's address for `DNS_UPSTREAM` **before running its setup block**. This replaces 4A's VPN-native provider choice; everything else stays the same. ```bash DNS_UPSTREAM='REPLACE_WITH_CHOSEN_VARIANT_DNS_IPV4' ``` Replace that placeholder with the actual address in the setup block. Do not run it literally, and do not merely change the shell variable after rules have already been installed: that would leave the old routes, firewall rules, and resolver settings in place. To change an installed provider, withdraw that configuration using its original values first. 1. [Set the addresses](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#addresses). Use your independent provider for `DNS_UPSTREAM`; retain and verify each interface's own local source address. 2. [Restrict DNS to VPN 1](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#dns-firewall). The same rules permit only this address on VPN 1 and the local stub. IPv6 upstream DNS and port 853 remain blocked. 3. [Install the host routes and select the resolver](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#dns-route). Keep the terminal `unreachable` route. Configure only your chosen provider, without adding VPN-native DNS as an alternate. 4. [Permit the reader's local stub requests](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#reader-stub). Its application mark, table, source translation, and VPN 2 guard remain unchanged. Use one configuration once. No additional table, packet mark, resolver service, or DNS switching tool is required for this provider variation. ## 3. Verify the Provider and Both Paths {#verification} Include the [public-exit comparison](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#public-exit-check) and [local-listener isolation check](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#local-isolation-check). Run [all of the shared verification commands](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#verification) with this provider's address. Inspect requests and replies; successful lookups alone do not prove the selected path. - Normal upstream UDP and TCP DNS must reach your designated provider through VPN 1. Both ordinary applications and the reader use the existing local stub. - Reader connections must use VPN 2; ordinary application connections remain direct. Direct-to-provider queries from the reader must fail rather than use VPN 2 for DNS. - Another resolver, the correct resolver on the wrong interface, upstream IPv6 DNS, and port 853 must not become alternatives. Retain the shared checks and application restrictions for other DNS transports. Perform the [DNS route-loss test](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#dns-route-loss): fresh upstream lookups must fail while known-address reader connections can continue through VPN 2. Restore the exact route, then perform the [application route-loss test](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#application-route-loss): reader connections must fail while DNS through VPN 1 continues. Test both routes absent, then restore each separately. Keep terminal routes and guards throughout. Use fresh names and connections. A cached answer, a pre-existing connection, or an absent IPv6 route is not proof that the relevant firewall restriction worked. VPN operation and availability monitoring remain separate; these checks do not install either. ## 4. Withdraw This Example {#withdrawal} Stop affected workloads and follow the [exact shared withdrawal sequence](/tutorials/networking/vpn-dns/vpn1-native-dns-apps-on-vpn2/#withdrawal), retaining the independent provider's address in `DNS_UPSTREAM`. Use the shared account-guard inspection and recovery steps: keep a valid original guard, restore it only when absent, and confirm no references remain before emptying the replacement chain. `VPN_IF` still means application VPN 2. Restore the saved DNS server/domain lists on all three affected interfaces before removing this example's DNS restrictions. The revised shared setup leaves the resolver's `default-route` setting untouched; follow its separate warning if you ran an older draft. Inspect partial setup first; remove only entries owned by this example, then verify the previous policy. Keep the reader stopped until its intended DNS environment and application route are verified. The independent resolver ordinarily sees VPN 1's exit address rather than your host's public address. That does not establish anonymity or unlinkability. VPN 1 can still observe the originating connection, and ordinary DNS beyond the VPN exit is not automatically encrypted. Encrypted upstream DNS is a separate, deferred variation. [DNS privacy considerations](https://www.rfc-editor.org/rfc/rfc9076.html) See the [separate technical change record](/review/vpn-dns-vpn1-independent-changes/). See the [account-guard withdrawal technical change record](/review/vpn-dns-account-guard-changes/). ## Leave the Root Shell After verification or withdrawal is complete, return to your ordinary shell: ```bash exit ``` See the [separate root-session and isolation change record](/review/vpn-dns-root-session-isolation-changes/). These commands remain untested on Linux. ## Review History [Preserved combined draft](/review/vpn-dns-vpn1-independent-integrated/), [separate prose and technical change records](/review/vpn-dns-integration-changes/).