looterz / grimd

:zap: fast dns proxy that can run anywhere, built to black-hole internet advertisements and malware servers
MIT License
1.39k stars 108 forks source link

No recursion/flattening for CNAME resolution for custom records #113

Open cottand opened 1 year ago

cottand commented 1 year ago

With the following custom records config (other config params mostly defaults):

customdnsrecords = [
    "example.memez         3600      IN  A       0.0.0.1",
    "example.different     3600      IN  CNAME   example.memez",
]

It seems when looking up example.different replies do not contain A 0.0.0.1 in the answer section.

dig output:

❯ dig @10.8.0.1 example.different

; <<>> DiG 9.10.6 <<>> @10.8.0.1 example.different
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40343
;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;example.different.     IN  A

;; ANSWER SECTION:
example.different.  3600    IN  CNAME   example.memez.

;; Query time: 86 msec
;; SERVER: 10.8.0.1#53(10.8.0.1)
;; WHEN: Wed Aug 09 14:17:51 WEST 2023
;; MSG SIZE  rcvd: 79

nslookup output:

❯ nslookup example.different
Server:     10.8.0.1
Address:    10.8.0.1#53

Non-authoritative answer:
example.different   canonical name = example.memez.

❯ nslookup example.memez
Server:     10.8.0.1
Address:    10.8.0.1#53

Non-authoritative answer:
Name:   example.memez
Address: 0.0.0.1

Not flattening is fine for some OSs (MacOS in my case does not mind) but on a Docker image (grafana/grafana:9.4.7) I found it to not be fine, resulting in the following:

# on grafana/grafana:9.4.7
/usr/share/grafana # ping example.different
ping: bad address 'example.different'

/usr/share/grafana # ping example.memez
PING example.memez (0.0.0.1): 56 data bytes
--- example.memez ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

# on MacOS
❯ ping example.different
PING example.memez (0.0.0.1): 56 data bytes
ping: sendto: No route to host
Request timeout for icmp_seq 0

So as you can see it can't recurse, maybe because the image is based on alpine?

Other DNS servers (like blocky) do flatten custom DNS but do not allow specyfing the records themselves (SRV, CNAME...) but grimd is the only one I have found that allows specifying custom DNS records and does adblocking. So I would love for this to work.