DNS and Name Resolution
Quick answer
Name resolution maps names to addresses through configured sources. DNS is one such source; Linux applications may also use local files and NSS.
Prepare the practice environment
Run python3 lab-fixtures/networking/setup.py from the extracted package root as an ordinary user. Enter the printed private path and check pwd. Use a fresh fixture, Bash with LC_ALL=C and set -o pipefail. Python 3 is required for the fixed local socket helper. Use only loopback or synthetic data; never apply sample configuration. Manual examples require an authorized disposable VM.
How it works
A records represent IPv4 addresses, AAAA records IPv6, and CNAME records aliases. getent uses NSS and may consult files, DNS or other services. dig and host query DNS directly, so a hosts-file mapping can appear in getent but not dig. NXDOMAIN differs from timeout and from a successful answer without the requested record type. resolvectl applies to systemd-resolved, not every distribution. A resolved address does not prove a TCP connection or TLS validation succeeds.
If an application resolves a name but a DNS query does not, first compare which source each tool consults. A successful response with no AAAA answer need not mean the name does not exist: it may have only an A record. A timeout is a missing response, not a negative answer. Record the queried name, record type, resolver and response status before drawing a conclusion.
Try the examples
getent -s files ahostsv4 localhost | awk 'NR==1 {print $1}'Explicit files service avoids external DNS.
Expected stdout:
127.0.0.1Synthetic records demonstrate type differences; no query is transmitted.
Expected stdout:
app.example. A 192.0.2.10app.example. AAAA 2001:db8::10missing.example. NXDOMAINExtract only the AAAA value from this fixture, not arbitrary dig output.
Expected stdout:
2001:db8::10Common mistakes
Do not overwrite resolv.conf or switch DNS servers blindly; identify the resolver and distinguish missing records from transport failures.
Practice
Use the fictional DNS records to explain A, AAAA and NXDOMAIN. In an authorized lab only, compare getent with dig @127.0.0.1 if a DNS service has been configured.
Related references
Study: getent, dig, host, resolvectl. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
DNS and name resolution — Knowledge Check
Apply network concepts to loopback, synthetic fixtures and VM-only scenarios.
Which record represents IPv6?
What does NXDOMAIN indicate?
Which uses NSS?
Does successful lookup prove HTTP works?