I was probably trying to confirm whether a change to my domain had taken effect. Suppose you’ve changed a website’s A record (the IPv4 address associated with a name) from an old server to a new one. Your computer still loads the old page, but a phone on mobile data shows the new version. Three addresses matter: the IP currently published by the domain’s authoritative servers, the IP returned by the local resolver, and the IP this HTTPS request actually connected to.
How do I confirm that the authoritative servers have published the change?
Write down the full hostname you changed and the expected new address. example.com and www.example.com can have different records. I’ll use www.example.com, with 192.0.2.10 as the old IPv4 address and 192.0.2.20 as the new one. These are documentation addresses. Substitute your site’s actual values.
host=www.example.com
dig +trace "$host." A
+trace makes your local dig ask each layer in turn, starting at the root. The root delegates .com, .com delegates example.com, and the domain’s authoritative server gives the final answer. In the output, NS identifies who is responsible for the next level. Received ... from shows who answered that round. The recursive resolver you normally use queries on a client’s behalf and can return cached answers, so this trace cannot reconstruct each hop of your earlier browser query. If your network allows only designated DNS servers, +trace can time out. Try verification from a network that permits direct authoritative queries.1
Choose the authoritative servers from the parent zone’s NS list and query each one. Substitute their actual names below. The trailing dot denotes a fully qualified name, and +norecurse asks only for information held by that server.
auth=ns1.example.net
dig @"$auth" "$host." A +norecurse
Look in two places. The aa flag means the server gave an authoritative answer. In ANSWER SECTION, read the record type and address. For example:
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; ANSWER SECTION:
www.example.com. 300 IN A 192.0.2.20
Here 300 is the TTL. The answer can normally be cached for 300 seconds. If every authoritative server returns the expected new IP, the record has been published. If one returns the old IP and another the new, check the DNS provider’s zone data and synchronization. If you changed DNS providers too, pay particular attention to the parent zone’s NS list. Even if you entered the correct A record in the new provider’s console, visitors may still reach old records while the parent delegates to the old provider.1
Why does my computer still get the old address when authority returns the new IP?
dig "$host." A
dig "$host." AAAA
getent ahosts "$host"
The first two commands query the default DNS server for IPv4 (A) and IPv6 (AAAA). Record the server address shown by SERVER, then read ANSWER SECTION. A CNAME points to another domain name. Follow the alias to the final address. If the A record changed but AAAA still points to the old server, IPv6-capable clients may continue opening the old site.
Suppose default DNS returns www.example.com. 82 IN A 192.0.2.10, but an authoritative query a moment ago returned 192.0.2.20. This is consistent with an old cached answer having about 82 seconds left. After that time, query the same resolver again. Lowering the TTL only during migration may leave existing caches counting down the original TTL. For a public domain, dig @1.1.1.1 "$host." A gives another observation point. For an internal company domain, query the appropriate internal DNS instead.2
getent ahosts displays addresses available to applications that use Linux’s system name resolution interface. If it gives the old address while dig gives the new one, inspect the hosts: line of /etc/nsswitch.conf and check /etc/hosts for manual mappings. If dig shows 127.0.0.53 as SERVER, run resolvectl status on a machine using systemd-resolved to see upstream DNS servers and domains for each interface and VPN. If the problem is confined to a browser, check its secure DNS, proxy, and browser cache.34
When a page request fails, should I check DNS or the new server?
On a network that permits direct access to the website, make the same HTTPS request twice. Resolve normally the first time, then specify the new IP for that request alone. If the fault affects a particular path, use that path both times.
new_ip=192.0.2.20 # 换成部署时确认的新 IPv4
url="https://$host/"
curl --noproxy '*' -v --max-time 10 -o /dev/null "$url"
curl --noproxy '*' -v --max-time 10 -o /dev/null \
--resolve "$host:443:$new_ip" "$url"
Both commands use --noproxy '*' so you can observe the direct connection from this machine. The URL retains the original domain so the server can choose the matching site certificate and curl can still verify the hostname. Visiting https://新IP/ (the new IP directly) changes the identity under verification. Find the peer IP after Connected to, then read the certificate verification result and the status line beginning < HTTP/.5
| Observation | What to check next |
|---|---|
The normal request reports Could not resolve host, while the forced new IP gives the expected response | The new endpoint is reachable from this machine. Check the default dig status. NXDOMAIN means the queried name or an alias target doesn’t exist. If NOERROR returns no records of the requested type, check A and AAAA. SERVFAIL means the resolver failed to process the query, so compare with an authoritative answer. For a timeout, start by checking DNS server reachability.6 |
| The normal request connects to the old IP, but forcing the new one opens the new version | Compare default DNS, system resolution, and authoritative answers to find where the old address remains. To distinguish deployments, omit -o /dev/null and fetch a static file that differs between them. |
Both requests reach the new IP and pass certificate verification but return 502 | This request reached an HTTP gateway. Check the new endpoint’s reverse proxy logs and whether it can connect to the backend. |
One Wi-Fi network resolves the domain to an unfamiliar IP. How do I investigate DNS hijacking?
Suppose your public site has only ever had the old and new addresses, but one Wi-Fi network returns an unfamiliar third address. DNS hijacking can redirect a query to another resolver or replace its answer, potentially steering later connections to another site. Record the unexpected address and identify the first query path on which it appears.7
dig "$host." A
dig @8.8.8.8 "$host." A
curl --noproxy '*' --fail --silent --show-error --max-time 10 \
--resolve dns.google:443:8.8.8.8 \
"https://dns.google/resolve?name=$host&type=A"
The first command asks the resolver configured on the current network. The second and third both specify Google Public DNS. The second uses ordinary DNS, which can still be redirected en route. The third uses HTTPS (DoH), pins the connection address, and checks the certificate for dns.google. Read Status and Answer in the JSON: Status: 0 means success, and the data of an answer with type: 1 is an IPv4 address. Repeat on the same computer using a trusted phone hotspot, keeping VPN and proxy settings the same. If IPv6 is affected, change both dig invocations and the type in the URL to AAAA and inspect type: 28 in the JSON.8
| Comparison across the two networks | What to check next |
|---|---|
| Only the Wi-Fi default resolver returns the unfamiliar IP, and both public DNS queries on the same network return the expected address | Check DNS distributed by the router, captive portals, and company split-horizon policies. If the answer is the address just replaced, recheck according to the old record’s TTL. |
Even dig @8.8.8.8 on Wi-Fi returns the unfamiliar IP, but the HTTPS query and hotspot queries match the authoritative configuration | Investigate the ordinary DNS path. Run dig @8.8.8.8 test.dns.google.com. TXT on both networks. Google’s diagnostic instructions say to expect “Thanks for using Google Public DNS.” If only Wi-Fi returns NXDOMAIN, that supports the query having been handled by another resolver. A single timeout only establishes that no response arrived.7 |
| An authoritative query from the hotspot also returns the unfamiliar IP | Check parent NS delegation with the registrar, then review records and change logs at the DNS provider. If you use a content delivery network (CDN), first check whether ordinary regional routing explains the address. |
When DNS answers look wrong, how can I tell if HTTPS is affected too?
On the affected Wi-Fi, use the earlier site-access commands to test the default address and the new IP established during deployment. If the default request reaches the unfamiliar address and its certificate does not match the domain, while forcing the new IP passes verification and gives the expected page, you can correlate the DNS anomaly, actual peer, and access symptom. Keep query times, DNS answers, peer IPs, and certificate errors so a network administrator can check for unauthorized redirection. Stop before logging in if the certificate raises a warning. A certificate warning alone does not establish that a third party read the HTTPS traffic.
If the forced new IP reports the same hostname mismatch on both networks, first check whether the new site has the right certificate. Keep certificate verification enabled throughout the comparison. curl -k skips that crucial check.5
Footnotes
-
Internet Systems Consortium. (n.d.). dig — DNS lookup utility(BIND 9.18.24,Query Options 中的
+trace与+recurse). BIND 9 Administrator Reference Manual. dig 手册 ↩ ↩2 -
Mockapetris, P. (1987, November). Domain names — concepts and facilities (RFC 1034, §3.6). RFC Editor. Resource Records ↩
-
Linux man-pages project. (n.d.). getent(1)(DESCRIPTION,ahosts). man7.org. 系统名称查询接口 ↩
-
systemd project. (n.d.). resolvectl(1)(COMMANDS,status). man7.org. 按接口查看 DNS 配置 ↩
-
The curl project. (n.d.). Name resolve tricks. Everything curl. Provide a custom IP address for a name ↩ ↩2
-
Andrews, M. (1998, March). Negative caching of DNS queries (DNS NCACHE) (RFC 2308, §§2.1–2.2). RFC Editor. Name Error 与 No Data ↩
-
Google. (2024, September 3). Troubleshooting(“DNS blocking and hijacking”,macOS or Linux 命令后的第 1 段). Google Public DNS. 检查查询是否到达指定解析器 ↩ ↩2
-
Google. (2024, September 3). JSON API for DNS over HTTPS (DoH). Google Public DNS. 查询参数与 JSON 回答格式 ↩