我正在尝试通过以下方式进行dnsmasq
设置AWS Ubuntu 20.4
这关联。
但是,我似乎无法解决该错误dnsmasq: failed to create listening socket for port 53: Address already in use
我已尝试这些帖子中的步骤但没有成功:
唯一产生明显影响的是将sudo systemctl stop systemd-resolved.service
错误消息从更改dnsmasq: failed to create listening socket for port 53: Address already in use
为dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use
我不确定 53 上实际运行的是什么,因为如果我运行sudo ss -alpn sport = 53 src 127.0.0.1
没有输出,则显然没有任何内容在端口 53 上侦听。但是,如果我运行sudo ss -lp "sport = :domain"
我的输出是:
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))
我的/etc/dnsmasq.conf
样子:
no-resolv
server=8.8.8.8#53
listen-address=127.0.0.1
cache-size=50
我尝试启用bind-interfaces
这/etc/dnsmasq.conf
没有什么区别。
我还尝试确保停止 systemd 解析的服务,并将其屏蔽,以便在重新启动时自动启动。
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved
sudo systemctl mask systemd-resolved
再说一遍,没有区别。
检查sudo systemctl dnsmasq.service
退货:
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.
答案1
你已经在运行dnsmasq
了127.0.0.1
。
0.0.0.0
是所有接口的简写,其中包括127.0.0.1
.
要么运行systemctl stop dnsmasq
并检查它是否已停止,要么发出kill -9 2059
并重试。