OnlyTwentyCharacters wrote: ↑2020/07/20 13:26:45
I'm trying to get subdomains to resolve to localhost in CentOS 8. In CentOS 7 I had a dnsmasq config file which would say
Then in dhclient.conf I had
Code: Select all
timeout 300;
retry 60;
prepend domain-name-servers 127.0.0.1;
This allowed all the example.com subdomains to resolve to the localhost. In CentOS 8 everything is run by NetworkManager and I have not found a way to achieve the same behaviour.
You have two things there:
1. DNS server
2. DNS client
Lets look at the DNS client side first. Clients read the resolv.conf, and we want them to use our DNS server.
Hence the address of our server before others. Can NetworkManager do that? Perhaps.
There are settings for each connection:
Code: Select all
# nmcli -f ipv4 c s $conn_name
ipv4.method: auto
ipv4.dns: --
ipv4.dns-search: --
ipv4.dns-options: --
ipv4.dns-priority: 0
...
ipv4.ignore-auto-dns: no
...
See man
nm-settings.
We can set
ipv4.dns 127.0.0.1 although, if other values come from DHCP, then order might be wrong.
With
ipv4.ignore-auto-dns yes DNS options offered by DHCP are ignored.
There is thus a possibility to tell NetworkManager what it writes to resolv.conf.
I have systems with two connections. One gets everything from DHCP. The other has higher
ipv4.dns-priority and sets thus the first DNS.
Note that NetworkManager config has option
dhcp. The default is to use internal dhcp client, but you can request the good old dhclient.
Therefore, you could have the familiar
prepend domain-name-servers 127.0.0.1;.
Then we have the DNS server. We could have the dnsmasq.service (or named) configured and running. (That is what I've done.)
Or tell NetworkManager ...
OnlyTwentyCharacters wrote: ↑2020/07/20 13:26:45
If I add the a NetworkManager configuration file with the following content
and manually run "dhclient" then NetworkManager no longer overwrites /etc/resolve.conf on every boot. Does anything update resolve.conf anymore if DNS servers happen to change or do I need to keep running dhclient manually?
That option
dns has many possible values, including
dnsmasq (systemd-resolved and unboud). See
man NetworkManager.conf
I have fancied testing that, but never got to it.
It is possible to pass custom options to the dnsmasq instance by adding them to files in the "/etc/NetworkManager/dnsmasq.d/" directory.
PS. The libvirtd.service, if installed and running, and with routed virtual networks (like the "default"), does start a separate dnsmasq process for each virtual network (to server DHCP and DNS for VMs).