Skip to content
Buy me a coffee

DNS

tag: networkingtag: beginners
  1. Your computer checks its own memory (its cache) and its hosts file. That file is where localhost is defined (see 127.0.0.1 and localhost).
  2. If it doesn’t know the answer, it asks a resolver, usually run by your router or internet provider.
  3. 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.
  4. The answer comes back with a TTL (time to live): how long everyone may cache it.

DNS mostly runs over UDP port 53.

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
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.

  • 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.com can 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