Here's my /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;
}
When I run "dhclient eth0", I get this:
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.
I used strace to make sure that dhclient really is reading that conf file. Why isn't it paying attention to my "fixed-address 192.168.1.222" line? Why is it doing a DHCPREQUEST for 192.168.1.27 instead?
As Zoredache correctly pointed out: the fixed-address setting is only for lease definitions that are effective only if the DHCP server does not respond. See http://linux.die.net/man/5/dhclient.conf under section "Lease Declarations".
What you want is
This is documented in the manpage of dhcp-options: http://linux.die.net/man/5/dhcp-options and conforms to the DHCP Options RFC available at http://www.rfc-editor.org/rfc/rfc2132.txt
Take note though: I lately run into dhclient3 not getting an IP with this configuration as the requested address was already taken. The server replies with DHCPNAK to the request, and the client will give up after a while. I had expected that the DHCP client will eventually end up with another address if the requested one is not available.
I used this approach in an attempt to make sure that I always know the address of my server without resorting to stuff like dyndns.com and ended up with no connectivity instead.
Reject is for rejecting offers from servers with a specific address. It is not there to reject addresses the server offers.
A defined lease is only used if the DHCP Server does not respond.
If you want a particular address you should probably setup a reservation on the server.
Did you actually check if it's accessible via your specified ip (back in 2010, i know...)?
I made that mistake just now.
Your dhclient-output is expected even though you have
That's because thats an
alias
, as in an additional ip address of that interface; the interface still also get's the dhcp-assigned ip.Regarding the
lease
the others are correct, basically it's ignored unless dhcp fails.