Network nightmare (nah, not really)

I’ve followed up this RH how to to set up dnsmasq for DNS with NetworkManager. It says current for EL9, but I’ve also set it with DHCP… (Or, so I thought.) Which may be why it doesn’t work…
And, I’ve just recently discovered this Fedora howto which covers both DNS and DHCP and leads me do suspect it might be more useful…
Any pointers and suggestions for dnsmasq setup for both DNS (with caching) and DHCP for EL9 would be happily welcomed.
The failures look like this (no network, pics only):


Accoring to those messages the dnsmasq does not like “option on line 12”.
What is in there? Expand-hosts ?
Perhaps expand-hosts would be better?

You do show two services: dnsmasq.service and NetworkManager.service
The latter you have configured to start dnsmasq as sub-process.
If both services would start properly, then you would have two distinct dnsmasq processes.
That is possible, but you would not want them to listen on same interface – that setup (multiple dnsmasq) is more special.

You don’t need the standalone dnsmasq.service, just fix the config in /etc/NetworkManager/dnsmasq.d/

Thanks @jlehtone - yeah, the ‘option on line 12’ quote references a default NM file for dnsmasq which is where I twigged - other than the glaring ‘Back off. Something is very wrong’ and it not working - that something was wrong, because obviously that default NM file is a file I haven’t touched - I included it’s contents in the second pic. But, the RH how to says nothing about configuring that file… The only file it references under the head ‘Configure dnsmasq to run under control of NetworkManager’ is /etc/NetworkManager/conf.d/dns.conf … So, that apparently up-to-date RH how to seems incomplete - for what I want anyway…

So, that’s the question - how applicable is the Fedora how to to dnsmasq set up for DNS and DHCP on EL9?

Because they assume one to primarily run the dnsmasq as mere name resolver – bit smarter than glibc.

To serve your own (local) names, and optionally DHCP (and TFTP) you have to add config and that one does “as one does for standalone dnsmasq” (with some twists). I usually read man dnsmasq to figure out which options to add.

My point was more about where the the options should be added rather than whether they should be added - I used /etc/dnfmasq.conf which is where man dnsmasq suggests adding them, but that doesn’t work. It seems the more recent incarnations of rpm based systems are using NetworkManager to manage dnsmasq rather than the documented dnsmasq specified config files - so, I guess what I was trying to ask and not doing very well:

  • For DHCP config of dnsmasq in EL9, is that Fedora how to more likely to work instead of the default dnsmasq config files (which don’t work)?

There is nothing wrong with the “default files” approach.

The dnsmasq.service starts /usr/sbin/dnsmasq – no command-line options, so it goes with defaults and reads the /etc/dnfmasq.conf that contains:


One should not edit that file, but add a file with your options into /etc/dnsmasq.d/

When you tell NetworkManager.service to use dns=dnsmasq, it will start its own instance of dnsmasq, with some options:

/usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/run/NetworkManager/ --listen-address= --cache-size=400 --clear-on-reload --conf-file=/dev/null --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d

Just like with the dnsmasq.service one can add custom config by adding into directory, but now the conf-dir points to directory /etc/NetworkManager/dnsmasq.d/

Note also that “all” files in the conf-dir are read – I had Emacs leave *~ files in there to mess up.

Another difference is that NetworkManager passes DNS-options that it has for connections to the dnsmasq (via DBus), but for standalone dnsmasq.service you do pass the upstream DNS server addresses by other means.

It is thus more convenient to use the NetworkManager, since you most probably want the dnsmasq to both resolve names for this host and provide DNS/DHCP/TFTP service for others.

If the “fedora howto” does show config for instance of dnsmasq started by NetworkManager, then it is probably more approriate to start from.

The man dnsmasq tells that there is option --test that one can use to hunt syntax errors from config files:

dnsmasq --conf-file=/dev/null --conf-dir=/etc/NetworkManager/dnsmasq.d --test

Thanks @jlehtone that’s very helpful - I think I was coming to the conclusion I should spend more time on the Fedora doc than the RHEL instructions. The RHEL instructions do suggest using /etc/dnsmasq.conf but, clearly that docs getting fairly long in the tooth since it’s been around since RHEL6.

I realise I could have worded the post title more usefully: perhaps ‘dnsmasq with DHCP and NetworkManager config?’ But, I can’t edit it; if someone with more privileges can, it might help to others.