DNS records and caching
A record answers a particular question
A resource record has an owner name, type, class (normally IN for Internet), time to live (TTL, in seconds) and type-specific data. A set of records at the same owner, class and type is an RRset. DNS is not limited to IP addresses: different queries can return different record types. An A record holds IPv4; AAAA holds IPv6. CNAME points from an alias to a canonical name; at that owner it generally cannot coexist with ordinary other record data. MX identifies a mail exchanger; smaller preference values are preferred, not necessarily geographically closer.
Read a fictional zone
This illustrative zone is unsigned and has no delegated child. Names end in a dot to make them absolute. SOA carries zone administration data including serial and timers; NS identifies authoritative servers. TXT stores text for applications. SRV specifies priority, weight, port and target for applications that use it (lower priority first, weight distributes among equal-priority targets). A target of MX or SRV should not be a CNAME alias. The addresses are documentation-only. Do not deploy the example or query the public domain to reproduce it.
example.com. 300 IN SOA ns.example.com. hostmaster.example.com. 2026112701 3600 600 86400 120example.com. 300 IN NS ns.example.com.ns.example.com. 300 IN A 192.0.2.53www.example.com. 300 IN A 192.0.2.20www.example.com. 300 IN AAAA 2001:db8::20shop.example.com. 60 IN CNAME www.example.com.example.com. 300 IN MX 10 mail.example.com.mail.example.com. 300 IN A 192.0.2.25example.com. 300 IN TXT "classroom-only"_chat._tcp.example.com. 300 IN SRV 10 5 5222 chat.example.com.chat.example.com. 300 IN A 192.0.2.30Follow aliases and reverse names
An A lookup for shop.example.com follows its CNAME to www.example.com and obtains 192.0.2.20. An AAAA lookup instead obtains 2001:db8::20. The alias and address RRsets have separate TTLs. Reverse IPv4 lookups reverse the octets and append in-addr.arpa; for 192.0.2.20 the PTR owner is 20.2.0.192.in-addr.arpa. IPv6 reverse lookup reverses individual hexadecimal digits of the full 32-digit address under ip6.arpa. PTR data belongs to a separately managed reverse zone; an A record does not automatically create a PTR.
Calculate positive and negative cache lifetime
In a simple cache with no refresh, prefetch, stale serving or local TTL cap, an A record received at t=0 with TTL 300 has 180 seconds remaining at t=120 and expires at t=300. The CNAME with TTL 60 expires earlier; a later request may refresh the alias while the address is still cached. A zone change does not instantly invalidate copies already cached. Negative caching also stores authoritative nonexistence of a name (NXDOMAIN) or absence of a requested type (NODATA). With SOA TTL 300 and SOA MINIMUM 120, the initial negative TTL is normally min(300,120)=120 seconds, subject to resolver policy. Resolution failures such as SERVFAIL have separate caching rules (RFC 9520), not this SOA calculation.
Plan a change without guessing
At t=45, how much time remains for the CNAME and A received at t=0? Answer: 15 and 255 seconds. At t=60 the alias expires while the A remains usable for 240 seconds. Lowering TTL before a planned change can reduce future cached lifetime only after old caches have aged out. Compare an MX query with an A query; neither proves mail delivery works. See RFC 1035, RFC 2308, RFC 3596 and RFC 2782. Next: diagnose DNS errors and security.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
DNS records and caching — knowledge check
Apply DNS concepts to synthetic records and recorded scenarios.
Which record type gives the IPv6 address of www.example.com?
An MX lookup returns preference 10 and preference 30. Which is preferred?
A record with TTL 300 was cached 170 seconds ago with no refresh. How many seconds remain?
What is the IPv4 PTR owner for 192.0.2.25?
SOA TTL is 300 and SOA MINIMUM is 120. What is the initial ordinary negative TTL before local caps?