You can do it with systemd-netowrkd and systemd-resolved. I'm assuming your local dnsmasq instance is the DNS server for your network, and that your computer is not a router for your LAN.
First, undo any changes in /etc/nsswitch.conf and /etc/systemd/resolved.conf. Recreate the /etc/resolve.conf symlink
dnsmasq will need to do ALL the DNS resolution for you network. Most routers have a DNS proxy, so if your router is 192,168.1.1, you need to add that as a "server=" in the dnsmaqs config file
Now there may be a problem: Both dnsmaqs and the systemd stub resolver can listen on localhost:53. Either make sure dnsmasq doesn't bind to bind to localhost, OR set "DNSStubListener=no" in /etc/systemd/resolved.conf
Now in /etc/systemd/network/10-home.network, it should look something like this:
Code: Select all
[Match]
Name=enp3s0
[Network]
DHCP=yes
DNS= # This clears any previous DNS servers
DNS=192.168.1.50 # Your local DNS server IP
Domains=home.arpa # Your local search domain
UseDomains=yes
[DHCPv4]
# This ensures DHCP doesn't overwrite your manual DNS settings
UseDNS=no
You may need to restart systemd-networkd and/or use "networkctl reload" after the file is modified
If successful, you should see the search domain in /etc/resolve.conf.
systemd-resolved should pass all DNS trafffic from your machine to dnsmasq which will resolve any local hostnames and pass the rest to you router for resolution.
You can test it with "resolvectl query"
Note the systemd-netwoprkd is great for servers, vms, appliances, and containers I wouldn't recommend it for clients - NetworkManager is a better choice there (you can still use systemd-resolved, though).