Networking · foundation
Domain Name System (DNS)
The Domain Name System is a distributed, hierarchical database and query protocol that stores typed records under domain names. Resolvers commonly use it to obtain addresses, mail-routing data, aliases, and other information needed by applications.
Why it matters
A valid URL can fail before any transport connection if name resolution is wrong. Record type, resolver configuration, caching, delegation, and TTL all affect what an application sees.
Mental model
How to reason about domain name system (dns)
A stub resolver asks a recursive resolver, which can follow referrals through the DNS hierarchy and cache answers for their allowed lifetime. The answer is a typed record set, not a permanent one-to-one mapping from name to server.
Analogy
DNS resembles a distributed directory service: a local assistant can consult responsible directories and cache an answer, but each entry has a type and an expiration policy.
Examples
See the boundary, not just the happy path
Worked example · Query IPv4 address records
dig +short A example.comThis asks for A records and prints concise answer data. A domain can return multiple addresses, no A records, or different cached results over time.
Worked example · Inspect delegation path
dig +trace example.comdig performs iterative-style queries starting from root-server information, revealing delegation toward the authoritative zone. It bypasses the normal single recursive-resolver experience and is a diagnostic view, not an application's usual lookup.
Useful contrast · Local name sources can precede DNS
getent hosts internal-apiOn systems using Name Service Switch, getent follows configured sources such as /etc/hosts and DNS. An application using the system resolver may therefore get an answer that a direct dig query does not show.
Common mistakes
Misconceptions to remove early
Assuming every domain name has one IP address
Names can have multiple A and AAAA records, aliases, or no address records. Load distribution and geo-aware responses can also vary the returned set.
Expecting a DNS update to appear everywhere immediately
Resolvers and applications can cache previous data according to TTL and local policy. Delegation and negative answers can be cached too.
Quick check
Can you predict the result?
1. What does a DNS TTL primarily tell a caching resolver?
- • How long it may cache that record data before treating it as expired.
- • How long an HTTP request may keep its TCP connection open.
- • How many IP addresses the name is allowed to have.
2. Why can getent hosts and dig return different results for the same name?
Keep building