Sep 21, 2009

DHCP on PCs: Lease-Time

Everyone knows DHCP. Yes your PC gets something like a lease for a time...
Do you know how to ask your PC, when this lease expires?
This is not very difficult:
On Windows:
ipconfig /all

Ethernetadapter Drahtlose Netzwerkverbindung:

Verbindungsspezifisches DNS-Suffix: mydomain.me
Beschreibung. . . . . . . . . . . : Intel(R) PRO/Wireless 2200BG Network Connection
Physikalische Adresse . . . . . . : 00-12-34-56-78-90
DHCP aktiviert. . . . . . . . . . : Ja
Autokonfiguration aktiviert . . . : Ja
IP-Adresse. . . . . . . . . . . . : 192.168.18.21
Subnetzmaske. . . . . . . . . . . : 255.255.255.0
Standardgateway . . . . . . . . . : 192.168.18.1
DHCP-Server . . . . . . . . . . . : 192.168.18.1
DNS-Server. . . . . . . . . . . . : 192.168.18.1
Lease erhalten. . . . . . . . . . : Dienstag, 22. September 2009 20:58:40
Lease läuft ab. . . . . . . . . . : Freitag, 2. Oktober 2009 20:58:40
On Linux:
cat /var/lib/dhcp3/dhclient.leases
lease {
interface "eth1";
fixed-address 192.168.18.21;
option subnet-mask 255.255.255.0;
option routers 192.168.18.1;
option dhcp-lease-time 864000;
option dhcp-message-type 5;
option domain-name-servers 192.168.18.1;
option dhcp-server-identifier 192.168.18.1;
option dhcp-renewal-time 432000;
option ntp-servers 192.168.18.1;
option broadcast-address 192.168.18.255;
option dhcp-rebinding-time 756000;
option domain-name "mydomain.me";
renew 6 2009/09/26 15:58:34;
rebind 3 2009/09/30 12:17:44;
expire 4 2009/10/01 18:17:44;
}
This is ok, but what if you use a black box as router, where you can not adjust the dhcpd parameters? Something like changing the lease time, because 756000s=210h=8.75d is really to long for a network, where you use computers only on a hourly base...
On Linux you can configure your client very easy:
Add inside /etc/dhclient.conf the following line
send dhcp-lease-time 3600;
After this little change start dhcp with
dhclient -cf /etc/dhclient.conf
and your lease details show:
option dhcp-lease-time 3600;
option dhcp-renewal-time 1800;
option dhcp-rebinding-time 3150;
On Windows this is nearly impossible:
There is a nice starting point provided by Microsoft: http://support.microsoft.com/kb/121005. But with this information you only know that you have to add the following key inside the registry:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Dhcp\Parameters\Options\51
With the explanation given there
Lease Time (51): This option is used in a client request (DHCPDISCOVER or DHCPREQUEST) to allow the client to request a lease time for the IP address. In a server reply (DHCPOFFER), a DHCP server uses this option to specify the lease time it is willing to offer. The time is in seconds, and is specified as a 32-bit unsigned integer. The code for this option is 51, and its length is 4.
it is not possible without any futher documentation to create the appropriate keys and values ... ;-(

2 comments:

  1. Great goods frkm you, man. I have understand your stuff previous to and you are jus extremely magnificent.
    I actually like what you've acquired here, really like whaat you are saying and the way in which you say it.
    You make it entertaining and you still take care of to keep it smart.
    I cant wait to read far more from you. This is really a great website.

    ReplyDelete
  2. I am curious to find out what blog syatem you have been utilizing?
    I'm havin some minor security issues with my latest website annd I'd like to find something more safe.
    Do you have any suggestions?

    ReplyDelete