Sub topic 3
DNS Messages and Transport over UDP and TCP
Assume you understand IPv4 and IPv6 addresses, client-server communication, ports, and basic terminal commands.
DNS messages and transport
A DNS message contains a header and several sections:
- Question: the name and record type being requested.
- Answer: records that directly answer the question.
- Authority: servers or records that provide a referral.
- Additional: useful related records, such as name-server addresses.
The header includes flags. RD requests recursion, RA shows that recursion is available, and AA means the answer came from an authoritative server. TC means the response was truncated.
DNS normally uses UDP port 53 because UDP has low overhead. If the response is too large, the client can retry over TCP port 53. TCP is also used for zone transfers between authoritative servers.
Reverse DNS and PTR records
A reverse DNS lookup maps an IP address back to a name. IPv4 addresses are reversed under in-addr.arpa; IPv6 addresses use ip6.arpa. The lookup asks for a PTR record, which stores the reverse name.
dig -x 192.0.2.10 +noall +answerReverse DNS is useful for logging and diagnostics, but it is not proof of a host's identity.
Querying and debugging with `dig`
dig displays the question, answer, authority, and additional sections. The number before a record's class is its remaining TTL.
dig example.com A
dig +short example.com AAAA
dig @8.8.8.8 example.com A
dig +trace example.comUse @server to compare resolvers and +trace to follow delegation from the root.
Record changes and the propagation myth
DNS changes do not spread at one fixed speed. Recursive resolvers keep answers until their TTL expires. A high TTL can make an old address remain visible for hours. Negative caching can also preserve a failed lookup. “Propagation” usually means different caches expiring at different times.
Threats and protections
An attacker may spoof replies, poison a resolver's cache, or observe unencrypted DNS queries. DNSSEC adds digital signatures so a validating resolver can detect altered or forged DNS data. It authenticates DNS data, but does not encrypt the query.
DoT, or DNS over TLS, encrypts DNS between a client and resolver over TCP port 853. DoH, or DNS over HTTPS, sends DNS through HTTPS, usually on port 443. Both protect the client-to-resolver connection, but neither by itself proves that every DNS record is authentic.
Exercise
Which mechanism detects forged DNS records, and which mechanisms encrypt the client-to-resolver connection?
Show answer
DNSSEC detects forged or altered records. DoT and DoH encrypt the client-to-resolver connection.