Skip to content

DNS

DNS turns a site’s name into an address. In AFTAB every client’s DNS is answered by the panel itself. A client’s config names the server’s own address on its inbound as its DNS. The firewall sends clients’ DNS, port 53, to the panel’s resolver, which listens on port 15353, and the resolver asks the real DNS servers for the client and keeps the answers. Because the panel sees the names, domain rules in Routing work, and a block rule for domains can answer “no such domain”.

  • It answers from its cache when it can. An answer is kept for as long as its own lifetime says, from 5 seconds up to an hour.
  • It asks the inbound’s DNS servers one after another. A server that stays silent is skipped after a short wait, and the resolver gives up after 6 seconds.
  • It gives out no IPv6 addresses, because the tunnel carries IPv4 only. Apps then connect over IPv4 through the VPN, instead of around it on the phone’s own IPv6.
  • It sends its questions the way the client’s traffic goes: through the inbound’s exit, or the client’s own exit. See Exits. A lookup through an exit that is not there stops at once. Each exit has its own share of the lookups in flight, so one silent exit does not hold up the others.
  • It refuses encrypted DNS that would go around it: DNS over TLS, such as Android’s Private DNS, and HTTPS to the DNS servers named in the configs. Apps then fall back to plain DNS, which the panel answers.

Each fleet server runs a resolver of its own for the inbounds on it.

  • For new inbounds, and for any inbound whose DNS servers field is empty, the servers come from Settings → Network → WireGuard → Default DNS. The default is 1.1.1.1 and 8.8.8.8.
  • For one inbound, edit it and fill DNS servers: Inbounds → Edit inbound → DNS servers. Give IP addresses separated by commas or spaces, IPv4 ones, because the resolver reaches its servers over IPv4.

The configs name the panel’s own address, so changing the servers needs no new config.

The card DNS for clients at the bottom of Routing has the field Ask upstream over HTTPS (DoH). Empty means plain DNS to each inbound’s DNS servers. To use DoH, type https:// addresses separated by commas, or press Cloudflare, Google or Quad9 to add https://1.1.1.1/dns-query, https://dns.google/dns-query or https://dns.quad9.net/dns-query, then press Save. The networks on the way can then neither read nor change the questions. The questions still leave through each inbound’s exit.

The DoH servers are asked in turn, and the inbounds’ DNS servers are not used while the field is filled. The card also shows how many questions were answered, how many came from the cache and how many were blocked.

  • Resolver not running, on the card: domain rules are not applied, and clients’ DNS goes straight to the inbounds’ DNS servers. Run sudo aftab restart, or sudo systemctl restart aftab-dns. When an inbound is up, the card says Answering clients.
  • Lookups fail after turning DoH on. None of the DoH servers answered, and there is no fallback to plain DNS. Check the addresses, or empty the field.
  • “DoH addresses start with https://”. The panel shows this when an address in the field does not start with https://.
  • An app ignores the panel’s DNS. An app with its own encrypted DNS to a server the configs do not name is not seen, so a domain rule cannot match its lookups.