dnsmasq无法在CentOS 7上启动dhcp服务器

Electirc_ar

我试图在我的CentOS 7系统上设置dnsmasq。每次dnsmasq出现时,都会在日志中说它无法绑定dhcp服务器套接字。

Oct 24 14:47:16 centos1 dnsmasq[1200]: started, version 2.76 cachesize 150
Oct 24 14:47:16 centos1 dnsmasq[1200]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop-detect inotify
Oct 24 14:47:16 centos1 dnsmasq-dhcp[1200]: DHCP, IP range 192.168.2.100 -- 192.168.2.199, lease time 2d
Oct 24 14:47:16 centos1 dnsmasq-tftp[1200]: TFTP root is /var/lib/tftpboot
Oct 24 14:47:16 centos1 dnsmasq[1200]: using nameserver 8.8.4.4#53
Oct 24 14:47:16 centos1 dnsmasq[1200]: reading /etc/resolv.conf
Oct 24 14:47:16 centos1 dnsmasq[1200]: using nameserver 8.8.4.4#53
Oct 24 14:47:16 centos1 dnsmasq[1200]: using nameserver 192.168.2.1#53
Oct 24 14:47:16 centos1 dnsmasq[1200]: read /etc/hosts - 2 addresses
Oct 24 14:47:17 centos1 dnsmasq[1200]: reading /etc/resolv.conf
Oct 24 14:47:17 centos1 dnsmasq[1200]: using nameserver 8.8.4.4#53
Oct 24 14:47:17 centos1 dnsmasq[1200]: using nameserver 192.168.2.1#53
**Oct 24 14:47:20 centos1 dnsmasq[1387]: failed to bind DHCP server socket: Address already in use**

我检查了端口,netstat对我来说所有端口似乎都正常(它们都连接到dnsmasq):

[root@centos1 log]# netstat -anlp | grep -w LISTEN
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      1200/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1206/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1203/cupsd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1481/master
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd
tcp6       0      0 :::21                   :::*                    LISTEN      1213/vsftpd
tcp6       0      0 :::53                   :::*                    LISTEN      1200/dnsmasq
tcp6       0      0 :::22                   :::*                    LISTEN      1206/sshd
tcp6       0      0 ::1:631                 :::*                    LISTEN      1203/cupsd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1481/master
[root@centos1 log]# netstat -anup
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:36235           0.0.0.0:*                           982/dhclient
udp        0      0 0.0.0.0:4011            0.0.0.0:*                           1200/dnsmasq
udp        0      0 0.0.0.0:53              0.0.0.0:*                           1200/dnsmasq
udp        0      0 0.0.0.0:60476           0.0.0.0:*                           643/avahi-daemon: r
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1200/dnsmasq
udp        0      0 0.0.0.0:68              0.0.0.0:*                           982/dhclient
udp        0      0 0.0.0.0:69              0.0.0.0:*                           1200/dnsmasq
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           643/avahi-daemon: r
udp        0      0 127.0.0.1:323           0.0.0.0:*                           659/chronyd
udp6       0      0 :::53                   :::*                                1200/dnsmasq
udp6       0      0 :::69                   :::*                                1200/dnsmasq
udp6       0      0 :::49922                :::*                                982/dhclient
udp6       0      0 ::1:323                 :::*                                659/chronyd

这也是我的 /etc/dnsmasq.conf

interface=enp0s3,lo
#bind-interfaces
domain=centos.home
# DHCP range-leases
dhcp-range= 192.168.2.100,192.168.2.199,255.255.255.0,48h
# PXE
dhcp-boot=pxelinux.0,pxeserver,192.168.2.199
# Gateway
dhcp-option=3,192.168.2.1
# DNS
dhcp-option=6,192.168.2.1,8.8.8.8
server=8.8.4.4
# Broadcast Address
dhcp-option=28,10.0.0.255
dhcp-host=08:00:27:c3:a2:df,192.168.2.199
# NTP Server
#dhcp-option=42,0.0.0.0
pxe-prompt="Press F8 for menu.", 60
pxe-service=x86PC, "Install CentOS 7 from network server 192.168.2.199", pxelinux
enable-tftp
tftp-root=/var/lib/tftpboot

我想念的是什么?

Electirc_ar

我确实停止了dnsmasq并检查了所有端口,但是dnsmasq使用的所有端口都消失了。无论如何,我认为这个想法使我走上了正确的道路。因此我尝试检查端口状态,我想到防火墙可能会阻止部分/全部dnsmasq端口连接,实际上就是这样。我只是禁用了那些端口上的防火墙,它终于开始正常工作。

记录是我所做的:我从上面的netstat命令检查所需的端口,并打开防火墙上的所有端口

firewall-cmd --add-service=ftp --permanent     
firewall-cmd --add-service=dns --permanent     
firewall-cmd --add-service=dhcp --permanent 
firewall-cmd --add-port=69/udp --permanent  
firewall-cmd --add-port=4011/udp --permanent
firewall-cmd --reload

谢谢

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章