2

I am on CentOS 7.4 attempting to configure dnsmasq for DNS caching and per-zone DNS servers for running Consul. Essentially, the dnsmasq configuration boils down to this:

# filter everything with consul in the name and send to local consul resolver
server=/consul/127.0.0.1#8600

The problem I'm having is getting the local resolver into /etc/resolv.conf without replacing any other resolvers in the file.

I used to be able to do this using dhclient configuration like so:

prepend domain-name-servers 127.0.0.1;

Since everything is NetworkManager now, I have discovered that the way to use dnsmasq is to add the following line to the [main] section of /etc/NetworkManager/NetworkManager.conf:

dns=dnsmasq

Before restarting NetworkManager, I see that my /etc/resolv.conf contains the network DNS server received by DCHP:

# Generated by NetworkManager
search nowhere
nameserver 10.0.2.3
options single-request-reopen

Upon restarting NetworkManager with the above configuration change, it supersedes my network DNS server with 127.0.0.1:

# Generated by NetworkManager
search nowhere
nameserver 127.0.0.1
options single-request-reopen

Since dnsmasq uses the /etc/resolv.conf to detect local resolvers, I'd like to leave the resolver(s) in /etc/resolv.conf so that dnsmasq can discover them.

Is there a way to achieve the previous functionality of having NetworkManager just prepend the local resolver instead?

Naftuli Kay
  • 1,708
  • 6
  • 24
  • 44
  • Is there anything compelling you to keep NetworkManager? Simple and painless to 'yum remove' it. (I'm intentionally avoiding debate on how useful it is on a server system) – Brandon Xavier Sep 27 '17 at 21:05
  • `dnsmasq uses the /etc/resolv.conf` - It doesn't have to. It can be configured to use a different file. And you can configure your DHCP client to write the DHCP options to a different file. This is what happens on recent Debian-based systems. – Zoredache Sep 28 '17 at 00:41

1 Answers1

1

Apparently even though CentOS 7.4 does not ship with an upstream /etc/dhclient.conf, this is still a valid path. I simply created this file with the following contents:

prepend domain-name-servers 127.0.0.1;

And voila!

# Generated by NetworkManager
search nowhere
nameserver 127.0.0.1
nameserver 10.0.2.3
options single-request-reopen
Naftuli Kay
  • 1,708
  • 6
  • 24
  • 44