Monday, March 25, 2024

Cloudflare DNS flapping

I saw something interesting with DNS today.

I updated my DNS record, then immediately queried Cloudflare DNS (1.1.1.1) and it would switch between the old and new IPs for a while before settling on the new IP. 

[linux 2024-Mar-25 09:56:43]$ host -v mydomain.com
Trying "mydomain.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56089
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;mydomain.com.                    IN      A

;; ANSWER SECTION:
mydomain.com.             60      IN      A       127.0.0.1

Received 44 bytes from 1.1.1.1#53 in 5 ms

[linux 2024-Mar-25 09:56:46]$ host -v mydomain.com
Trying "mydomain.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63287
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;mydomain.com.                    IN      A

;; ANSWER SECTION:
mydomain.com.             60      IN      A       10.0.0.1

Received 44 bytes from 1.1.1.1#53 in 5 ms

Pretty interesting behavior.

My best guess is that different DNS servers are answering my query each time. I guess some nameservers get updated faster than other ones, and sometimes my queries are answered by one nameserver while at other times it's being answered by other nameservers. Some of the nameservers have the old IP while others have the new IP, hence the flapping behavior you see here. 

I don't know where exactly the flapping is taking place. Maybe Cloudflare internally uses some kind of load balancing mechanism that distributes DNS queries to different machines each time (or randomly)? Don't know.

In any case, this dashes my dreams of using 1.1.1.1 for instantaneous reliable DDNS, because it seems that sometimes the DNS change is not instantaneously reflected in the host/dig output and sometimes it flaps between the old and the new IP. Sadge.

 


No comments:

Post a Comment