dnsmasq:无法为端口53创建侦听套接字:地址已在使用中

我正在设置服务器,如下面的链接https://help.ubuntu.com/community/Dnsmasq

root@user-desktop:/etc/init.d# sudo apt-get install dnsmasq Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: dnsmasq 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/15.4 kB of archives. After this operation, 120 kB of additional disk space will be used. Selecting previously unselected package dnsmasq. (Reading database ... 146283 files and directories currently installed.) Unpacking dnsmasq (from .../dnsmasq_2.59-4_all.deb) ... Processing triggers for ureadahead ... Setting up dnsmasq (2.59-4) ... * Starting DNS forwarder and DHCP server dnsmasq dnsmasq: failed to create listening socket for port 53: Address already in use [fail] invoke-rc.d: initscript dnsmasq, action "start" failed. 

我和你有同样的问题。 我认为自12.10以来这是真的,但这个post在12.10发布之前就已经关闭了。

我做了一些谷歌搜索(主要是从这里受到启发),我找到了这个解决方案:

  • 编辑/etc/NetworkManager/NetworkManager.conf文件,与你最喜欢的编辑器
  • 注释行dns=dnsmasq
  • 重启网络管理器: sudo service network-manager restart

但是在dnsmasq配置( /etc/dnsmasq.conf )中,您必须确保使用listen-address=127.0.0.1listen-address=127.0.0.1 localhost DNS查询。

如果更改了dnsmasq的配置,请不要忘记运行sudo /etc/init.d/dnsmasq restart

我希望这将有所帮助。

我有同样的问题。

在端口53上安装并侦听了dnsmasq-base ,阻止了dnsmasq的启动。

为了相同的目的,可以使用dnsmasq-base insead:只使用另一个config目录:放在Network Manager文件夹中的目录:

 /etc/NetworkManager/dnsmasq.d/ 

编辑:一些谷歌搜索,我找到了解决方案 。 似乎网络管理器依赖于一个名为“dnsmasq-base”的包,它提供了一些dnsmasqfunction。 Ubuntu Wiki中的Dnsmasq条目指出

“请注意,”dnsmasq“软件包会干扰网络管理器,网络管理器可以使用”dnsmasq-base“在共享Internet连接时提供DHCP服务。因此,如果您使用网络管理器(仅限简单设置),请安装dnsmasq -base,但不是dnsmasq。如果你有一个更复杂的设置,卸载网络管理器,使用dnsmasq或类似的软件(bind9,dhcpd等),并手动配置。“

换句话说:你想使用dnsmasq吗? 那你就更清楚自己在做什么了。 前面提到的解决方案建议用以下方式用dnsmasq替换dnsmasq-base(第一个命令也将删除network-manager):

 sudo apt-get remove dnsmasq-base sudo apt-get install dnsmasq sudo apt-get install network-manager network-manager-gnome 

这里有一些关于找到什么阻塞你的端口的一般性评论:你可以通过使用lsof找到正在监听哪个端口的内容:

 lsof -Pn +M -i4 

将列出由于-i4而导致的IPv4端口

 lsof -Pn +M -i6 

将列出IPv6端口。 或者输入

 lsof -Pn +M | grep ':53 (LISTEN)' 

这应该(希望)告诉您使用端口53的是什么。- -Pn命令行开关阻止端口号/主机IP转换为名称。

或者,跑

 netstat -utlnp