dnsmasq 无法在 Ubuntu 13.10 启动时启动

dnsmasq 无法在 Ubuntu 13.10 启动时启动

dnsmasq 无法在 Ubuntu 13.10 启动时启动,并在系统日志中显示错误:

dnsmasq failed to create listening socket for 192.168.0.10: Cannot assign requested address

当我手动启动它时,它工作得很好。这是 dnsmasq.conf:

bogus-priv
server=212.27.40.240
server=212.27.40.241
local=/mydomain.0./
# interface=eth0
listen-address=127.0.0.1
listen-address=192.168.0.10
expand-hosts
domain=mydomain.0.
dhcp-range=192.168.0.20,192.168.0.100,24h
dhcp-option=3,192.168.0.1
dhcp-option=vendor:MSFT,2,1i
cname="www.mydomain.0",myhost

据我了解,NetworkManager 使用的是精简版 dnsmasq 的实例,该实例可能与完整版冲突。我猜这就是问题的原因。我希望拥有服务器的主机以及网络上的所有其他主机都使用 dnsmasq。

知道发生了什么事吗?

答案1

听起来好像地址或端口已被使用。尝试禁用networkmanager以查看是否有帮助。这很可能不是原因,因为您在手动启动服务时能够访问该地址。

此外,如果在服务启动之前您的地址尚未分配给服务器,则在启动时也可能发生这种情况dnsmasq。如果是这种情况,请确保您的服务器分配了静态 IP 地址。

答案2

我在 14.04 中遇到了同样的问题。原来是 NetworkManager 和 dnsmasq 的组合。/var/log/syslog您可能会看到,当 dnsmasq 尝试启动时,eth0 也未准备好。

我的解决方案是通过在 中配置 eth0 来禁用 NM 的 eth0 /etc/network/interfaces。将 iface eth0 inet dhcp... 或类似内容添加到配置中。这样,当 dnsmasq 启动时,eth0 即可使用。

答案3

遇到了同样的错误,我没有启动我的接口 eth0,并且没有分配服务器的 IP 地址。因此解决问题的方法是

  1. 启动 eth0 接口并分配 IP sudo ifup eth0,然后使用sudo ip a
  2. 重新启动 dnsmask 服务器sudo service dnsmasq restart

如果有帮助的话我的配置如下 /etc/网络/接口

allow-hotplug eth0
iface eth0 inet dhcp
    address 192.168.2.1
    netmask 255.255.255.0
    network 192.168.2.0
    broadcast 192.168.2.255
    dns-nameservers 8.8.8.8
    dns-search lan
    post-up /sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

/etc/dnsmasq.conf

interface=eth0      # Use interface eth0  
listen-address=192.168.2.1 # Explicitly specify the address to listen on  
bind-interfaces      # Bind to the interface to make sure we aren't sending things elsewhere  
server=8.8.8.8       # Forward DNS requests to Google DNS  
domain-needed        # Don't forward short names  
bogus-priv           # Never forward addresses in the non-routed address spaces.  
dhcp-range=192.168.2.50,192.168.2.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time  

我的目的是获得一个 dhcp 服务器,以便能够将有线流量重新路由到我的 lptp 的 wlan

相关内容