मुख्य सामग्री पर जाएं

DNS: van fundament tot beveiliging

DNS Cheatsheet

A practical DNS reference: names and records, resolution, diagnostic commands, DNSSEC, privacy, and operational defenses.

Print-ready: use Ctrl/Cmd + P.

Back to the DNS course

1. The mental model

DNS is a distributed system that maps names to data. It is not one server, and by itself it neither encrypts nor authenticates an answer.

A name is made of labels separated by dots and is read right to left; the final dot represents the root. www.example.com. is absolute; www.example.com may be completed using zone context.

  1. 1

    Application and stub

    The device checks local caches and sends the question to its configured resolver.

  2. 2

    Recursive resolver

    If no valid answer is cached, it looks up the data for the client.

  3. 3

    Root

    It points to the TLD servers that can answer for .com, .it, and other TLDs.

  4. 4

    TLD

    It points to the authoritative servers delegated for the domain, such as example.com.

  5. 5

    Authority

    It returns the zone answer, for example an A record or a CNAME.

  6. 6

    Cache and answer

    The resolver caches the data for its TTL and returns the result to the client.

2. Names, records, and zones

A record binds an owner name to a type and value. Records with the same owner and type form an RRset and share a TTL.

TypeMeaning
A / AAAAName → IPv4 / IPv6 address.
CNAMEAlias name → canonical name.Cannot coexist with other records at that name; generally not used at the apex.
MXMail servers that receive mail for a domain.The lower number means higher preference.
NS / SOAAuthoritative servers / core zone information and parameters.
TXTText attached to a name; used by SPF, DKIM, DMARC, and ownership checks, among other things.
PTRIP address → name in the reverse in-addr.arpa or ip6.arpa zone.
SRVService → host, port, priority, and weight.
DNAMERedirects an entire subtree of names to another suffix; CNAME aliases only one owner name.
CAACertificate authorities allowed to issue certificates for a domain.
DS / DNSKEY / RRSIGRecords that connect a delegation to a key and DNSSEC signatures.
NSEC / NSEC3Signed proof that a name or record type does not exist.
SVCB / HTTPSAdvanced service parameters, also used for HTTPS connections.

3. Reading a zone

A zone is an administratively managed part of the namespace. A final dot marks an absolute name; without it, $ORIGIN may be appended.

Minimal example zone

$ORIGIN example.com.
$TTL 3600

@   IN SOA ns1.example.com. hostmaster.example.com. (
        2026102301 ; serial
        3600       ; refresh
        900        ; retry
        1209600    ; expire
        300        ; negative cache TTL
)
@   IN NS  ns1.example.com.
@   IN NS  ns2.example.com.
@   IN A   192.0.2.10
www IN CNAME @

@ is the zone apex. A CNAME is an alias and cannot coexist with other types at the same name; a standard CNAME is not used at the apex.

Records used for email

mail IN A 192.0.2.25
@    IN MX 10 mail.example.com.
@    IN TXT "v=spf1 mx -all"
_dmarc IN TXT "v=DMARC1; p=none; rua=mailto:dmarc@example.com"
selector1._domainkey IN TXT "v=DKIM1; k=rsa; p=PUBLIC_KEY_FROM_PROVIDER"

Use values supplied by your email provider. DMARC p=none is for monitoring; it does not enforce blocking. Coordinate SPF, DKIM, and DMARC before changing them.

4. Query commands

dig is the most flexible tool on Linux and macOS. On Windows, use nslookup or Resolve-DnsName. Query only servers you are allowed to use.

Common queries

dig example.com A +noall +answer
dig example.com AAAA +noall +answer
dig example.com MX +noall +answer
dig example.com NS +noall +answer
dig @1.1.1.1 example.com A

Replace 1.1.1.1 with an authorized resolver if your network requires it. example.com data is public; the file addresses are reserved for examples.

Path and targeted checks

dig +trace www.example.com A
dig @ns1.example.com example.com SOA +norecurse
dig +tcp example.com A
dig -x 192.0.2.10

+trace follows delegations; +norecurse queries without requesting recursion; +tcp forces TCP; -x performs a reverse PTR lookup.

Windows commands

nslookup -type=A example.com
nslookup -type=AAAA example.com
Resolve-DnsName example.com -Type A

Resolve-DnsName is available in modern PowerShell. nslookup is included in many Windows installations.

5. Reading answers and errors

Check status, flags, and answer first. NOERROR does not guarantee that the requested type exists: an answer can be empty (NODATA).

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1234
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1
example.com. 300 IN A 192.0.2.10

This record is synthetic. AD means the resolver claims it validated the data with DNSSEC; trust the flag only if the resolver and path to it are trusted.

CodeReading
NOERRORThe query succeeded; the answer may still be empty (NODATA).
NXDOMAINThe requested name does not exist according to this answer.
SERVFAILThe server could not complete resolution or validation.
REFUSEDThe server rejected the query due to policy or access rules.
TimeoutNo reply in time: check network, firewall, path, and server health.

Useful flags

CodeReading
AAThe answer is authoritative for the zone.
RD / RARecursion requested by the client / recursion available on the server.
TCThe answer was truncated; the client may retry over TCP.
ADThe resolver claims the answer was validated with DNSSEC.

A compact answer example

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1234
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1
example.com. 300 IN A 192.0.2.10

This record is synthetic. AD means the resolver claims it validated the data with DNSSEC; trust the flag only if the resolver and path to it are trusted.

6. Caches, TTL, and delegations

Resolvers cache answers to reduce latency and load. Each cache expires data according to the TTL it saw when it obtained the answer.

  • TTL is measured in seconds: 3600 is one hour.
  • The displayed TTL is the remaining cache time; different resolvers can show different values.
  • A negative answer (NXDOMAIN/NODATA) can be cached using the zone SOA parameters.
  • Glue is an address published by the parent for an NS inside the delegated child zone. It breaks a resolution loop and is a starting hint, not the authoritative source for child data.
  • Before a service migration, lower the TTL ahead of time and wait at least the old TTL before changing the data.
  • NS delegation and the parent DS record have their own caches; changing the zone apex does not replace them.

7. DNSSEC: authenticity, not secrecy

DNSSEC lets a validating resolver check data origin and integrity along a trust chain. DNS data remains public.

RecordRole
DNSKEYThe zone public key.
KSK / ZSKTraditional roles: KSK signs the DNSKEY RRset; ZSK signs other RRsets. Some platforms manage keys differently.
RRSIGA signature over an RRset, verifiable with DNSKEY.
DSA digest of the child DNSKEY published in the parent; it links the chain levels.
NSEC / NSEC3Authenticated proof that names or record types are absent.

DS links the child key to the parent. Expired keys, missing signatures, or mismatched DS records can cause SERVFAIL on validating resolvers. NSEC/NSEC3 proves absence; it does not make the zone secret.

DNSSEC queries

dig example.com A +dnssec
dig example.com DNSKEY +dnssec
dig example.com DS
delv example.com A

+dnssec requests DNSSEC records but does not validate the chain by itself. delv performs validation when BIND tools are installed.

8. Encrypted transport and privacy

DoH, DoT, and DoQ protect the link between a device and its resolver. The chosen resolver can still see and log queries.

MethodWhat changes
DoTDNS over TLS; encrypts the client-resolver link, commonly over TCP/853.
DoHDNS over HTTPS; carries DNS inside HTTPS, commonly over TCP/443.
DoQDNS over QUIC; encrypted transport, commonly over UDP/853.
QNAME minimizationReduces the name shared with root and TLD servers during iterative resolution.
ECS / ODoHECS can expose part of a client network; ODoH separates relay and resolver under a different trust model.

Transport encryption is not anonymity: the resolver sees queries, and the visited site can often infer the destination. ODoH limits what one intermediary sees, subject to its trust model.

9. Threats and defensive controls

DNS defense needs controls on resolvers, authoritative servers, credentials, and the systems that consume DNS results.

RiskControl
Spoofing / cache poisoningForged answers try to poison a cache.Patch, randomize, validate DNSSEC, and monitor.
Open resolver / amplificationAn exposed recursive server can be abused or reflect traffic.Limit recursion and transfers to authorized clients; rate-limit and use upstream anti-spoofing.
Tunneling / DGAUnusual queries may hide data or contact malware-generated domains.Analyze rate, entropy, length, and reputation; use policy controls and incident response.
Dangling recordAn alias points to a cloud resource that is no longer assigned.Inventory records, remove stale aliases, and verify resource lifecycle.
DNS rebindingA name alternates between public and internal addresses.Applications should validate resolved IPs and block unexpected private or metadata ranges.
NXDOMAIN floodMany nonexistent names consume resolver resources.Monitor response codes, apply limits, and plan capacity and caching.

10. Change checklist

Plan each change like infrastructure work: check dependencies, timing, rollback, and health signals.

  1. 01Confirm owner, scope, approval, and change window.
  2. 02Export the current zone and record values needed for rollback.
  3. 03Check dependencies: NS, glue, MX, CAA, TXT, DNSSEC, and names used by other services.
  4. 04Lower TTL ahead of time; wait at least the old TTL before the planned change.
  5. 05Validate syntax and consistency: updated SOA serial, existing targets, and no conflicting CNAME.
  6. 06For DNSSEC, follow the provider procedure for publishing keys and DS in the correct order.
  7. 07Limit AXFR to authorized secondaries; TSIG authenticates and protects transfer integrity, but does not encrypt it.
  8. 08Check authoritative servers first, then multiple trusted resolvers; also check IPv4, IPv6, and mail.
  9. 09Monitor SERVFAIL, unexpected NXDOMAIN, latency, and application errors; keep a rollback procedure.

11. Quick troubleshooting

Compare authoritative and recursive answers, then narrow the issue to name, type, delegation, cache, network, or validation.

SymptomMeaning / check
NXDOMAINThe name is absent or the delegation/zone is wrong.Check spelling, parent NS, and the authoritative answer.
NOERROR with no answerThe name exists but not that type (NODATA).Request the right type and inspect the authoritative zone.
SERVFAIL on some resolversPossible DNSSEC, delegation, or reachability problem.Compare authority, DS/DNSKEY, and validation; do not blindly disable DNSSEC.
Old addressA cache still holds the previous value.Compare remaining TTL, resolver, and authority; do not flush caches at random.
TimeoutThe server or transport does not reply.Compare UDP and TCP, firewall, routing, NS, and authority availability.
Mail not deliveredMX or email authentication records may be inconsistent.Check MX, mail host A/AAAA, SPF, DKIM, and DMARC.

12. Ports and transports

Ports describe common transports; they do not prove which service is running or whether it is trustworthy.

PortTypical use
53 UDP/TCPTraditional DNS; TCP is also used for large answers and zone transfers.
853 TCPCommonly used by DNS over TLS (DoT).
853 UDPCommonly used by DNS over QUIC (DoQ).
443 TCP/UDPHTTPS/HTTP3; often used by DNS over HTTPS (DoH).
eLearner.app · DNS · DNS Cheatsheet