The default CloudFlare TTL for NX (non-existing) records is about three hours, which is a bit of a bummer if I accidentally query a DNS name I haven't created yet. The CloudFlare API calls to create and edit records make no mention of the NX record. Is there some way to set this?
2 Answers
It is controlled by the "negative TTL" field (last field) in the SOA record for the zone in question. Can't help you more since you didn't provide any domain name(s).
Edit --
But as an example, if the domain name is something-of-yours.cloudflare.com, here's where the non-existent cache value comes from (below). It's the last value returned in the SOA record, that is the negative-caching TTL field, and it's 3600 (seconds) = 1 hour in this case.
Whoever is the admin for the zone cloudflare.com (first field ot the SOA) controls this value, and the e-mail address is apparently dns@cloudflare.com.
Notice there is no "NX" record returned, there's no such thing.
$ dig something-of-yours.cloudflare.com
; <<>> DiG 9.10.0rc2-1+b1-Debian <<>> something-of-yours.cloudflare.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51707
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;something-of-yours.cloudflare.com. IN A
;; AUTHORITY SECTION:
cloudflare.com. 3600 IN SOA ns3.cloudflare.com. dns.cloudflare.com. 2020742566 10000 2400 604800 3600
;; Query time: 121 msec
- 2,030
The answer unfortunately is that Cloudflare does not allow the NX TTL to be changed. Today, the value is 1 hour.
$ dig soa my-domain-on-cloudflare.com
; <<>> DiG 9.10.6 <<>> soa my-domain-on-cloudflare.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59079
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;my-domain-on-cloudflare.com. IN SOA
;; ANSWER SECTION:
my-domain-on-cloudflare.com. 3600 IN SOA daisy.ns.cloudflare.com. dns.cloudflare.com. 2030614699 10000 2400 604800 3600
;; Query time: 38 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Apr 05 12:16:45 EDT 2019
;; MSG SIZE rcvd: 102
- 362