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

mah*_*ood 9 networking tftp dnsmasq

操作系统是Scientific Linux 6.3(类似于redhat、centos和fedora),我安装了dnsmasq,配置如下

interface=eth1
domain=hpclab
expand-hosts
dhcp-range=10.0.2.51,10.0.2.100,static
dhcp-option=42,0.0.0.0
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/var/lib/tftpboot
dhcp-host=08:00:27:69:73:7A,ws04,10.0.2.51
Run Code Online (Sandbox Code Playgroud)

和当前节点(运行 dnsmasq)有这个 ip

eth1  Link encap:Ethernet  HWaddr 08:00:27:A9:20:C0  
      inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
      inet6 addr: fe80::a00:27ff:fea9:20c0/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
Run Code Online (Sandbox Code Playgroud)

但是,尝试启动 dnsmasq 服务时出现错误

[root@localhost mahmood]# /etc/init.d/dnsmasq status
dnsmasq is stopped
[root@localhost mahmood]# /etc/init.d/dnsmasq start
Starting dnsmasq: 
dnsmasq: failed to create listening socket: Address already in use
                                                       [FAILED]
Run Code Online (Sandbox Code Playgroud)

netstat 命令显示以下信息

[root@localhost mahmood]# netstat -anlp | grep -w LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1252/rpcbind        
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1445/cupsd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1685/master         
tcp        0      0 0.0.0.0:46556               0.0.0.0:*                   LISTEN      1348/rpc.statd      
tcp        0      0 :::111                      :::*                        LISTEN      1252/rpcbind        
tcp        0      0 :::80                       :::*                        LISTEN      4884/httpd          
tcp        0      0 ::1:631                     :::*                        LISTEN      1445/cupsd          
tcp        0      0 :::51096                    :::*                        LISTEN      1348/rpc.statd      
Run Code Online (Sandbox Code Playgroud)

[root@localhost mahmood]# netstat -aunp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
udp        0      0 0.0.0.0:69                  0.0.0.0:*                               5110/xinetd         
udp        0      0 0.0.0.0:34136               0.0.0.0:*                               1323/avahi-daemon   
udp        0      0 0.0.0.0:38756               0.0.0.0:*                               1348/rpc.statd      
udp        0      0 0.0.0.0:5353                0.0.0.0:*                               1323/avahi-daemon   
udp        0      0 0.0.0.0:1003                0.0.0.0:*                               1252/rpcbind        
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               1252/rpcbind        
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               1445/cupsd          
udp        0      0 0.0.0.0:676                 0.0.0.0:*                               1348/rpc.statd      
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               5189/dhclient       
udp        0      0 :::1003                     :::*                                    1252/rpcbind        
udp        0      0 :::111                      :::*                                    1252/rpcbind        
udp        0      0 :::43248                    :::*                                    1348/rpc.statd      
Run Code Online (Sandbox Code Playgroud)

什么会导致这样的错误,我该如何解决?

Ste*_*day 5

问题是您已配置dnsmasq为提供 TFTP 服务(通过 中的enable-tftp选项dnsmasq.conf)。TFTP的服务端口是UDP/69,所以dnsmasq想绑定,但是xinetd已经绑定了,不可能两个不同的进程绑定到同一个服务端口。

如果您想dnsmasq提供 TFTP 服务,您将需要编辑xinetd配置(可能/etc/xinetd.conf)以关闭其 TFTP 服务。或者,如果您希望xinetd提供 TFTP 服务,那么您需要enable-tftpdnsmasq.conf.

  • 对我没有帮助的是错误_dnsmasq:无法为192.168.2.1创建监听套接字:地址已在使用_可能有点误导其“地址已在使用”,因为它实际上是已在使用的端口,但是对这个答案应用类似的逻辑“netstat -anup”将我指向“in.tftp”,我用“service tftpd-hpa stop”停止了它 (2认同)