Closed alpominth closed 1 year ago
Blocky caches positive responses (response with answer section) and negative responses (only NXDOMAIN). In your case, there is no answer section and status is NOERROR.
Sorry, I forgot to set the option cacheTimeNegative: and I didn't know that it caches NXDOMAIN, it was my fault.
Thanks for the explanation.
Results from any DNS server:
$ dig @1.1.1.1 -t ptr g.co
; <<>> DiG 9.18.4-2ubuntu2-Ubuntu <<>> @1.1.1.1 -t ptr g.co
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64255
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;g.co. IN PTR
;; AUTHORITY SECTION:
g.co. 60 IN SOA ns1.google.com. dns-admin.google.com. 502341315 900 900 1800 60
;; Query time: 103 msec
;; SERVER: 1.1.1.1#53(1.1.1.1) (UDP)
;; WHEN: Tue Jan 17 01:04:32 EST 2023
;; MSG SIZE rcvd: 93
From cached Blocky:
$ dig @127.0.0.1 -p 53 -t ptr g.co
; <<>> DiG 9.18.4-2ubuntu2-Ubuntu <<>> @127.0.0.1 -p 53 -t ptr g.co
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5075
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;g.co. IN PTR
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)
;; WHEN: Tue Jan 17 01:05:48 EST 2023
;; MSG SIZE rcvd: 22
I know that this behavior is more aesthetic than practical in fact, but it would be a good idea to make Blocky cache queries with type different from the type queried, it would be more like a "normal" caching DNS proxy.
Easy to reproduce, just enable cache and test it:
The queried type was PTR and a SOA was returned:
When using a different DNS client such as dnsproxy and looking at the timings, you can perceive that the different returned query type was cached:
The same problem is showed when querying A type on a AAAA only hostname:
time dig @127.0.0.1 -p 53 -t A v6.testmyipv6.com
===============================================================
I think this behavior should be fixed.