DNS
tag: networkingtag: beginners
How a lookup works
Section titled “How a lookup works”- Your computer checks its own memory (its cache) and its hosts file. That file is where
localhostis defined (see 127.0.0.1 and localhost). - If it doesn’t know the answer, it asks a resolver, usually run by your router or internet provider.
- The resolver asks around: the root servers point it to the servers for
.com, and those point it to the domain’s own authoritative server, which has the answer. - The answer comes back with a TTL (time to live): how long everyone may cache it.
DNS mostly runs over UDP port 53.
Record types
Section titled “Record types”| Record | Holds | Example use |
|---|---|---|
| A | An IPv4 address | example.com → its IPv4 address |
| AAAA | An IPv6 address | The same, for IPv6 |
| CNAME | Another name (an alias) | www points at the main name |
| MX | The mail server for a domain | Where email for the domain goes |
| TXT | Free text | Email security settings, domain ownership checks |
| NS | The domain’s authoritative servers | Who answers for the domain |
| PTR | A name for an IP (reverse lookup) | Which name an address belongs to |
Try it
Section titled “Try it”| System | Command |
|---|---|
| macOS, Linux | dig example.com or nslookup example.com |
| Windows (PowerShell) | Resolve-DnsName example.com |
Ask for a specific record with dig example.com MX or Resolve-DnsName example.com -Type MX.
Why analysts care
Section titled “Why analysts care”- DNS logs show intent. A machine looking up a malicious domain is often the first sign of infection, even if the connection that follows is blocked.
- Strange names stand out. Long random-looking names such as
kq3v9xz7hd2.comcan come from a domain generation algorithm (DGA), which malware uses to make thousands of possible server names. - Data can hide in DNS. Lots of long, unusual lookups to one domain can be data being smuggled out inside the names themselves (DNS tunneling).
- History helps. Passive DNS services record which IPs a domain pointed to over time, so you can link infrastructure together.
- Defang domains in reports. Write
bad-domain[.]com.
Packets: what all of this looks like on the wire.

One Reverse Look
"A little learning is a dangerous thing." ~ A. Pope
One Reverse Look · Made with ❤ · Your friendly knowledge seeker

