Skip to content

The DNS client

The DNS client asks one DNS server one question, and shows what the server answered. It asks over UDP, TCP, DNS over TLS, DNS over HTTPS on HTTP/2 or HTTP/3, or DNS over QUIC. Use it to see what a forwarder answers, or why a name answers what it does at its source. Use it to copy a record of another server into a zone of yours, too.

The console has it as the page Tools, DNS client. A script calls POST /api/dns-client. A shell runs tadoru dig, which asks from its own process with no server.

An operator or an admin. A viewer gets 403. A session sends its forgery token in x-csrf-token, as for every change. On the management socket, the server does not take the word of the operating system for this route: the socket needs a token too. Accounts has the roles.

Terminal window
curl -s --unix-socket ./data/run/api.sock http://localhost/api/dns-client \
-H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
-d '{"server": "tls://dns.quad9.net (9.9.9.9)", "name": "example.com", "type": "MX"}'

The body names the question and the server, and nothing else. It is 16 KiB at most.

Field What it is Default
server The server: an address, an entry in the form of forwarders, or a host name Required
transport udp, tcp, tls, https, quic or h3 udp, or the scheme of server
name The name, in ASCII. Write an internationalized name as its A-label Required
type A type by its name, such as AAAA, or by its number A
class IN or CH IN
recursion The RD bit true
checking_disabled The CD bit false
dnssec The DO bit. It needs edns false
edns Whether the query carries an OPT record true
payload_size The payload size of the OPT record, 512 to 4096. It needs edns 1232
tcp_after_truncation Whether a UDP reply with TC is asked again over TCP true
timeout_ms The time of one attempt, 100 to 5000 milliseconds 3000

The forms of server:

Form Asked over
192.0.2.53, 192.0.2.53:5353 UDP, or TCP with "transport": "tcp"
tcp://192.0.2.53, tcp://dns.example TCP alone
tls://dns.example (192.0.2.53) DNS over TLS, port 853
https://dns.example/dns-query (192.0.2.53) DNS over HTTPS, port 443
h3://dns.example/dns-query (192.0.2.53) DNS over HTTPS on HTTP/3, port 443
quic://dns.example (192.0.2.53) DNS over QUIC, port 853
dns.example, tls://dns.example A host name, which this server looks up

An encrypted form checks the certificate of the server for its name, and no field turns that check off. A form with a scheme takes that transport, so transport is absent or the same word. type cannot be AXFR, IXFR, OPT, TKEY, TSIG, MAILA or MAILB, because those are not one question.

The route answers 200 whatever the server answered. outcome says how the query ended:

outcome What happened What to do
answered The server answered, whatever its response code. message holds the reply Read message.rcode and the sections
timeout Nothing that answers came back in time Check that the server listens on that port, or raise timeout_ms
unreachable The connection was refused, or the network has no route Check the address and the port
refused The rule of the target refused each address that a host name gave Read problem, and see “The limits” below
tls The handshake failed, or the certificate did not pass for the name Check the name before the parentheses
http A DoH server answered with something other than 200 and application/dns-message Read status and content_type of the attempt
malformed The reply does not read as an answer to the query Read problem
local The query did not start here. For example, no socket was left Ask again, and read the server log
unresolved The host name of server gave no address Read problem, and see “A host name” below
too-large The reply passed 4,096 records or 1 MiB of text message holds the header and the counts alone

These words are the set of this version. A later version can add one, so a script shows a word it does not know as another outcome. attempts holds each exchange: its transport, its outcome, the microseconds of its handshake and of the whole attempt, and the octets of its reply. A query has two attempts where a UDP reply was cut short and the query asked again over TCP. elapsed_us of the last attempt is the time it took.

The TTLs are those that the server sent. A DoH reply that carries an Age header keeps its TTLs, and the attempt shows age apart.

server in the answer shows the host name, the name of the certificate and the path of a DoH server as you wrote them. A path can hold a token, so keep and log the answer as you keep and log what you sent. No refusal and no line of the server log holds the text of server.

A server can be a host name, such as tls://dns.google. This server then looks it up as the server itself, for AAAA and A at the same time, within timeout_ms. The lookup writes no row of the query log. The query goes to the first address that the rule of the target takes, IPv6 first, and every attempt connects to that one address. Nothing looks the name up again. The host name serves the certificate and the host of DoH alone. server in the answer names the host name, the addresses that the lookup gave, at most 32, and the address that the query used.

The lookup meets the rebinding check of this server. A name that a forwarder answers with a private address comes back as SERVFAIL, and the query is unresolved. To ask such a server, write its address in server, as tls://dns.home.example (192.168.1.53).

A name under a special-use zone is always unresolved, unless a zone of yours holds it. Such zones are .test, .invalid, .local and home.arpa. A name under .onion is refused in every form, because such a name is reached through Tor alone, and the DNS client goes direct.

A lookup that does not end in time is timeout. The lookup can join a resolution that another question started. Where that resolution runs out of its time first, the query is timeout too.

Each record of message that a zone can hold has zone_line, the line that POST /api/zones/{id}/records takes in add. A record that a zone cannot hold has not_addable instead: class, soa, signer-type, opt, not-data or data. The console button “Add to a zone” sends the lines that you pick, and the record change judges each line as it judges every line. Local Zones has the record change.

  • One query runs at a time for the whole server, across every account, token and listener of the API. A second one is 429 dns-client-busy, with Retry-After: 1.
  • 60 queries run in any 60 seconds. The 61st is 429 dns-client-rate, with Retry-After in seconds.
  • A query ends 15 seconds after the server took it, whatever it waits for.
  • The rule of the target refuses loopback, link-local, multicast and broadcast addresses, the unspecified address, and a NAT64, 6to4 or IPv4-compatible form of any of them. A DNS listener of this server on loopback passes, for its own transport. A private address passes.
  • Where server names addresses and the rule refuses each of them, the answer is 422 target-refused. Nothing is sent, and the query counts nothing in the 60.
  • A host name is looked up after the server took the query. So a host name whose every address the rule refuses answers 200 with the outcome refused, and the query counts in the 60.
  • The route never shows the body of an HTTP reply, or the octets of a reply that does not read.

The limits bound the route. They do not make it harmless.

  • An operator can scan the ports of the private network, over UDP and TCP: 60 targets a minute, one at a time. A timeout and an unreachable tell a closed port from a silent one. The limits make a scan slow and logged, not impossible.
  • The rule reads the address that the route sends to. A network can translate or route that address to another one: a NAT64 gateway with a prefix of its own, a port forward of a router, or a host that relays. The rule reads the well-known NAT64 prefixes, the prefixes of rebind_nat64, 6to4 and the IPv4 forms of IPv6. The firewall of the network protects a service behind another path.
  • The rule does not read Teredo (2001::/32) or ISATAP addresses.
  • Some metadata services of clouds sit at addresses that the rule takes, such as fd00:ec2::254 and 100.100.100.200. Such a service speaks plain HTTP, so DoT, DoH and DoQ fail at the handshake, and the route never shows a body.
  • DoH makes a web server at the target receive a POST with a DNS body.
  • Inside 64:ff9b:1::/48, the rule refuses some addresses that reach a public server, because it cannot know the layout of the network. Write the prefix of your network in rebind_nat64, and the rule reads that layout alone.

Each query writes one line at info: “a query of the DNS client ended”. It holds the account or token:<id>, the address, the port, the transport, the type and the outcome of each attempt. A refused target writes one line at warn, “the DNS client refused a target”, with each address and its rule. A line can hold the name of the question, the host name of the server and the text of each problem. It holds them only where store_names was on as the query started, and is on as the line is written. A query of the DNS client writes no audit row. dns_client_attempts_total counts the attempts by transport and outcome. Logs and metrics has both.