I'm trying to set up dnsmasq
on AWS Ubuntu 20.4
by following this link.
However, I can't seem to get around the error dnsmasq: failed to create listening socket for port 53: Address already in use
I've tried the steps in these posts with no success:
dnsmasq: failed to create listening socket for port 53: Address already in use
https://discourse.pi-hole.net/t/dnsmasq-failed-to-create-listening-socket-for-port-53-permission-denied/16436
https://jonamiki.com/2020/01/29/dnsmasq-failed-to-create-listening-socket-for-port-53-address-already-in-use/
dnsmasq : failed to create listening socket for port 53: Address already in use
The only thing that has had any obvious impact has been sudo systemctl stop systemd-resolved.service
which changed the error message from dnsmasq: failed to create listening socket for port 53: Address already in use
to dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use
I'm not sure what's actually running on 53 because, if I run sudo ss -alpn sport = 53 src 127.0.0.1
there is no output, nothing is apparently listening on port 53. However, If I run sudo ss -lp "sport = :domain"
my output is:
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
udp UNCONN 0 0 0.0.0.0:domain 0.0.0.0:* users:(("dnsmasq",pid=2059,fd=4))
udp UNCONN 0 0 [::]:domain [::]:* users:(("dnsmasq",pid=2059,fd=6))
tcp LISTEN 0 32 0.0.0.0:domain 0.0.0.0:* users:(("dnsmasq",pid=2059,fd=5))
tcp LISTEN 0 32 [::]:domain [::]:* users:(("dnsmasq",pid=2059,fd=7))
My /etc/dnsmasq.conf
looks like:
no-resolv
server=8.8.8.8#53
listen-address=127.0.0.1
cache-size=50
I tried enabling bind-interfaces
in /etc/dnsmasq.conf
which made no difference.
And I also tried to make sure to stop systemd-resolved service and I masked it so auto start on reboot.
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved
sudo systemctl mask systemd-resolved
Again, no difference.
Checking sudo systemctl dnsmasq.service
returns:
Unknown operation dnsmasq.service.
ubuntu@ip-172-31-27-116:~$ sudo systemctl status dnsmasq.service
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-02-13 19:55:05 UTC; 36s ago
Process: 3381 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
Process: 3382 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)
Feb 13 19:55:04 ip-172-31-27-116 systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Feb 13 19:55:05 ip-172-31-27-116 dnsmasq[3381]: dnsmasq: syntax check OK.
Feb 13 19:55:05 ip-172-31-27-116 dnsmasq[3382]: dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use
Feb 13 19:55:05 ip-172-31-27-116 dnsmasq[3382]: failed to create listening socket for 127.0.0.1: Address already in use
Feb 13 19:55:05 ip-172-31-27-116 dnsmasq[3382]: FAILED to start up
Feb 13 19:55:05 ip-172-31-27-116 systemd[1]: dnsmasq.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Feb 13 19:55:05 ip-172-31-27-116 systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
Feb 13 19:55:05 ip-172-31-27-116 systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.