By default Ubuntu does indeed cache DNS entries with Dnsmasq. Dnsmasq does a lookup when a DNS entry is not in its cache, which is why you'll always see the localhost
(127.0.0.1
) IP address when doing a DNS lookup without specifying the nameserver.
In the manpage it's explained as follows:
Dnsmasq accepts DNS queries and either answers them from a small,
local, cache or forwards them to a real, recursive, DNS server. It
loads the contents of /etc/hosts so that local hostnames which do not
appear in the global DNS can be resolved and also answers DNS queries
for DHCP configured hosts.
This behaviour can be overridden by editing /etc/NetworkManager/NetworkManager.conf
and changing dns=dnsmasq
to #dns=dnsmasq
, after which you'll need to restart the network-manager service (sudo service network-manager restart
).
More information can be found in the community documentation and in the manpage.
dns=dnsmasq
line? – Douglas Gaskell Feb 28 '19 at 23:50systemd-resolved
in version 17.04. See: https://askubuntu.com/questions/907246/how-to-disable-systemd-resolved-in-ubuntu – Silke Mar 06 '19 at 11:19