Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache entire DNS response and not only the answer section #833

Closed
0xERR0R opened this issue Jan 20, 2023 · 2 comments · Fixed by #909
Closed

Cache entire DNS response and not only the answer section #833

0xERR0R opened this issue Jan 20, 2023 · 2 comments · Fixed by #909
Labels
🔨 enhancement New feature or request
Milestone

Comments

@0xERR0R
Copy link
Owner

0xERR0R commented Jan 20, 2023

Currently, blocky caches only the answer section from the DNS response.

It would be better to cache the entire DNS response (anser, authority section etc.).

@0xERR0R 0xERR0R added the 🔨 enhancement New feature or request label Jan 20, 2023
@alpominth
Copy link

I think this would be easy to implement, here an example with a little toy DNS app: https://github.com/orivej/dnscache

$ go install github.com/orivej/dnscache@latest

$ go/bin/dnscache -listen 127.0.0.1:1053 -upstream 1.1.1.1:53
2023/01/20 09:12:18.642838 87C2┐g.co. PTR IN
2023/01/20 09:12:18.871154 87C2└g.co. PTR IN = 
^C

user@localhost:~$ time dig @127.0.0.1 -p 1053 -t PTR g.co
; <<>> DiG 9.18.10-2-Debian <<>> @127.0.0.1 -p 1053 -t PTR g.co
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34754
;; 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.			46	IN	SOA	ns1.google.com. dns-admin.google.com. 503115268 900 900 1800 60
;; Query time: 227 msec
;; SERVER: 127.0.0.1#1053(127.0.0.1) (UDP)
;; WHEN: Fri Jan 20 09:12:18 EST 2023
;; MSG SIZE  rcvd: 107
real	0m0.250s
user	0m0.006s
sys	0m0.006s

$ time dig @127.0.0.1 -p 1053 -t PTR g.co
; <<>> DiG 9.18.10-2-Debian <<>> @127.0.0.1 -p 1053 -t PTR g.co
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56350
;; 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.			46	IN	SOA	ns1.google.com. dns-admin.google.com. 503115268 900 900 1800 60
;; Query time: 0 msec
;; SERVER: 127.0.0.1#1053(127.0.0.1) (UDP)
;; WHEN: Fri Jan 20 09:12:19 EST 2023
;; MSG SIZE  rcvd: 107
real	0m0.021s
user	0m0.004s
sys	0m0.006s

It's a pitty that I don't know how to code in Go, if not I could modify Blocky by myself.

@0xERR0R 0xERR0R added this to the 0.21 milestone Jan 24, 2023
@alpominth
Copy link

I noticed that Blocky doesn't cache the OPT pseudosection:

$ time dig @127.0.0.1 -p 1053 www.linux.bogus

; <<>> DiG 9.18.10-2-Debian <<>> @127.0.0.1 -p 1053 www.linux.bogus
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 32153
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;www.linux.bogus.		IN	A

;; AUTHORITY SECTION:
.			44469	IN	SOA	a.root-servers.net. nstld.verisign-grs.com. 2023012500 1800 900 604800 86400

;; Query time: 270 msec
;; SERVER: 127.0.0.1#1053(127.0.0.1) (UDP)
;; WHEN: Wed Jan 25 13:09:50 EST 2023
;; MSG SIZE  rcvd: 119


real	0m0.292s
user	0m0.006s
sys	0m0.006s
$ time dig @127.0.0.1 -p 1053 www.linux.bogus

; <<>> DiG 9.18.10-2-Debian <<>> @127.0.0.1 -p 1053 www.linux.bogus
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 30175
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.linux.bogus.		IN	A

;; Query time: 0 msec
;; SERVER: 127.0.0.1#1053(127.0.0.1) (UDP)
;; WHEN: Wed Jan 25 13:09:53 EST 2023
;; MSG SIZE  rcvd: 33


real	0m0.021s
user	0m0.007s
sys	0m0.004s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants