我在 Centos 6.10 上安装了 dhcp (4.1.1)。我使用以下配置:
#specify domain name
option domain-name "example.com";
#specify DNS server ip and additional DNS server ip
option domain-name-servers 192.168.5.40;
#specify default lease time
default-lease-time 600;
#specify Max lease time
max-lease-time 7200;
#specify log method
log-facility local7;
#Configuring subnet and iprange
subnet 192.168.5.0 netmask 255.255.255.0 {
range 192.168.5.50 192.168.5.200;
option broadcast-address 192.168.5.255;
#Default gateway ip
option routers 192.168.5.1;
}
当我从 localhost(服务器本身)和网络上的系统使用 dhcping 测试服务器时,我收到了no answer
。
dhcping -s 192.168.5.40
网络上另一台计算机(运行 Fedora)的输出是:
# dhcping -V -s 192.168.5.40
setup
request
packet 250 bytes
01 01 06 00 fe cc 2d 5c 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 63 82 53 63
35 01 03 32 04 00 00 00 00 ff
op: 1
htype: 1
hlen: 6
hops: 0
xid: fecc2d5c
secs: 0
flags: 0
ciaddr: 0.0.0.0
yiaddr: 0.0.0.0
siaddr: 0.0.0.0
giaddr: 0.0.0.0
chaddr: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
sname : .
fname : .
option 53 DHCP message type
DHCP message type: 3 (DHCPREQUEST)
option 50 Request IP address
Requested IP address: 0.0.0.0
no answer
close
补充信息:
禁用 iptables 没什么区别。DHCP 和 DNS Server 是同一台机器 (192.168.5.40)。netstat -tulpen
(on server) 的输出如下:
# netstat -tulpen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 0 12595 1795/master
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 25 12065 1510/named
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 496 12146 1538/redis-server 1
tcp 0 0 192.168.5.40:53 0.0.0.0:* LISTEN 25 12062 1510/named
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 25 12060 1510/named
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 12254 1589/sshd
tcp 0 0 ::1:25 :::* LISTEN 0 12597 1795/master
tcp 0 0 ::1:953 :::* LISTEN 25 12066 1510/named
tcp 0 0 :::3306 :::* LISTEN 498 12343 1668/mysqld
tcp 0 0 :::80 :::* LISTEN 0 12732 1808/httpd
tcp 0 0 :::53 :::* LISTEN 25 12055 1510/named
tcp 0 0 :::22 :::* LISTEN 0 12256 1589/sshd
udp 0 0 0.0.0.0:67 0.0.0.0:* 0 14480 2146/dhcpd
udp 0 0 192.168.5.40:53 0.0.0.0:* 25 12061 1510/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 25 12059 1510/named
udp 0 0 :::53 :::* 25 12054 1510/named
附言
添加authoritative
配置文件并不能解决问题。
答案1
事实证明,这dhcping
与我的 DHCP 服务器的健康状况无关,而是我的 iptables 规则存在问题。我检查了正在运行的防火墙规则service iptables status
:
我注意到 TCP 上只打开了 80 和 443。我也为 UDP 打开了它们。我还通过运行以下命令打开了 53 (DNS):
iptables -I INPUT -p tcp --dport 53 -j ACCEPT
iptables -I INPUT -p udp --dport 53 -j ACCEPT
service iptables save
service iptables restart
我不确定 UDP 部分。也许端口在没有 UDP 的情况下也能工作。不过,我猜解决问题的方法是为端口 53 添加规则。
现在,我能够将设备直接连接到服务器的 RJ45 端口,获得 IP,并浏览服务器上托管的网站。