11

How can i configure ISC DHCP server to infinite lease time for all clients?

man dhcpd:

Lease Lengths DHCP leases can be assigned almost any length from zero seconds to infinity. What lease length makes sense for any given subnet, or for any given installation, will vary depending on the kinds of hosts being served.

but dhcpd completely not works with the zero lease-time value:

ddns-update-style none;
#option domain-name "dobisel.com";
option domain-name-servers 8.8.8.8,8.8.4.4;
default-lease-time 0; <---- here
max-lease-time 0; <----- here
authoritative;
log-facility local7;

subnet 192.168.11.0 netmask 255.255.255.240 {
  range 192.168.11.2 192.168.11.14;
  option routers 192.168.11.1;
  option broadcast-address 192.168.11.15;
  option subnet-mask 255.255.255.240;
}
  • 2
    This is an ancient question, but I found it so others might. The question shows a lack of understanding of DHCP. The lease expiring does not mean "the client will get a different IP". The client will request the same IP again. You should set the lease to longer than the maximum time a client will be offline for. So 30 days would probably get what @pylover wanted all those years ago, but still make it possible to change settings without dealing with infinitely stuck leases. – Cylindric Jul 5 '19 at 15:13
17

It is not mentioned explicitly in the manpage, but setting lease time to -1 in any of the options you mention,

default-lease-time -1;
max-lease-time -1;

is effectively disabling the expiry time of the leases, so their expiration will be effectively set "to infinity".

4

You should not configure an infinite lease time. The reason of having DHCP is to have a central management and flexibility. Making the lease time infinite, you will kill the flexibility.

  • 1
    i want to users join my network without any configuration and communicate each other by dedicated ip address for ever. this is simplicity, automation and stability. just remember a morning in your office you cannot view a shared-folder on a computer because of lease-expiration of a computer.how can i forget automation and stability on the way of flexibility ? – pylover May 10 '13 at 20:25
  • Why don't you use static leases? – Mircea Vutcovici May 10 '13 at 20:29
  • 1
    ok, so i need to spend some times to gathering mac addresses, and configuring associated address for each. – pylover May 10 '13 at 20:31
  • 1
    You could create a script that is adding all new hosts to the static lease list. This script could send you an email when you run out of IP addresses in that pool. Or send you an email each time a new IP/MAC was detected in the network. In this way you have the convenience of DHCP, you have the same IP assigned to the same NIC. And you have full control to change all this in a instant if you need it, and you can have static IPs too if you must. Modern DHCP server can be instructed to send an ARP request before assigning a lease for an IP. – Mircea Vutcovici Nov 10 '14 at 14:50
  • 1
    Or maybe his idea is a good one. He just wants to attribute IP addresses easily. If the DHCP range becomes completely full my guess is he could make a script to cleanup the dhcpd.leases files – Florent Aug 8 '15 at 18:03
3

I would suggest specifying lease times in seconds. So where:

default-lease-time 600; This being ten minutes
max-lease-time 7200; This being two hours

try:

default-lease-time 86400; This being one day
max-lease-time 604800; This being one week

You could try 2592000 which is 30 days.

    I wouldn't exceed that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.