unbraid

Guides · Published · Updated on

Private DNS and a VPN on Android

On Android 10 and later, Private DNS keeps working while a VPN is connected. If you type a hostname into it, apps that use Android’s own resolver send their lookups to that service and not to the DNS servers your VPN set up, so the VPN’s DNS and any blocking it does are skipped. Automatic works the other way round: it tries encrypted DNS with the servers the VPN or your network already provides, and uses plain lookups when they don’t offer it.

Android 9 handled this differently. Google’s own Public DNS setup page warns that on Android 9 the Private DNS setting has no effect while a VPN is on. Advice written for that version still turns up in search results.

What Private DNS does

Before an app connects to a server by name, the phone needs the server’s address, and a DNS server provides it. Android keeps recent answers for a while, so not every connection needs a new lookup. When it does ask, plain DNS has no encryption of its own. On Wi-Fi or mobile data, your internet provider or carrier usually answers, and anyone on the path can read the names. Inside a VPN tunnel the tunnel protects it.

Android 9 added DNS over TLS and a setting for it called Private DNS. Lookups travel encrypted on port 853. In 2022 Google added DNS over HTTP/3 for a short list of well known services, delivered to Android 11 and later through a Google Play system update. Other services keep using DNS over TLS.

Private DNS covers lookups and nothing else. The sites you visit still see your real IP address, and your network can still see which servers you connect to. A VPN carries the traffic assigned to it through a tunnel, and sites reached through it see the VPN server’s address. You can use Private DNS while connected to a VPN.

The three settings

On a Pixel the setting is under Settings, Network & internet, Private DNS (Pixel Help). Samsung puts it under Connections, More connection settings. Other phones usually have it next to the Wi-Fi and mobile data settings.

  • Off. Plain DNS to whatever server the current network provides.
  • Automatic. Android’s default. It tries encrypted DNS with the network’s own DNS servers. If they support it, lookups go encrypted. If not, they go in plain text as before.
  • Private DNS provider hostname. You type the hostname your DNS service gives you for Private DNS, a bare name without https:// or a path, and tap Save. Android checks that the server’s certificate matches that name.

The hostname mode is strict. If Android can’t reach the service or can’t verify it, new lookups fail instead of falling back to plain DNS, and most apps behave as if you had no internet. Answers already in the cache and connections already open can keep working for a while, which makes the problem look patchy. A typo in the hostname, an outage at the service, or a network that blocks encrypted DNS can all cause it.

What changes when a VPN connects

A VPN on Android is its own network. Apps that use it get the DNS servers the VPN app set up, and apps left out of it keep the DNS of Wi-Fi or mobile data. Private DNS is applied to each network separately, the VPN included. The change that made strict mode work on VPNs was written in 2019 and is part of Android 10.

The table assumes the app uses Android’s resolver and the VPN app sets DNS servers. If a VPN sets none, Android can use the underlying network’s DNS for apps on it.

Your setting Apps going through the VPN Apps left out of the VPN
Off The VPN’s DNS, plain inside the tunnel The network’s DNS, plain
Automatic The VPN’s DNS, encrypted if those servers support it The network’s DNS, encrypted if it supports it
Hostname Your Private DNS service, not the VPN’s DNS Your Private DNS service, over Wi-Fi or mobile data

With a hostname set, lookups for apps on the VPN are made on the VPN network, so with a typical full tunnel they travel inside it, encrypted, to your Private DNS service. That service then sees the VPN server’s address, not yours. The VPN’s own DNS server doesn’t get the question, so whatever it would have blocked or answered differently is lost. Android’s documentation for device administrators adds that some of the system’s own traffic to the resolver may not go through the VPN, and asks for a resolver reachable both inside and outside it.

What a leak test shows

A DNS leak test page asks your browser to look up a few random names and then reports which DNS servers came asking. It tests that browser only. Other apps can use other DNS settings, or other VPN routes.

With a hostname in Private DNS, you would normally see that service’s servers. That isn’t a leak to your internet provider, but it isn’t your VPN’s DNS either. With Automatic, you would expect the VPN provider’s servers, or another DNS service the VPN uses. The test shows who answered. It can’t show whether the question travelled through the tunnel.

If it shows your internet provider or mobile carrier, look further: the browser may be excluded from the VPN, the VPN app may not set DNS, or the browser may do its own lookups. How to check your VPN is working on Android goes through the DNS test and the other checks step by step, with a table of what each result means.

Apps and browsers with their own DNS

Private DNS changes the phone’s built in resolver. Apps that use it get the setting. Apps that bring their own DNS code don’t, and Android’s security guidance for developers says custom DNS can bypass the system’s protection.

Browsers are the common case. Chrome on Android has Use secure DNS under Settings, Privacy and security (Chrome Help). With a provider chosen there, Chrome sends its own encrypted lookups to that provider, whatever Android or the VPN says. These lookups are ordinary web traffic, so they still go through the VPN if the browser is in it, but the VPN’s DNS server isn’t asked.

Your browser’s DNS setting can differ from Android’s and from the VPN’s. When a page or a leak test shows a DNS server you didn’t expect, check the browser’s setting too.

What a DNS filter can and can’t block

Many people set Private DNS to a filtering service, so the whole phone gets the filter without an extra app. Services filter different things. AdGuard DNS blocks ads and trackers, Cloudflare’s 1.1.1.2 and 1.1.1.3 block malware (1.1.1.3 adult sites too), NextDNS blocks what you set in your profile, and Quad9 blocks malicious domains. Read what a service filters before you use its hostname.

For a blocked name, the service returns a blocking answer in place of a usable address, and connections that depend on that lookup fail. That works against ad, tracking and malware servers on their own domains. It doesn’t help with:

  • Ads from the same domain as the content. DNS sees names, not pages. If ads come from the same servers as the videos, blocking one blocks the other. AdGuard explains this for YouTube ads.
  • Apps with their own encrypted DNS, or with server addresses built in. Their lookups don’t reach the filter. A VPN that catches ordinary DNS traffic can still filter an app that sends plain lookups of its own.
  • Anything inside a page. A DNS filter can’t hide an element or remove a banner that the site serves itself.

Many VPN providers offer their own DNS blocking. With a hostname in Private DNS, apps on the VPN skip it, so you get one filter or the other, not both.

Which setting to choose

You use a VPN and want its DNS. Set Private DNS to Automatic. Apps on the VPN use the DNS the VPN set up, including any blocking your provider offers. Apps left out keep your network’s DNS, encrypted when the network supports it.

You want one filter on and off the VPN. Set a hostname. Apps using Android’s resolver get the same service on every network, encrypted, but the VPN’s DNS is skipped, and a network that blocks encrypted DNS stops their lookups.

You don’t use a VPN. Automatic encrypts lookups when your network supports it. A hostname gives you a chosen service on every network, including mobile data.

If lookups fail in hostname mode, switch to Automatic for a moment. If things work again, check the hostname and whether the network you’re on can reach that service.

Private DNS in unbraid

unbraid runs one VPN on Android and gives each app its own exit, or none. A route’s internet lookups normally go through that route’s tunnel, to the provider’s or the tunnel’s DNS, with Quad9 as a fallback, unless you set a filter in Protection. Local names use your network’s DNS while Local network bypasses the VPN is on. A Private DNS hostname overrides this for apps that use Android’s resolver: Android does the lookups itself and they skip their routes’ DNS. When Android reports a hostname, Routes shows a warning. Tapping it opens Android’s network settings, where you can set Private DNS to Automatic.

To filter lookups inside unbraid, go to Settings, Protection. None keeps each provider’s own blocking. You can pick a public filter or Own DNS server: an https:// address for DNS over HTTPS, a tls:// address for DNS over TLS, or a plain IPv4 address. A plain address has no encryption of its own, though on a VPN route it still travels inside the tunnel. On Android, wherever your Own DNS server choice applies, a server within your configured home WireGuard ranges is reached through that tunnel. With Reach your tailnet on, a server within your tailnet or configured Tailscale home subnets is reached through Tailscale. Then choose where it applies:

  • VPN routes. The filter replaces each provider’s own blocking and is asked inside each route’s tunnel.
  • Direct traffic through unbraid. Apps that follow a Direct default route use the filter.
  • Apps set to Direct. Outside unbraid leaves them on the phone’s DNS. Through unbraid sends their lookups to the filter while their traffic still goes straight out, but they can then see that a VPN is on, which some banking and streaming apps refuse. Each Direct app can be set on its own in Apps. With Android’s Block connections without VPN on, apps kept outside pass through unbraid but still use the phone’s DNS.

If you keep Direct apps outside and the filter has a Private DNS name (a public filter, a NextDNS profile, or your own tls:// server), Private DNS for apps outside unbraid copies that name and opens Android’s settings. You paste and save it there yourself. From then on it also affects apps on routes that use Android’s resolver, so they skip their routes’ DNS. The page says so before you tap.

Questions

Is Private DNS the same as a VPN? No. Private DNS encrypts DNS lookups: Automatic uses your network’s resolver, hostname mode uses the service you enter. A VPN carries the traffic assigned to it through a tunnel and changes the address sites see. They can run together, and the table above shows who answers the lookups when they do.

Should Private DNS be on or off? Automatic encrypts lookups when the network’s or VPN’s DNS servers support it and uses plain DNS when they don’t, so it rarely breaks anything. Use a hostname when you want one particular service on every network and accept that it replaces your VPN’s DNS.

Why does the internet stop working with a Private DNS hostname? In hostname mode Android doesn’t fall back to plain DNS. If it can’t reach and verify the service, new lookups fail. Check the hostname for typos. On a Wi-Fi network with a sign-in page, use the network’s sign-in notification first. If lookups still fail, set Automatic while you’re on that network.

Bring your own VPN

unbraid is a VPN client with no servers of its own. You sign in with an account you already have, or add your own server. It has built-in support for AirVPN, ExpressVPN, IVPN, Mullvad, NordVPN (affiliate link), Private Internet Access, Proton VPN (Free included), Surfshark (affiliate link) and Windscribe. For CyberGhost, you import config files from your account, with step-by-step help in the app.

We earn a commission if you subscribe through a link marked (affiliate link). It helps keep unbraid free. If you're about to subscribe to a VPN service, thank you for considering doing it through one of them.