Skip to content

Chapter 2 of 8

DNS and Name Resolution

DNS is the addressing layer of the internet, and Linux administrators must understand its record types. An A record maps a domain to an IPv4 address, AAAA to IPv6, and CNAME creates an alias pointing to another canonical name. Mail delivery relies on MX records pointing to the responsible mail servers, while NS records designate the authoritative nameservers and SOA marks the start of authority zone with administrative information. Reverse DNS uses PTR records to map IPs back to hostnames, which is critical for mail servers since many receivers reject mail from IPs lacking valid reverse entries. Email authentication is reinforced by TXT records carrying SPF (which mail servers may send for the domain), DKIM (cryptographic signatures), and DMARC (policy for handling failures).

For diagnosing DNS, dig is the preferred tool because it provides detailed query output, unlike the simpler nslookup. Common invocations include dig TYPE domain to query a specific type, dig @nameserver domain to query a specific resolver, dig +short for compact answers, dig +trace to walk the full resolution path from the root servers, and dig -x IP for reverse lookups. TTL controls how long a record is cached, with 300 to 3600 seconds typical for production records and lower values like 60 to 300 seconds advisable 24 to 48 hours before a migration to speed propagation. Global propagation can be checked via online services such as dnschecker.org or whatsmydns.net, which query multiple geographic locations.

Local name resolution happens before DNS. /etc/hosts provides static hostname-to-IP mappings useful for overrides or local-only entries, while /etc/resolv.conf configures the resolver's nameservers and search domains. /etc/nsswitch.conf defines the order in which resolution sources are consulted (files, dns, ldap, and so on), and getent hosts hostname performs lookups using the configured chain, while getent passwd username retrieves user information from all sources. On systems using systemd-resolved, resolvectl status shows per-interface DNS settings and search domains, while resolvectl flush-caches clears cached entries. Caches on other operating systems can be cleared with ipconfig /flushdns on Windows or sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder on macOS.

All chapters
  1. 1SSH, Remote Access, and File Transfer
  2. 2DNS and Name Resolution
  3. 3Systemd, Logging, and Scheduled Tasks
  4. 4Users, Permissions, and Linux Security
  5. 5Storage, Filesystems, and LVM
  6. 6Networking, Firewalls, and Diagnostics
  7. 7Web Servers, SSL/TLS, and Hosting Panels
  8. 8Process Management, Performance, and Containers

Drill it

Reading is not remembering. These come from the Sysadmin Cards deck:

Q

What is the purpose of the <code>~/.ssh/config</code> file?

It allows users to define shortcuts and configuration options (like Hostname, User, Port, IdentityFile) for SSH connections.

Q

What are the recommended permissions for the <code>~/.ssh/authorized_keys</code> file?

600 (read/write for owner only).

Q

What is a DNS <b>CNAME</b> record?

A Canonical Name record that maps one domain name (alias) to another domain name (canonical).

Q

What is a DNS <b>MX</b> record?

A Mail Exchange record that specifies the mail server responsible for accepting email messages on behalf of a domain.