为什么不能使用静态IP我告诉它要求?

这是我的/etc/dhcp3/dhclient.conf:

request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, domain-search, host-name, netbios-name-servers, netbios-scope, interface-mtu; timeout 60; alias { interface "eth0"; fixed-address 192.168.1.222; } lease { interface "eth0"; fixed-address 192.168.1.222; option subnet-mask 255.255.255.0; option broadcast-address 255.255.255.255; option routers 192.168.1.254; option domain-name-servers 192.168.1.254; } 

当我运行“dhclient eth0”时,我得到这个:

 There is already a pid file /var/run/dhclient.pid with pid 6511 killed old client process, removed PID file Internet Systems Consortium DHCP Client V3.1.1 Copyright 2004-2008 Internet Systems Consortium. All rights reserved. For info, please visit http://www.isc.org/sw/dhcp/ wmaster0: unknown hardware address type 801 wmaster0: unknown hardware address type 801 Listening on LPF/eth0/00:1c:25:97:82:20 Sending on LPF/eth0/00:1c:25:97:82:20 Sending on Socket/fallback DHCPREQUEST of 192.168.1.27 on eth0 to 255.255.255.255 port 67 DHCPACK of 192.168.1.27 from 192.168.1.254 bound to 192.168.1.27 -- renewal in 1468 seconds. 

我使用strace来确保dhclient真正在读取conf文件。 为什么不关注我的“固定地址192.168.1.222”行? 为什么它代替192.168.1.27做DHCPREQUEST?

拒绝是拒绝具有特定地址的服务器的报价。 这不是拒绝服务器提供的地址。

拒绝语句会导致DHCP客户端拒绝来自其服务器标识符与任何指定的主机或子网匹配的服务器的提供。 这可以用来避免被stream氓或错误configuration的DHCP服务器configuration,

定义的租约只有在DHCP服务器没有响应时才会使用。

lease {lease-declaration [… lease-declaration]}

DHCP客户端可能会在一段时间后(请参阅PROTOCOL TIMING)决定不会成功联系服务器。

如果你想要一个特定的地址,你应该在服务器上设置一个预留。

正如Zoredache正确指出的那样:固定地址设置仅适用于仅在DHCP服务器不响应时才有效的租用定义。 请参阅“租赁声明”一节中的http://linux.die.net/man/5/dhclient.conf

你想要的是

 interface "eth0" { send dhcp-requested-address 192.168.1.222; } 

这在dhcp-options的联机帮助页中有logging: http : //linux.die.net/man/5/dhcp-options并符合可在http://www.rfc-editor.org/rfc上获得的DHCP选项RFC /rfc2132.txt

但请注意:由于请求的地址已经被占用,我最近遇到dhclient3没有得到这个configuration的IP。 服务器用DHCPNAK回应请求,并且客户端会在一段时间后放弃。 我曾经预料到,如果请求的DHCP客户端不可用,DHCP客户端最终会得到另一个地址。

我使用这种方法试图确保我总是知道我的服务器的地址,而不是诉诸像dyndns.com的东西,并最终没有连接。

你真的检查,如果它是通过您指定的IP访问(早在2010年,我知道…)?

我刚才犯了这个错误。

即使你有,你的dhclient输出也是预料之中的

 alias{ fixed-address 

这是因为这是一个alias ,如在该接口的额外的IP地址; 界面还得到了dhcp分配的ip。

关于lease的其他人是正确的,基本上它被忽略,除非DHCP失败。