Run your own dnsmasq in tandem with libvirtd and NetworkManager
blog.grobinson.net
blog.grobinson.net
You can also replace your routers firmware with OpenWRT. OpenWRT uses dnsmasq by default (and allows you to customize the configuration, of course), so you don't even have to use a separate server.
/etc/dnsmasq.d/network-manager:
bind-interfaces
interface=lo
/etc/systemd/resolved.conf:
[Resolve]
DNS=127.0.0.1 ::1
/etc/nsswitch.conf:
passwd: compat
group: compat
shadow: compat
hosts: files mymachines gw_name myhostname mdns4_minimal resolve [NOTFOUND=return] dns mdns4
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
They are so many as I also have the packages libnss-myhostname libnss-mymachines libnss-gw-name libnss-mdns. Important to note is the NOTFOUND=return directive after resolve, because libnss-resolved is not available on Debian yet and thus it's going to query dnsmasq directly instead of first resolved (which is also using dnsmasq anyway).
http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/200...
Before every new dns entry was naively compared sequentially with current dataset, the fix was probably a hashtable.
But then I tried to search online and at least try to understand what it actually is, what it does or is supposed to do, or what it doesn't do and so on. Then I thought that running bind9 might be easier, at least I know what it's supposed to do.
I finally decided to leave it the way it came with my Ubuntu. Some articles say it's there to act as a dns cache and something else with VPNs while other articles claim the caching functionality is turned off by default. Really confusing for somebody who's not that experienced.
Oh well.