I wish to clear my local DNS cache so that I can access a server via a domain name which has recently had its DNS A record changed. For illustration purposes, lets assume the following:
Domain: mydomain.com
Old IP address 111.111.111.111
New IP address 222.222.222.222
Everything seems to be updated at my ISP's DNS and on my router's DNS cache:
$ dig @<ISP DNS> mydomain.com
;; ANSWER SECTION:
mydomain.com. 7186 IN A 222.222.222.222
$dig @<router>
;; ANSWER SECTION:
mydomain.com. 7186 IN A 222.222.222.222
The local cache however, is not updated:
$ dig mydomain.com
;; ANSWER SECTION:
mydomain.com. 7186 IN A 111.111.111.111
;; SERVER: 127.0.0.53#53(127.0.0.53)
Clearing the local cache seems to work, but only temporarily:
$ systemd-resolve --statistics;systemd-resolve --flush-caches;systemd-resolve --statistics
Cache
Current Cache Size: 1
Cache Hits: 12222
Cache Misses: 6507
<omitted>
Cache
Current Cache Size: 0
Cache Hits: 12222
Cache Misses: 6507
$ dig mydomain.com
;; ANSWER SECTION:
mydomain.com. 7186 IN A 222.222.222.222
;; SERVER: 127.0.0.53#53(127.0.0.53)
However, after some time, seemingly at random, I can no longer access the server via the domain name. Running dig
again shows that the local cache has reverted back while the router and ISP's entries have remained correct:
$ dig mydomain.com
;; ANSWER SECTION:
mydomain.com. 7186 IN A 111.111.111.111
;; SERVER: 127.0.0.53#53(127.0.0.53)
$ dig @<ISP DNS> mydomain.com
;; ANSWER SECTION:
mydomain.com. 7186 IN A 222.222.222.222
$dig @<router>
;; ANSWER SECTION:
mydomain.com. 7186 IN A 222.222.222.222
I have not figured out how to reliably reproduce the problem. The first time, it reverted overnight. Today it reverted within a few seconds. In between, I have tried accessing the domain name via Firefox which has sometimes correctly loaded the site, and sometimes not (following which a check of the local DNS cache shows it has reverted).
Any suggestions would be most welcome.