如果可能的话,我需要一些有关 dhcp 服务器和 ip 地址预留的建议。
该系统是 Ubuntu 服务器 12.04 LTS。DHCP 是 ISC DHCPd 版本 4.1。
这是 /etc/dhcp/dhcpd.conf 文件:
ddns-update-style interim;
log-facility local7;
subnet 100.1.1.0 netmask 255.255.255.0 {
option ntp-servers ntp1.inrim.it;
authoritative;
option domain-name-servers 100.1.1.120 , 100.1.1.130;
option domain-name "domain.local";
option subnet-mask 255.255.255.0;
option routers 100.1.1.120;
max-lease-time 7200;
default-lease-time 600;
range 100.1.1.150 100.1.1.170;
# NEXUS_5
host android-72c7a71611f38b65 {
hardware ethernet CC:FA:00:E8:7E:37;
fixed-address 100.1.1.250;
}
}
这是我的 nexus 连接到 LAN 并获取 IP 地址时的系统日志:
Jun 19 17:50:22 gate dhcpd: Unable to add forward map from android-72c7a71611f38b65.jodovit.local to 100.1.1.162: timed out
Jun 19 17:50:22 gate dhcpd: DHCPREQUEST for 100.1.1.162 from cc:fa:00:e8:7e:37 (android-72c7a71611f38b65) via eth1
Jun 19 17:50:22 gate dhcpd: DHCPACK on 100.1.1.162 to cc:fa:00:e8:7e:37 (android-72c7a71611f38b65) via eth1
正如您所看到的..我的 nexus 采用 ip 100.1.1.162 而不是配置文件中的 100.1.1.250...
有人可以更好地向我解释预订工作原理吗?
谢谢并且抱歉我的英语不好...
卢卡
===================================================================================
根据@Andrew的建议,我将主机声明移到子网声明之外。重新启动服务并尝试连接我的Nexus,但IP地址来自DHCP池,而不是预留IP。
dhcpdump 的结果是:
TIME: 2014-06-20 08:31:40.706
IP: 0.0.0.0 (cc:fa:0:e8:7e:37) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
OP: 1 (BOOTPREQUEST)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 09ae4197
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: cc:fa:00:e8:7e:37:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 3 (DHCPREQUEST)
OPTION: 61 ( 7) Client-identifier 01:cc:fa:00:e8:7e:37
OPTION: 50 ( 4) Request IP address 100.1.1.162
OPTION: 57 ( 2) Maximum DHCP message size 1500
OPTION: 60 ( 12) Vendor class identifier dhcpcd-5.5.6
OPTION: 12 ( 24) Host name android-72c7a71611f38b65
OPTION: 55 ( 10) Parameter Request List 1 (Subnet mask)
33 (Static route)
3 (Routers)
6 (DNS server)
15 (Domainname)
26 (Interface MTU)
28 (Broadcast address)
51 (IP address leasetime)
58 (T1)
59 (T2)
---------------------------------------------------------------------------
TIME: 2014-06-20 08:31:40.710
IP: 100.1.1.120 (0:50:56:a5:eb:ed) > 100.1.1.162 (cc:fa:0:e8:7e:37)
OP: 2 (BOOTPREPLY)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 09ae4197
SECS: 0
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 100.1.1.162
SIADDR: 100.1.1.120
GIADDR: 0.0.0.0
CHADDR: cc:fa:00:e8:7e:37:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 5 (DHCPACK)
OPTION: 54 ( 4) Server identifier 100.1.1.120
OPTION: 51 ( 4) IP address leasetime 600 (10m)
OPTION: 1 ( 4) Subnet mask 255.255.255.0
OPTION: 3 ( 4) Routers 100.1.1.120
OPTION: 6 ( 8) DNS server 100.1.1.120,100.1.1.130
OPTION: 15 ( 13) Domainname jodovit.local
OPTION: 58 ( 4) T1 300 (5m)
OPTION: 59 ( 4) T2 525 (8m45s)
---------------------------------------------------------------------------
答案1
我认为这可能是一个范围问题。我建议将host
声明移到声明之外subnet
。
DHCPd 会首先查找host
声明,然后根据分配的固定 IP 地址确定主机属于哪个子网。
如果您想跟踪 DHCP 对话,这个dhcpdump
软件包非常有用。
例子:
ddns-update-style interim;
log-facility local7;
subnet 100.1.1.0 netmask 255.255.255.0 {
option ntp-servers ntp1.inrim.it;
authoritative;
[... snip ...]
range 100.1.1.150 100.1.1.170;
}
host android-72c7a71611f38b65 {
hardware ethernet CC:FA:00:E8:7E:37;
fixed-address 100.1.1.250;
}