1

I set up a DNS server using dnsmasq, but it seems that it doesn't work properly. The networking delay is up to hundreds of millisecs.

PING [server] ([server]) 56(84) bytes of data.
64 bytes from [server]: icmp_seq=1 ttl=50 time=583 ms
64 bytes from [server]: icmp_seq=2 ttl=50 time=583 ms
64 bytes from [server]: icmp_seq=3 ttl=50 time=583 ms
64 bytes from [server]: icmp_seq=4 ttl=50 time=583 ms
64 bytes from [server]: icmp_seq=5 ttl=50 time=583 ms
64 bytes from [server]: icmp_seq=6 ttl=50 time=583 ms
64 bytes from [server]: icmp_seq=7 ttl=50 time=583 ms
64 bytes from [server]: icmp_seq=8 ttl=50 time=583 ms

Then soon I discovered that it'll turn all right with using the default resolver systemd-resolved. By checking the log, I got the messages here below:

Jul 27 13:32:53 dnsmasq[3780]: query[A] ntp.ubuntu.com from 127.0.0.1
Jul 27 13:32:53 dnsmasq[3780]: forwarded ntp.ubuntu.com to 127.0.0.53
Jul 27 13:32:53 dnsmasq[3780]: query[A] ntp.ubuntu.com from 127.0.0.1
Jul 27 13:32:53 dnsmasq[3780]: forwarded ntp.ubuntu.com to 127.0.0.53
[countless records repeating these above...]
Jul 27 13:32:53 dnsmasq[3780]: Maximum number of concurrent DNS queries reached (max: 150)
Jul 27 13:32:54 dnsmasq[3780]: query[A] ntp.ubuntu.com from 127.0.0.1
Jul 27 13:32:54 dnsmasq[3780]: forwarded ntp.ubuntu.com to 127.0.0.53
[...]
[probably the sigterm was sent here?]
Jul 27 13:32:57 dnsmasq[3780]: query[A] ntp.ubuntu.com from 127.0.0.1
Jul 27 13:32:57 dnsmasq[3780]: forwarded ntp.ubuntu.com to 127.0.0.53
Jul 27 13:32:58 dnsmasq[3780]: no servers found in /run/dnsmasq/resolv.conf, will retry
Jul 27 13:32:58 dnsmasq[3780]: query[A] ntp.ubuntu.com from 127.0.0.1
Jul 27 13:32:58 dnsmasq[3780]: query[A] ntp.ubuntu.com from 127.0.0.1
Jul 27 13:32:58 dnsmasq[3780]: query[A] ntp.ubuntu.com from 127.0.0.1
Jul 27 13:32:58 dnsmasq[3780]: query[A] ntp.ubuntu.com from 127.0.0.1
Jul 27 13:32:58 dnsmasq[3780]: query[A] ntp.ubuntu.com from 127.0.0.1
Jul 27 13:32:58 dnsmasq[3780]: exiting on receipt of SIGTERM

So.. How to resolve this problem which makes me crazy, plz :(

The content from dnsmasq.conf is here:

strict-order
resolv-file=/etc/resolv.conf.dnsmasq
listen-address=0.0.0.0
server=/aliyuncs.com/100.100.2.136
server=/aliyuncs.com/100.100.2.138
server=/*.cn/100.100.2.136
server=/*.cn/100.100.2.138

bogus-nxdomain=100.100.2.136
bogus-nxdomain=100.100.2.138

log-queries
log-facility=/var/log/dnsmasq/dnsmasq.log
log-async=50

#EOF

And resolv.conf.dnsmasq:

nameserver 100.100.2.136
nameserver 100.100.2.138
nameserver 208.67.222.123
nameserver 208.67.220.123
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 1.2.4.8
nameserver 210.2.4.8
nameserver 208.67.222.222
nameserver 208.67.220.220

resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
options timeout:2 attempts:3 rotate single-request-reopen
  • It looks like that all the requests which wants the result of ntp.ubuntu.com are redirected to 127.0.0.53... but it's the same host with 127.0.0.1... isn't it? – Joseph Lee Jul 27 '19 at 06:10
  • 1
    since systemd-resolved listen on 127.0.0.53, id try to make dnsmasq listen on 127.0.0.1 -- See https://askubuntu.com/questions/1032450/how-to-add-dnsmasq-and-keep-systemd-resolved-18-04 – cmak.fr Jul 27 '19 at 06:12

1 Answers1

3

Resolved. Just simply add an entry bind-interfaces to dnsmasq.conf and start the two DNS resolvers.
And make sure that systemd-resolved listens on 127.0.0.53:53.

[resolv.conf]

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.1
options timeout:2 attempts:3 rotate single-request-reopen

[netstat -apn | grep 53]

tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      10122/dnsmasq       
tcp        0      0 172.18.129.180:53       0.0.0.0:*               LISTEN      10122/dnsmasq       
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      10066/systemd-resolved 
udp        0      0 127.0.0.1:53            0.0.0.0:*                           10122/dnsmasq       
udp        0      0 172.18.129.180:53       0.0.0.0:*                           10122/dnsmasq       
udp        0      0 127.0.0.53:53           0.0.0.0:*                           10066/systemd-resolved 
unix  3      [ ]         STREAM     CONNECTED     590253   1121/master

[dnsmasq.log]

Jul 28 12:31:57 dnsmasq[10122]: query[A] www.stackexchange.com from 127.0.0.1
Jul 28 12:31:57 dnsmasq[10122]: forwarded www.stackexchange.com to 127.0.0.53
Jul 28 12:31:57 dnsmasq[10122]: reply www.stackexchange.com is <CNAME>
Jul 28 12:31:57 dnsmasq[10122]: reply stackexchange.com is 151.101.129.69
Jul 28 12:31:57 dnsmasq[10122]: reply stackexchange.com is 151.101.193.69
Jul 28 12:31:57 dnsmasq[10122]: reply stackexchange.com is 151.101.65.69
Jul 28 12:31:57 dnsmasq[10122]: reply stackexchange.com is 151.101.1.69

[nslookup www.stackexchange.com]

Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
www.stackexchange.com   canonical name = stackexchange.com.
Name:   stackexchange.com
Address: 151.101.193.69
Name:   stackexchange.com
Address: 151.101.1.69
Name:   stackexchange.com
Address: 151.101.65.69
Name:   stackexchange.com
Address: 151.101.129.69
  • Congratulations on finding the answer and sharing it! +1 :-) Note: You did not install a DNS Server, you installed a DNS Forwarder. Look into bind9 if you want to install an actual server. ;-) – Fabby Jul 27 '19 at 07:38
  • 1
    @Fabby thx, :-D – Joseph Lee Jul 27 '19 at 09:31