Expert peeps,
I recently started attempting to gain some control over Dhcp. The
leases file at /var/lib/dhcp/dhcpd.leases seems to be key in controlling
what mac addresses are assigned what IP's.
I need to assign a more or less permanent ip address to a particular
mac...via dhcp, of course. There is a winblows machine here on the net
that needs to get the same ip every time it's booted. For awhile the
dhcp server was assigning 192.168.0.250 to the Win box...and life was
good. Windows was reinstalled, and then the LM82 dhcp server decided
that it was time to expire the lease for some reason, even though the
mac address was the same: evidently related to reinstallation of
winblows, but I'm not sure why. Apparently more than the mac address is
involved. The dhcp server then put the winbox at 192.168.0.249, and put
some lines in the /var/lib/dhcp/dhcpd.leases file saying that 250 was
available. Here it is:
[root@mail dhcp]# tail -n 18 dhcpd.leases
lease 192.168.0.18 {
binding state free;
}
lease 192.168.0.17 {
binding state free;
}
lease 192.168.0.16 {
binding state free;
}
lease 192.168.0.249 {
starts 1 2002/10/14 08:42:05;
ends 1 2002/10/14 14:42:05;
binding state active;
next binding state free;
hardware ethernet 00:68:62:27:95:08;
uid "\001\000`g%\221\007";
client-hostname "Tomcat";
}
[root@mail dhcp]#
There is a "default-lease-time 21600;" statement in the /etc/dhcpd.conf
file. This is the factory setting, and it seems to equate to 5 hours.
So therefore any IP address that's given out by the dhcp server is only
good for that amount of time. To adjust for that I increased the number
to this:
range dynamic-bootp 192.168.0.16 192.168.0.253;
default-lease-time 35697000;
max-lease-time 71394000;
That adjustment put the new IP lease expiration in december of 2003.
Like so:
lease 192.168.0.249 {
starts 1 2002/10/14 09:24:32;
ends 1 2003/12/01 13:14:32;
binding state active;
next binding state free;
hardware ethernet 00:68:62:27:95:08;
uid "\001\000`g%\221\007";
client-hostname "Tomcat";
}
This will not work for an existing lease; you must eliminate all old
lease entries under
lease 192.168.0.16 {
binding state free;
}
in the /var/lib/dhcp/dhcpd.leases file, and restore all entries to
factory default at the TOP of the file, then allow the dhcp server to
create a new lease when it is asked for an IP. The dhcp server enters
active entries at the bottom and removes them from the top of the file
as it gives leases. To get an entry taken from the top and recorded at
the bottom, you have to stop the dhcp server, fix the dhcp.leases file
(to factory default), restart the server, and then get the winbox to ask
for an IP address. This creates a new entry at the bottom of
/var/lib/dhcp/dhcpd.leases with the right mac address and improved
expiration date.
I should also mention that in this process the
/var/lib/dhcp/dhcpd.leases~ file needs to be removed before the dhcp
server is restarted.
Although I had forstalled the dhcp server from changing the winbox IP
every five hours, I still had some unanswered questions. Such as:
1) Was there an easier way to assign a specific IP address to a MAC
hardware address within the /etc/dhcpd.conf file?
2) Was there a way to make the specific IP address permanent?
The answer was yes to both. I found the answer within the only help
file that was in the dhcp server directory,
/usr/share/doc/dhcp-server-3.0/dhcpd.conf. In that was a statement that
seemed to fit the bill:
-----------------------------------------------------------------
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can
# only be booted with DHCP, unless there is an address range on the
# subnet to which a BOOTP client is connected which has the
# dynamic-bootp flag set.
host fantasia {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address fantasia.fugue.com;
}
-----------------------------------------------------------------
After inserting that statement into the dhcpd.conf with the right
adjustments, the winbox was effectively using the dhcp server to get a
permanent IP.
Hope this helps someone with a similar problem.
L8r,
LX
--
���������������������������������������������������
Kernel 2.4.18-6mdk Mandrake Linux 8.2
Enlightenment 0.16.5-11mdk Evolution 1.0.2-5mdk
Registered Linux User #268899 http://counter.li.org/
���������������������������������������������������
Want to buy your Pack or Services from MandrakeSoft?
Go to http://www.mandrakestore.com