How to setup Wireless Access Point and Pi-hole

I used Network Manager to set up the access point. So far so good. I'm able to connect through it.

I installed Pi Hole.

However, Pi Hole doesn't work because of a conflict on Port 53:

2025-05-10 11:05:43.541 failed to create listening socket for port 53: Address in use
2025-05-10 11:05:43.541 FAILED to start up

When I use netstat, I see that dnsmasq is listening on port 53. Apparently it is from using Network Manager.

How do I disable that instance of dnsmasq so that the one in use by pihole can be used instead?

How did you configure dnsmasq? You may need to apply some of its settings to your Pi-Hole installation. (By default Pi-hole no longer makes use of the contents of /etc/dnsmasq.d/)

For most distros:

$ sudo systemctl stop dnsmasq
$ sudo systemctl restart pihole-FTL

Will stop dnsmasq allowing pihole to use port 53, and restart pihole.

If all goes well and you would like to make this permanent (prevent dnsmasq starting again at reboot):

$ sudo systemctl disable dnsmasq

If you later need to revert to using dnsmasq for any reason:

$ sudo systemctl disable pihole-FTL
$ sudo systemctl enable dnsmasq
$ sudo systemctl start dnsmasq

I tried this:

sudo systemctl stop dnsmasq

It returns this:

Failed to stop dnsmasq.service: Unit dnsmasq.service not loaded.

Based on this, it looks like I need to configure nmtui to use dns from pihole by editing /etc/NetworkManager/NetworkManager.conf

I tried adding this line to [main], but that does not do it, even with a reboot.

dns=pihole-FTL

It looks like I need to specify the pihole DNS service here. Does anyone know how to do that?

EDIT:
I found a suggestion here to use dns=none in that file, but it also did not work.

Could you try creating a file like /etc/NetworkManager/dnsmasq.d/no-dns.conf and adding port=0. If port=0 does not work try a different unused port number. This will effectively deactivate/change to port of the dnsmaq networkmanager is using

 sudo systemctl status dnsmasq
Unit dnsmasq.service could not be found.

So, dnsmasq isn't running as a standalone service, but it is running and blocking port 53.

However, when I use netstat to see what is using port 53, this is what I get:

sudo netstat -nltup | grep ':53 '
tcp        0      0 X.X.0.1:53              0.0.0.0:*               LISTEN      1215/dnsmasq
udp        0      0 0.0.0.0:53              0.0.0.0:*                           1479/pihole-FTL
udp        0      0 X.X.0.1:53              0.0.0.0:*                           1215/dnsmasq

Which is why I'm trying to figure out how to stop Network Manager from running its own instance of dnsmasq.

Only the dnsmasq binary is installed as a NM dependency:

$ dpkg -S bin/dnsmasq
dnsmasq-base: /usr/sbin/dnsmasq
$ apt depends network-manager
[..]
  Recommends: dnsmasq-base

The systemd service unit for dnsmasq is contained in another package that isn't installed:

$ dpkg -S dnsmasq.service
dpkg-query: no path found matching pattern *dnsmasq.service*
$ apt-file search dnsmasq.service
dnsmasq: /lib/systemd/system/dnsmasq.service
$ apt policy dnsmasq dnsmasq-base
dnsmasq:
  Installed: (none)
[..]
dnsmasq-base:
  Installed: 2.89-1
[..]

I had a go at it below replacing the dnsmasq binary with the pihole-FTL binary (via symlinking) but the later seems to be missing a Dbus dependency to go forward:

As port=0 was tried already in above thread, you could try configuring another unused port.

Grep for it:

sudo rgrep -i dnsmasq /etc/NetworkManager/

See also:

man NetworkManager.conf

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