How can I tell which DNS servers DNSMasq is using?

Solution 1:

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.

Solution 2:

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

Solution 3:

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

journalctl -u dnsmasq

Solution 4:

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.