Skip to content
Resource Records
step 1/5

Reading — step 1 of 5

Read

~1 min readRecord Types & Lookups

Resource Records

Answer / Authority / Additional sections all use the same Resource Record (RR) format:

+----------+
| NAME     |   encoded name (often a pointer)
+----------+
| TYPE     |   16-bit
+----------+
| CLASS    |   16-bit (= IN normally)
+----------+
| TTL      |   32-bit seconds
+----------+
| RDLENGTH |   16-bit length of RDATA
+----------+
| RDATA    |   variable; format depends on TYPE
+----------+

RDATA per type:

  • A (1): 4 bytes (the IPv4 address)
  • AAAA (28): 16 bytes (the IPv6 address)
  • NS (2): an encoded domain name
  • CNAME (5): an encoded domain name
  • MX (15): 16-bit preference + encoded domain name
  • TXT (16): one or more length-prefixed text strings
  • SOA (6): primary NS + admin email + serial + refresh + retry + expire + minimum TTL

The TTL governs caching: how many seconds the answer is valid before re-querying. Typical: 300s (5 min). Production DNS for a high-traffic site might be 60s or even 30s.

For this lesson: encoding/decoding A and CNAME records.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…