Enable pi-hole along with hotspot in Ubuntu

I installed Pi-hole successfully but I'm enabling hotspot, so I got this error:

FTL failed to start due to failed to create listening socket for port 53: Address already in use (by dnsmasq)

When I kill dnsmasq, Pi-hole works fine, but I'm not now able to enable hotspot, I get:

dnsmasq[22153]: failed to create listening socket for port 53: Address already in use

I uninstalled dnsmasq-base and Pi-hole is working fine, but when I try to enable hotspot, I get this error:

NetworkManager[116210]: <warn> [1734879323.7233] device (wlp0s20f3): ip:shared4: could not start dnsmasq: Could not find "dnsmasq" binary

Is there a way to use Pi-hole and hotspot at the same time in Ubuntu? Can I configure hotspot to use Pi-hole instead of dnsmasq?

Not sure if it might work but you could try symlinking as pihole-FTL should work as a dnsmasq drop in/replacement.

$ apt-file list dnsmasq-base
[..]
dnsmasq-base: /usr/sbin/dnsmasq
$ which pihole-FTL
/usr/bin/pihole-FTL

Symlink to be made is:

sudo ln -s /usr/bin/pihole-FTL /usr/sbin/dnsmasq

Test:

$ readlink -f /usr/sbin/dnsmasq
/usr/bin/pihole-FTL
$ /usr/sbin/dnsmasq -vv
****************************** FTL **********************************
Version:         v5.25.2
Branch:          master
Commit:          8943e260 (2024-05-08 20:59:50 +0100)
Architecture:    armv6hf (compiled on CI)
Compiler:        arm-linux-gnueabihf-gcc (GCC) 10.3.0

****************************** dnsmasq ******************************
Version:         pi-hole-v2.90+1
Features:        IPv6 GNU-getopt no-DBus no-UBus no-i18n IDN DHCP DHCPv6 Lua TFTP no-conntrack ipset no-nftset auth cryptohash DNSSEC loop-detect inotify dumpfile

****************************** SQLite3 ******************************
Version:         3.42.0
Features:        ATOMIC_INTRINSICS=1 COMPILER=gcc-10.3.0 DEFAULT_AUTOVACUUM DEFAULT_CACHE_SIZE=-16384 DEFAULT_FILE_FORMAT=4 DEFAULT_FOREIGN_KEYS DEFAULT_JOURNAL_SIZE_LIMIT=-1 DEFAULT_MEMSTATUS=0 DEFAULT_MMAP_SIZE=0 DEFAULT_PAGE_SIZE=4096 DEFAULT_PCACHE_INITSZ=20 DEFAULT_RECURSIVE_TRIGGERS DEFAULT_SECTOR_SIZE=4096 DEFAULT_SYNCHRONOUS=2 DEFAULT_WAL_AUTOCHECKPOINT=1000 DEFAULT_WAL_SYNCHRONOUS=2 DEFAULT_WORKER_THREADS=0 DQS=0 ENABLE_DBPAGE_VTAB MALLOC_SOFT_LIMIT=1024 MAX_ATTACHED=10 MAX_COLUMN=2000 MAX_COMPOUND_SELECT=500 MAX_DEFAULT_PAGE_SIZE=8192 MAX_EXPR_DEPTH=1000 MAX_FUNCTION_ARG=127 MAX_LENGTH=1000000000 MAX_LIKE_PATTERN_LENGTH=50000 MAX_MMAP_SIZE=0x7fff0000 MAX_PAGE_COUNT=1073741823 MAX_PAGE_SIZE=65536 MAX_SQL_LENGTH=1000000000 MAX_TRIGGER_DEPTH=1000 MAX_VARIABLE_NUMBER=32766 MAX_VDBE_OP=250000000 MAX_WORKER_THREADS=8 MUTEX_PTHREADS OMIT_DEPRECATED OMIT_DESERIALIZE OMIT_LOAD_EXTENSION OMIT_PROGRESS_CALLBACK SYSTEM_MALLOC TEMP_STORE=1 THREADSAFE=1

******************************** LUA ********************************
Version:         5.4
Libraries:       inspect.lua (8.46 KB)

***************************** LIBNETTLE *****************************
Version:         3.4
GMP:             Full

If not working you can delete the symlink with below:

sudo rm /usr/sbin/dnsmasq

I just realised that the dnsmasq instance called upon by NM would conflict with the pihole-FTL.service instance over port 53.
You could try disabling the pihole-FTL.service reboot persistent with below and hope NM will startup dnsmasq / pihole-FTL as expected:

sudo systemctl disable --now pihole-FTL.service

To enable again if not working as expected:

sudo systemctl enable --now pihole-FTL.service

Or else it gets quite complicated to have the two coexist bc of the port 53 conflict (EDIT: I guess).

EDIT: Below ones might be useful:

pstree -pt

sudo ss -nltup

EDIT2: Do you have below folder?

/etc/NetworkManager/dnsmasq-shared.d/

I believe thats the spot where dnsmasq config files can be dropped.
Or maybe there is one or more already?

Yes, I have this folder and dnsmasq.d folder as well, but they are empty.

[quote="deHakkelaar, post:3, topic:74690"]
/etc/NetworkManager/dnsmasq-shared.d/
[/quote]

Does above folder have content?
And whats in those files if any?

What absolute path is that?

/etc/NetworkManager/dnsmasq.d

Did you get the symlinked pihole-FTL to run via NM?
If so, what does below output?

ps -o cmd -C dnsmasq -C pihole-FTL

Unfortunately, the symbolic link approach didn't work. I got

NetworkManager[661]: <warn> [1735002298.9753] dnsmasq-manager: dnsmasq exited with error: Configuration problem (1)

Hmm never heard of dnsmasq-manager.
Not sure whats going on here.
Was worth a try :wink:

1 Like

Check below man page which has a few dnsmasq references:

$ man NetworkManager.conf
[..]
           dnsmasq: NetworkManager will run dnsmasq as a local
           caching nameserver, using "Conditional Forwarding" if you
           are connected to a VPN, and then update resolv.conf to
           point to the local nameserver. It is possible to pass
           custom options to the dnsmasq instance by adding them to
           files in the "/etc/NetworkManager/dnsmasq.d/" directory.

And maybe if you get the hotspot up with Pi-hole disabled, you can figure out with which arguments the dnsmasq binary is called upon with below?

EDIT: Oh change that into below so we know the user as well:

ps -o uid,user,gid,group,pid,cmd -C dnsmasq -C pihole-FTL

Oh blast, I realised above attempt maybe left some loging why it failed.
Check if so in below logs:

/var/log/pihole/FTL.log

/var/log/pihole/pihole.log

This has been asked before, see e.g.
Wifi hotspot not suppling ip & kills FTLDNS.

NetworkManager is able to start dnsmasq processes as required.
NM configures them via configuration files from /etc/NetworkManager/dnsmasq-shared.d (for its hotspot service) and /etc/NetworkManager/dnsmasq.d/ (for its DNS service).

So for NM's dnsmasq DHCP service and pihole-FTL's DNS service to coexist, you 'd have to make sure that neither one uses the ports of the other.

If you want Pi-hole to handle DNS, try adding port=0 to NM's dnsmasq config files to disable NM's DNS functionality and only leave DHCP.

1 Like

I added /etc/NetworkManager/dnsmasq.d/custom.conf that has only port=0 and then restarted the NetworkManager, but I got this:
NetworkManager[264904]: dnsmasq: failed to create listening socket for 10.42.0.1: Address already in use