0

I am trying to configure a DNS cache with dnsmasq. The server responds to the query, but the response time is exactly the same as the Cloudflare DNS. To test the DNS Server I have removed any internet DNS Server from my computer and also in the dnsmasq config file.

Here my /etc/dnsmasq.conf

domain=raspberry.local
resolv-file=/etc/resolv.dnsmasq
min-port=4096
cache-size=10000

I have tried for example:

dig facebook.it

and the Query time is circa 85 msec, end this is the exactly tile that I have if I use Clodflare DNS. maybe there is something that I don't understand, but I think that a Query time should be less than 10 msec if I use a local cache DNS.

Here the content of the file /etc/resolv.conf

# Generated by resolvconf
# Domain
search xxxxxxx
# CloudFlare Servers
nameserver 1.1.1.1
nameserver 1.0.0.1
search lan
nameserver 127.0.0.1

I don't try 127.0.0.1 because I use the DNS server on raspberry pi for the rest of lan. I have tried dig facebook.com and the response arrive from 192.168.100.5 that is the raspberry pi LAN IP


Here the content of the file /etc/resolv.conf

# Generated by resolvconf
# Domain
search xxxxxxx
# CloudFlare Servers
nameserver 1.1.1.1
nameserver 1.0.0.1
search lan
nameserver 127.0.0.1

I don't try 127.0.0.1 because I use the DNS server on raspberry pi for the rest of lan. I have tried dig facebook.com and the response arrive from 192.168.100.5 that is the raspberry pi LAN IP

0

If you really want to use your dnsmasq as caching DNS and also allow the rest of the LAN to connect to it:

Remove the upstream nameservers from your resolv.conf:

# Generated by resolvconf
# Domain
search xxxxxxx
search lan
nameserver 127.0.0.1

You don't need the cloudflare DNS servers here. You can add them in the configuration files that dnsmasq uses. Then, configure dnsmasq in dnsmasq.conf as follows:

domain=raspberry.local
resolv-file=/etc/resolv.dnsmasq
min-port=4096
cache-size=10000
listen-address=<your_local_ip_address_here>
bind-interfaces
port=53

Now, to use the upstream nameservers you want (for example the Cloudflare one), add them to /etc/resolv.dnsmasq:

nameserver 1.1.1.1

Afterwards, simply restart dnsmasq, and you should be done:

sudo systemctl restart dnsmasq

0

I have followed your instructions and this is the results.

1 - To remove the content of the resolve.conf file I modified the file resolve.conf.head file that I have modified because may ISP router has only a DNS Proxy, so, to give an other DNS to the raspberry IP I had added it in the file resolve.conf.head

2 - This is the resolve.conf file generated automatically at boot:

# Generated by resolvconf
search lan
nameserver 127.0.0.1

3 - I modify the rest of configuration as you have indicated.

4 - Here 3 subsequent test to dig facebook.com, you can see that the quay times are 80msec, 3msec and 85msec, I have noted also that the response to the dig command is instantaneous when the quay time si 80-85msec, but much longer for the 3msec quay time:

minilan:~ paolo$ dig facebook.com

; <<>> DiG 9.10.6 <<>> facebook.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27874
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;facebook.com.          IN  A

;; ANSWER SECTION:
facebook.com.       109 IN  A   31.13.86.36

;; Query time: 80 msec
;; SERVER: 192.168.100.5#53(192.168.100.5)
;; WHEN: Fri Nov 30 16:58:42 CET 2018
;; MSG SIZE  rcvd: 57

minilan:~ paolo$ dig facebook.com

; <<>> DiG 9.10.6 <<>> facebook.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44541
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;facebook.com.          IN  A

;; ANSWER SECTION:
facebook.com.       103 IN  A   31.13.86.36

;; Query time: 3 msec
;; SERVER: 192.168.100.5#53(192.168.100.5)
;; WHEN: Fri Nov 30 16:58:48 CET 2018
;; MSG SIZE  rcvd: 57

minilan:~ paolo$ dig facebook.com

; <<>> DiG 9.10.6 <<>> facebook.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14477
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;facebook.com.          IN  A

;; ANSWER SECTION:
facebook.com.       54  IN  A   31.13.86.36

;; Query time: 85 msec
;; SERVER: 192.168.100.5#53(192.168.100.5)
;; WHEN: Fri Nov 30 16:59:38 CET 2018
;; MSG SIZE  rcvd: 57
  • Ok after several proof I have discovered that dnsmasq runs for the local 127.0.0.1 raspberry pi dig test, with quay time like 1 or 2 msec. For other device the time increase, but in any case less than the previous time. – Paolo Bertolli Dec 1 '18 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.