31

How can I tell which DNS servers DNSMasq is using to resolve a name to an IP address? I can't figure it out. All of the existing questions here seem to just go as far as telling users that they are using DNSMasq.

17

You can find the DNS servers with the NetworkManagerCLI (nmcli) tool:

nmcli dev show | grep DNS
IP4.DNS[1]:                             172.22.216.251
IP6.DNS[1]:                             2a01:4f0:400c:1::1

Ubuntu 14.04 and older

The command is slightly different in older (<15.04) versions of Ubuntu:

> nmcli dev list | grep DNS
IP4.DNS[1]:                             172.22.216.251
IP6.DNS[1]:                             2a01:4f0:400c:1::1
  • Don't you mean nmcli dev show? – einpoklum Jan 29 '16 at 17:34
  • @einpoklum: No. On my 14.04 box, nmcli dev show gives: Error: 'dev' command 'show' is not valid. – Peter V. Mørch Jan 29 '16 at 18:42
  • On my Lubuntu 15.10 I get the opposite. – einpoklum Jan 29 '16 at 18:42
20

For a more generic answer when you are using dnsmasq without network manager and with several upstream DNS :

sh# kill -USR1 <PID OF DNSMASQ>
sh# tail /var/log/syslog

Upon receiving SIGUSR1, dnsmasq will log various statistics, including the number of DNS request send to each upstream server. Based on that, you can easily determine the most frequently used DNS server on your system.

  • 4
    Also, when any changes are made to the connection (e.g. connecting to VPN), dnsmasq logs these to /var/log/syslog: dnsmasq[xxx]: setting upstream servers from DBus dnsmasq[xxx]: using nameserver 10.xx.xx.xx#53(via tun0) dnsmasq[xxx]: using nameserver 192.xx.xx.x#53(via wlp2s0) – Mike Demenok Aug 28 '17 at 23:45
  • This is a better answer because it tells you which servers were actually used as opposed to just which servers are configured to be used. – Jonah Braun Sep 12 '17 at 16:20
  • Thanks, your answer gave me a hint to look into the logs, I used sudo journalctl -b -u dnsmasq | grep nameserver. – selurvedu Jan 12 '18 at 21:21
2

Generally, for the system using systemd, the DNS servers dnsmasq is using can be found via

journalctl -u dnsmasq

  • This does not work when dnsmasq is launched by NetwokrManager (and configuration is passed via dbus) – Taha Jahangir Sep 27 '18 at 5:17
0

On Ubuntu 15.04 the command is:

$ nmcli dev show | grep DNS
IP4.DNS[1]:                             8.8.8.8
0

In package:

network-manager 0.9.8.8-0ubuntu7.2 amd64 

The command is:

root@D-MIS-001:~# nmcli dev list | grep DNS
IP4.DNS[1]:                             172.16.10.173
IP4.DNS[2]:                             172.16.10.133

This is what seems to be the current package version for Ubuntu 14.04 LTS. The correct command for 15.* may have changed.

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.