I have a small network of computers that can be moved between sites.
These computers are connected to a switch, and one of them acts as DHCP server and DNS server via dnsmasq for this network, let's call it MAINPC.
The DNS is used only to provide name resolution between these computers, and if you add another computer to the LAN, it will be added to the DNS via dnsmasq.
The rest of DNS names have to be handled by secondary DNS server, here comes my problem.
I don't want to hard code a secondary DNS server like 8.8.8.8, because sometimes you will plug this whole network inside another network, with its own DNS server. I want dnsmasq to give as secondary DNS the NetworkManager provided DNS.
What I've done is set dns=default
in a conf file in /etc/NetworkManager/conf.d/
.
This causes NetworkManager to write the DHCP mandated DNS to /etc/resolv.conf, which is read by dnsmasq. This solves most of the problems.
The PC's that are using MAINPC as DNS server work fine, they direct their queries to MAINPC, which answers from the local domain if possible, and if not redirects to the DNS mandated by NetworkManager.
But MAINPC itself is only using the DNS mandated by NetworkManager, and is unable to resolve the other PCs in the network. In a nutshell, it is not using it's own DNS server as primary.
How can this be achieved?
Basically I just need that my /etc/resolv.conf looks like:
# Generated by NetworkManager
search internal_domain other_domain
nameserver MAINPC_IP
nameserver IP_MANDATED_BY_NETWORK_MANAGER
Currently I managed to have it like, by forcing the MAINPC DNS server in a /etc/netplan/
file:
# Generated by NetworkManager
search internal_domain other_domain
nameserver IP_MANDATED_BY_NETWORK_MANAGER
nameserver MAINPC_IP