dnsmasq:无法为 127.0.0.1 创建监听套接字:地址已在使用中

dnsmasq:无法为 127.0.0.1 创建监听套接字:地址已在使用中

我正在尝试按照以下方式进行dnsmasq设置AWS Ubuntu 20.4关联。

然而,我似乎无法解决这个错误dnsmasq: failed to create listening socket for port 53: Address already in use

我尝试过这些帖子中的步骤,但没有成功:

  1. dnsmasq:无法为端口 53 创建监听套接字:地址已被使用

  2. https://discourse.pi-hole.net/t/dnsmasq-failed-to-create-listening-socket-for-port-53-permission-denied/16436

  3. https://jonamiki.com/2020/01/29/dnsmasq-failed-to-create-listening-socket-for-port-53-address-already-in-use/

  4. dnsmasq:无法为端口 53 创建监听套接字:地址已被使用

唯一有明显影响的是将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-resolved 服务并将其屏蔽以便在重启时自动启动。

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.

相关内容