Reading — step 1 of 5
Read
~1 min readRecord Types & Lookups
Zone Files & Authoritative Lookups
A zone file lists the records an authoritative server holds for a zone:
$TTL 86400
$ORIGIN example.com.
@ SOA ns1.example.com. admin.example.com. (
2024010101 ; serial
3600 ; refresh
600 ; retry
86400 ; expire
300 ) ; minimum
@ NS ns1.example.com.
@ NS ns2.example.com.
ns1 A 192.0.2.10
ns2 A 192.0.2.11
@ A 192.0.2.1
www A 192.0.2.1
api A 192.0.2.20
www AAAA 2001:db8::1
mail MX 10 mailhost.example.com.
mailhost A 192.0.2.30
@ TXT "v=spf1 mx -all"
The @ symbol means "the zone's apex" (example.com.). A bare hostname (www) means www.example.com.. Trailing dots distinguish FQDN from relative names.
Authoritative lookup:
def lookup(name, type):
records = zone[name]
matching = [r for r in records if r.type == type]
return matching # may be 0, 1, or many records
Special cases:
- A query for
example.com Areturns the apex A records. - A query for
*.example.com A(wildcard) matches anything not explicitly listed (some zones use this). - A CNAME response means "follow this alias" — the resolver should chase it.
Authoritative servers don't recurse. They only answer for zones they're authoritative for. If they don't know, they return RCODE=3 NXDOMAIN.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…