“It works by IP but not by name” means DNS. Query records directly with dig and nslookup to see exactly what a name resolves to — and whether it resolves at all.
Why: if a site loads by IP but not by name, the network is fine and DNS is the problem — separating the two is a five-second test that saves chasing the wrong layer. When: any "some sites don’t load" or "intermittent" complaint. Where: query a name directly rather than trusting the browser, which caches aggressively.
dig google.com # the modern tool (Linux/macOS)
nslookup google.com # everywhere, including Windows
# A quick answer with an IP = DNS works. No answer / timeout = DNS is
# the problem (wrong resolver, unreachable resolver, or bad record).Why: DNS holds different record types — A (IPv4), AAAA (IPv6), MX (mail), CNAME (alias), NS (nameservers), TXT — and problems are often specific to one type (mail down = check MX, not A). When: query the exact record relevant to the issue. Where: the DNS Servers topic in the roadmap lists these record types; dig shows them directly.
dig example.com A # IPv4 address
dig example.com AAAA # IPv6 address
dig example.com MX # mail servers (troubleshoot email delivery)
dig example.com NS # authoritative nameservers
dig example.com TXT # SPF/DKIM/verification records
dig +short example.com A # just the answer, no noiseWhy: the same name can resolve differently depending on WHICH DNS server you ask, and stale caches cause "it changed but I still get the old IP" — querying a specific resolver and checking TTL settles it. When: compare your local resolver against a public one (8.8.8.8) to spot a bad or poisoned local cache. Where: the TTL in the answer tells you how long the record is cached before a re-query.
# Ask a SPECIFIC resolver — compare local vs. a public one:
dig @8.8.8.8 example.com +short # Google's resolver
dig @1.1.1.1 example.com +short # Cloudflare's resolver
# See the full answer incl. TTL (how long it's cached):
dig example.com
# If your local resolver disagrees with a public one, suspect a stale
# or misconfigured local cache. Flush it and re-test.