16

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;
}
pylover
  • 708
  • 3
  • 9
  • 15
  • 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 05 '19 at 15:13

3 Answers3

24

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".

dawud
  • 14,918
  • 3
  • 41
  • 61
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.

Mircea Vutcovici
  • 16,706
  • 4
  • 52
  • 80
  • 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
  • 2
    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 08 '15 at 18:03
  • Changing the lease file will not determine the DHCP client to renew DHCP information. You will have to manually configure each client to renew the lease. Which defies the purpose of DHCP. Remember with DHCP you set not only the IP/MASK/DefaultGateway, but also DNS, Proxy which might change in time. – Mircea Vutcovici Aug 09 '15 at 12:29
4

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.
user199239
  • 43
  • 4
AndreasRZA
  • 59
  • 2