SadServers
  • Scenarios
  • Labs
    All Labs Linux & Bash Web Servers Databases Data Processing Docker Kubernetes CI/CD Infrastructure as Code Tooling / Applications
  • Dashboard
  • Solutions
    For Individuals For Businesses
  • Ranking
  • Newsletter
  • Documentation
    FAQ Support Pro Accounts Pro+ Accounts Business Accounts Gift API CLI/TUI Privacy Troubleshooting Interviews
  • Blog
  • Pricing
  • Gift
    Gift Purchase Gift Redeem
  • About
Log In - Sign Up
  1. Labs
  2. DNS
  3. Cheatsheet

Guide

Concepts and learning path

Troubleshooting

Failure modes and fixes

Cheatsheet

Commands to keep handy

DNS cheatsheet

Query tools

CommandDescription
dig example.comDNS lookup with full response
dig +short example.com AJust the A record answer
dig @8.8.8.8 example.comQuery a specific nameserver
dig +trace example.comFollow delegation from root
host example.comSimple forward lookup
nslookup example.comInteractive / legacy lookup tool
dig -x 93.184.216.34Reverse DNS (PTR) lookup

Record lookups

CommandDescription
dig example.com MXMail exchanger records
dig example.com TXTTXT records (SPF, verification)
dig example.com NSNameserver delegation
dig example.com AAAAIPv6 address records
dig example.com CNAMECanonical name (alias)
dig example.com SOAZone authority metadata

System resolver

Command / fileDescription
cat /etc/resolv.confActive nameservers and search domains
cat /etc/hostsStatic hostname overrides
grep hosts /etc/nsswitch.confResolution order (files vs dns)
resolvectl statussystemd-resolved DNS config per link
resolvectl query example.comResolve via systemd-resolved
systemctl status systemd-resolvedCheck resolver service
getent hosts example.comResolve using NSS (same path as apps)

Connectivity checks

CommandDescription
ping -c1 example.comICMP after DNS resolution
curl -v https://example.comHTTP with TLS and resolved IP in verbose output
nc -zv example.com 443TCP connect test after resolve
dig +time=2 +tries=1 @NS example.comQuick timeout test to a nameserver

Example /etc/resolv.conf

nameserver 10.0.0.2 search internal.example.com example.com options ndots:1 timeout:2

Example /etc/hosts override

127.0.0.1 localhost 10.0.1.50 db.internal.example.com db

Pro tips

  • Use getent hosts to test the same path your application uses — not just dig
  • dig @server bypasses local resolver config; useful to isolate upstream vs local issues
  • Check /etc/hosts first when one machine resolves differently from others
  • Always use FQDNs in production configs to avoid search-domain surprises

Practice scenarios

Hands-on DNS scenarios on live Linux VMs: dns

SadServersSadServers

Real-world Linux and DevOps scenarios for hands-on learning and technical assessment.

Uptime Robot ratio (30 days)
Product
  • Scenarios
  • For Individuals
  • For Businesses
  • Pricing
Resources
  • FAQ
  • Blog
  • Newsletter
Company
  • About Us
  • Support
  • Privacy Policy
  • Terms of Service
  • Contact
Connect With Us
info@sadservers.com

Made in Canada 🇨🇦
Updated: 2026-06-13 16:06 UTC – 2d2950a