Resolved dnsmasq low performance

DNS

I use dnsmasq which is open source light weight DNS server.

However I am a bit irritated its slow performance when accessing my Nextcloud welcome page.

This is how to resolve this problem.

As a conclusion I could improve about 2 seconds to display Nextcloud welcome page!

How to resolve

My dnsmasq configuration didn't support AAAA record.
So I configured to be able to reply AAAA query.

That’s it!

Detail

This is a part of my /var/log/syslog.
dnsmasq forwards AAAA to 192.168.1.1 and waits 2 seconds.
This is why I need to wait my Nextcloud welcome page.

nslookup yasufumi-yokoyama.gq
(tail -f /var/log/syslog by another terminal)
Jun  2 20:29:45 raspberrypi dnsmasq[26771]: query[A] yasufumi-yokoyama.gq from 1234:567:89:abcd:ef01:2345:6789:abcd
Jun  2 20:29:45 raspberrypi dnsmasq[26771]: /etc/hosts yasufumi-yokoyama.gq is 192.168.1.123
Jun  2 20:29:45 raspberrypi dnsmasq[26771]: query[AAAA] yasufumi-yokoyama.gq from 1234:567:89:abcd:ef01:2345:6789:abcd
Jun  2 20:29:45 raspberrypi dnsmasq[26771]: forwarded yasufumi-yokoyama.gq to 192.168.1.1
Jun  2 20:29:45 raspberrypi dnsmasq[26771]: query[AAAA] yasufumi-yokoyama.gq from 1234:567:89:abcd:ef01:2345:6789:abcd
(Wait 2 seconds)
Jun  2 20:29:47 raspberrypi dnsmasq[26771]: query[AAAA] yasufumi-yokoyama.gq from 1234:567:89:abcd:ef01:2345:6789:abcd
Jun  2 20:29:47 raspberrypi dnsmasq[26771]: forwarded yasufumi-yokoyama.gq to 1234:567:89:abcd:ef01:2345:6789:abcd
Jun  2 20:29:47 raspberrypi dnsmasq[26771]: forwarded yasufumi-yokoyama.gq to 1234:567:89:abcd:ef01:2345:6789:abcd
Jun  2 20:29:47 raspberrypi dnsmasq[26771]: forwarded yasufumi-yokoyama.gq to 192.168.1.1
Jun  2 20:29:47 raspberrypi dnsmasq[26771]: query[AAAA] yasufumi-yokoyama.gq from 1234:567:89:abcd:ef01:2345:6789:abcd
Jun  2 20:29:47 raspberrypi dnsmasq[26771]: forwarded yasufumi-yokoyama.gq to 1234:567:89:abcd:ef01:2345:6789:abcd
Jun  2 20:29:47 raspberrypi dnsmasq[26771]: forwarded yasufumi-yokoyama.gq to 1234:567:89:abcd:ef01:2345:6789:abcd
Jun  2 20:29:47 raspberrypi dnsmasq[26771]: forwarded yasufumi-yokoyama.gq to 192.168.1.1
Jun  2 20:29:47 raspberrypi dnsmasq[26771]: reply error is REFUSED



This is the case of dig which doesn’t send query AAAA so it’s fast!

dig yasufumi-yokoyama.gq
(tail -f /var/log/syslog by another terminal)
Jun  2 20:28:34 raspberrypi dnsmasq[26771]: query[A] yasufumi-yokoyama.gq from 1234:567:89:abcd:ef01:2345:6789:abcd
Jun  2 20:28:34 raspberrypi dnsmasq[26771]: /etc/hosts yasufumi-yokoyama.gq is 192.168.1.123



But if the option for AAAA is added to dig it’s slow as well as nslookup.

dig <domain name> aaaa



I added configuration to /etc/hosts to be used by dnsmasq for AAAA record like this.

1234:567:89:abcd:ef01:2345:6789:abcd    yasufumi-yokoyama.gq
1234:567:89:abcd:ef01:2345:6789:abcd    www.yasufumi-yokoyama.gq

Of course please don’t forget to restart.

sudo service dnsmasq restart
# or
sudo systemctl restart dnsmasq



You can find your IPv6 address by ifconfig.

$ ifconfig eth0
(snip)
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.123  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 1234:567:89:abcd:ef01:2345:6789:abcd  prefixlen 64  scopeid 0x20<link>
        inet6 1234:567:89:abcd:ef01:2345:6789:abcd  prefixlen 64  scopeid 0x0<global>
        ether 12:34:56:78:90:ab  txqueuelen 1000  (Ethernet)
        RX packets 1622897  bytes 962296354 (917.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 13
        TX packets 668903  bytes 324940192 (309.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

This is ip command.

ip -6 addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
    inet6 1234:567:89:abcd:ef01:2345:6789:abcd/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 2591942sec preferred_lft 604742sec
    inet6 1234:567:89:abcd:ef01:2345:6789:abcd/64 scope link 
       valid_lft forever preferred_lft forever



That’s it!
2 seconds wait will be removed!

How to output debug log by dnsmasq

I configured to add debug log to syslog by adding these lines to /etc/dnsmasq.conf.

log-queries
log-facility=local0

Conclusion

how was it?

Your web server performance may be able to improve by this!

Author
yatch

I am Japanese software engineer having over 15 years career in embedded system software.
I have worked for designing/quality assurance products which has embedded linux.
I love Raspberry Pi.
I am also interested in stock market.
I married Hong Konger as international marriage.

Please follow me
DNSdnsmasq
Please follow me
The World's Linux Journal

Comments

タイトルとURLをコピーしました