I want to get fast dns resolution with dnsmasq and keep the default systemd-resolved.
Looking for an elegant way to do this
I want to get fast dns resolution with dnsmasq and keep the default systemd-resolved.
Looking for an elegant way to do this
I wanted to get fast dns resolution with dnsmasq and keep the default systemd-resolved/NetworkManager setup untouched for future use. Yes the huge dns caching of dnsmasq can improve browsing speed. Yes the goal was to keep the default featured dns setup of 18.04
1 - With sudo
2 - With sudo
3 - With USER, configure NetworkManager
4 - Check verify
I have a specific use case that works great. I run dnsmasq on my LAN router (an Ubuntu server machine, with no systemd-resolved), and let the LAN machines behind the router default to vanilla systemd-resolved DNS resolution. It's all possible and works elegantly, with a few tweaks to dnsmasq:
Now I can stand up a gazillion Ubuntu VMs inside my LAN and never have to fiddle with DNS any more - it just works.
The tweaks are required because systemd-resolved does not allow you to use "single-label" host names (with no dot in them), unlike dnsmasq and "classic DNS". Once you get dnsmasq to automatically extend LAN host names into FQDNs, everything is happy. This took me a LONG time to figure out, btw. These systemd-resolved issues 1 2 helped me crack the problem.
I tried to find a reasonable solution and looks that there are different approaches.
I wanted to stay at most within the distribution layout while keeping all business requirements fulfilled. This is what I collected around and tested to work on clean Ubuntu 18.04 and KDE Neon flavour:
(please note that the only general difference with the above answers is that the NetworkManager handle the dnsmasq DNS server assignments automatically
As you know, Docker copy host /etc/resolv.conf file to containers but removing any local nameserver.
My solution to this problem is to keep using systemd-resolvd and NetworkManager but add dnsmasq and use it to "forward" Docker containers DNS queries to systemd-resolvd.
Step by step guide:
For more info see my post (in spanish) https://rubensa.wordpress.com/2020/02/07/docker-no-usa-los-mismos-dns-que-el-host/
Ubuntu 18.10
IMHO, if your going to be running dnsmasq, you should statically assign your ip address instead of getting it from dhcp. This way you can just disable systemd-resolved all together.
sudo apt-get install dnsmasq
sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved
Manually assign your ip address, gateway, and assign the ip address to your machine as DNS.
configure /etc/dnsmasq.conf (really...RTFM --> man dnsmasq.conf)
sudo systemctl enable dnsmasq
sudo systemctl status dnsmasq
point dhcp on your dhcp server to your shiny new dnsmasq server (..if yumpto)