# Network nightmare (nah, not really)

**URL:** https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244
**Category:** Rocky Linux Help & Support
**Created:** [March 17, 2024, 1:44pm UTC](https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244 "2024-03-17T13:44:52Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![pseud](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/pseud/32/1323_2.png) [@pseud](https://forums.rockylinux.org/u/pseud)
#### Post date: [March 17, 2024, 1:44pm UTC](https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244/1 "2024-03-17T13:44:52Z")

</div>

Folks,  
I’ve followed up [this RH how to](https://access.redhat.com/solutions/2189401) 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](https://docs.fedoraproject.org/en-US/fedora-server/administration/dnsmasq/) 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):

 ![img_20240317_132800Z.resize](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/2X/1/1ff50ac2e93b6e10fc8797cbd2bddd5020f51748.jpeg)  
 ![img_20240317_132839Z.resize](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/2X/7/7653620afc2e3149103711d1da749cb4183e41b0.jpeg)  
Thanks!

---

<div class="post-metadata">

### Author: ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)
#### Post date: [March 17, 2024, 3:18pm UTC](https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244/2 "2024-03-17T15:18:58Z")

</div>

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/

---

<div class="post-metadata">

### Author: ![pseud](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/pseud/32/1323_2.png) [@pseud](https://forums.rockylinux.org/u/pseud)
#### Post date: [March 17, 2024, 4:27pm UTC](https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244/3 "2024-03-17T16:27:01Z")

</div>

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](https://access.redhat.com/solutions/2189401) seems incomplete - for what I want anyway…

So, that’s the question - how applicable is [the Fedora how to](https://docs.fedoraproject.org/en-US/fedora-server/administration/dnsmasq/) to `dnsmasq` set up for DNS and DHCP on EL9?

---

<div class="post-metadata">

### Author: ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)
#### Post date: [March 17, 2024, 9:30pm UTC](https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244/4 "2024-03-17T21:30:08Z")

</div>

> [@pseud](#):
>
> But, the RH how to says nothing about configuring that file…

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.

---

<div class="post-metadata">

### Author: ![pseud](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/pseud/32/1323_2.png) [@pseud](https://forums.rockylinux.org/u/pseud)
#### Post date: [March 18, 2024, 1:11am UTC](https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244/5 "2024-03-18T01:11:55Z")

</div>

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)?

---

<div class="post-metadata">

### Author: ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)
#### Post date: [March 18, 2024, 9:48am UTC](https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244/6 "2024-03-18T09:48:31Z")

</div>

> [@pseud](#):
>
> 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:

```auto
user=dnsmasq
group=dnsmasq
interface=lo
bind-interfaces
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig

```

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:

```auto
/usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/run/NetworkManager/dnsmasq.pid --listen-address=127.0.0.1 --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:

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

```

---

<div class="post-metadata">

### Author: ![pseud](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/pseud/32/1323_2.png) [@pseud](https://forums.rockylinux.org/u/pseud)
#### Post date: [March 19, 2024, 2:24pm UTC](https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244/7 "2024-03-19T14:24:58Z")

</div>

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.

Thanks.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/1X/91b7219eec10e30013422e4df76c1d898711a5d5.svg) [@system](https://forums.rockylinux.org/u/system)
#### Post date: [May 18, 2024, 2:25pm UTC](https://forums.rockylinux.org/t/network-nightmare-nah-not-really/13244/8 "2024-05-18T14:25:41Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
