SSH Connection Problem: Can't Connect to Server
SSH connection troubleshooting guide: Path.net firewall rules, Default Block, creating a filter rule for SSH port, and step-by-step troubleshooting.
Comprehensive guide to diagnosing and resolving DNS issues using dig, nslookup commands, DNS propagation checks, cache clearing, and common DNS error solutions.
DNS (Domain Name System) is one of the fundamental components of internet infrastructure. This system translates domain names to IP addresses, and when it doesn't work correctly, many services including website access, email delivery, and server connections can be disrupted.
In this guide, we'll examine the tools and methods you can use to diagnose and resolve DNS issues in detail.
| Record Type | Description | Example |
|---|---|---|
| A | IPv4 address mapping | example.com → 1.2.3.4 |
| AAAA | IPv6 address mapping | example.com → 2001:db8::1 |
| CNAME | Alias to another domain | www → example.com |
| MX | Mail server routing | mail.example.com (priority: 10) |
| TXT | Text record (SPF, DKIM, etc.) | v=spf1 ip4:1.2.3.4 -all |
| NS | Nameserver definition | ns1.example.com |
| PTR | Reverse DNS record | 4.3.2.1 → example.com |
| SOA | Zone authority record | TTL, serial, refresh info |
User → Local DNS Cache → Recursive Resolver → Root NS → TLD NS → Authoritative NS → IP Address
dig (Domain Information Groper) is the most powerful tool for diagnosing DNS issues.
# Query A record
dig example.com A
# Query from a specific DNS server
dig @8.8.8.8 example.com A
# Short output
dig example.com +short
# Query all record types
dig example.com ANY
# Query MX record
dig example.com MX
# Query NS record
dig example.com NS
# Query TXT record
dig example.com TXT
# Trace mode — shows resolution process step by step
dig example.com +trace
# SOA record — zone information
dig example.com SOA
# Reverse DNS query
dig -x 1.2.3.4
# Query over TCP (for large responses)
dig example.com +tcp
# DNSSEC validation
dig example.com +dnssec
$ dig example.com A
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 300 IN A 93.184.216.34
;; AUTHORITY SECTION:
example.com. 86400 IN NS ns1.example.com.
;; Query time: 23 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; MSG SIZE rcvd: 56
Key fields:
nslookup is a simpler tool for DNS queries:
# Basic query
nslookup example.com
# Query from specific DNS server
nslookup example.com 8.8.8.8
# MX record query
nslookup -type=MX example.com
# NS record query
nslookup -type=NS example.com
# TXT record query
nslookup -type=TXT example.com
# Reverse DNS
nslookup 1.2.3.4
When DNS changes are made, it takes time for new records to propagate to all DNS servers.
| Record Type | Typical TTL | Propagation Time |
|---|---|---|
| A / AAAA | 300-3600 sec | 5 min - 1 hour |
| MX | 3600-86400 sec | 1 - 24 hours |
| NS | 86400 sec | 24 - 48 hours |
| TXT | 300-3600 sec | 5 min - 1 hour |
# Google DNS
dig @8.8.8.8 example.com A +short
# Cloudflare DNS
dig @1.1.1.1 example.com A +short
# Quad9 DNS
dig @9.9.9.9 example.com A +short
# Local ISP DNS
dig example.com A +short
Online propagation check tools:
To speed up DNS propagation, lower the TTL value before making changes (e.g., 300 seconds). You can increase the TTL again after the change is complete.
# Linux (systemd-resolved)
sudo systemd-resolve --flush-caches
sudo resolvectl flush-caches
# macOS
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# Windows
ipconfig /flushdns
# BIND named cache clearing
sudo rndc flush
# For a specific zone
sudo rndc flushname example.com
# Unbound cache clearing
sudo unbound-control flush_zone example.com
To clear DNS cache in Chrome browser:
chrome://net-internals/#dns → Clear host cache
$ dig nonexistent.example.com
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN
Causes:
Solution:
# Check domain WHOIS information
whois example.com
# Check nameservers
dig example.com NS +short
# Query from authoritative NS
dig @ns1.example.com example.com A
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL
Causes:
Solution:
# Check nameserver reachability
dig @ns1.example.com example.com A
# Check DNSSEC status
dig example.com +dnssec
# Try with a different resolver
dig @1.1.1.1 example.com A
Causes:
Solution:
# Clear cache
sudo systemd-resolve --flush-caches
# Query directly from authoritative NS
dig @ns1.example.com example.com A +short
# Check resolution path with trace
dig example.com +trace
Causes:
Solution:
# Measure DNS response time
dig example.com | grep "Query time"
# Compare different DNS servers
for dns in 8.8.8.8 1.1.1.1 9.9.9.9; do
echo "$dns: $(dig @$dns example.com +short +stats | grep 'Query time')"
done
# Update /etc/resolv.conf
sudo nano /etc/resolv.conf
nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 9.9.9.9
For persistent DNS settings, use systemd-resolved or NetworkManager configuration instead of directly editing /etc/resolv.conf.
# Zone transfer test
dig @ns1.example.com example.com AXFR
# Restrict zone transfer (named.conf)
zone "example.com" {
type master;
file "/etc/bind/zones/example.com.zone";
allow-transfer { SLAVE_IP; };
};
#!/bin/bash
# DNS Troubleshooting Script
DOMAIN="example.com"
echo "=== DNS Troubleshooting: $DOMAIN ==="
# 1. Nameserver check
echo -e "\n[1] Nameservers:"
dig $DOMAIN NS +short
# 2. A record check
echo -e "\n[2] A Record:"
dig $DOMAIN A +short
# 3. MX record check
echo -e "\n[3] MX Record:"
dig $DOMAIN MX +short
# 4. TXT record check
echo -e "\n[4] TXT Records:"
dig $DOMAIN TXT +short
# 5. SOA record check
echo -e "\n[5] SOA Record:"
dig $DOMAIN SOA +short
# 6. Check from different DNS servers
echo -e "\n[6] Propagation Check:"
for dns in 8.8.8.8 1.1.1.1 9.9.9.9; do
result=$(dig @$dns $DOMAIN A +short)
echo " $dns → $result"
done
# 7. Reverse DNS check
IP=$(dig $DOMAIN A +short | head -1)
if [ -n "$IP" ]; then
echo -e "\n[7] Reverse DNS ($IP):"
dig -x $IP +short
fi
echo -e "\n=== Check Complete ==="
DNS issues are among the most common problems in server management. By effectively using dig and nslookup tools, you can quickly diagnose issues, track propagation processes, and resolve cache problems. Remember to lower TTL values before DNS changes and verify from different DNS servers after changes.
DNS propagation time depends on the TTL value. With low TTL (300 sec), changes can propagate in 5-30 minutes. With high TTL (86400 sec), it can take 24-48 hours. NS record changes typically take the longest.
Ubuntu/Debian: sudo apt install dnsutils, CentOS/RHEL: sudo yum install bind-utils, macOS: Install with Homebrew using brew install bind.
Your ISP's DNS server may still be caching the old record. Test using Google DNS (8.8.8.8) or Cloudflare DNS (1.1.1.1). Also remember to clear your browser's DNS cache.
Check that the domain hasn't expired using whois. Verify nameservers are correctly configured with dig domain.com NS. Check that the DNS record exists on the authoritative nameserver with dig @ns1.domain.com domain.com A.
On Linux, you can change your DNS server by editing /etc/resolv.conf or updating the systemd-resolved configuration. For persistent changes, it's recommended to use NetworkManager or netplan configuration.
SSH connection troubleshooting guide: Path.net firewall rules, Default Block, creating a filter rule for SSH port, and step-by-step troubleshooting.
RDP connection troubleshooting guide: Path.net firewall rules, Default Block, creating a filter rule for RDP port, and step-by-step troubleshooting.
Guide to running MTR network tests with WinMTR and Linux MTR, creating ICMP filter rules, and submitting results to support. Diagnose packet loss and latency.