2

My ubuntu machine is receiving a renewal time of 7000 seconds from the DNS server. I want to change this on the ubuntu machine to be longer via the dhclient.conf. I can't change the dhcp sever.

However all the examples I try don't seem to be the correct syntax. For instance if I add at the top of the .conf to request a lease time of 6000, I get no change. I've also tried

min-lease-time infinite;
max-lease-time infinite;

as global variables.

#send host-name "andare.fugue.com";
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
send dhcp-lease-time 6000;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, host-name,
    netbios-name-servers, netbios-scope;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/etc/dhcp3/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

Any ideas, seems like it should be easy to do?

TIA

James MV
  • 8,569
  • 17
  • 65
  • 96

3 Answers3

6

In my case the solution was to add in dhclient.conf :

supersede dhcp-lease-time the_value_i_want;

This override the lease time given by the server.

By the way this set the expiration time, the renewal (T1) and rebind (T2) times are calculated by the client (something like 1/2 and 7/8 of the lease time).

bwt
  • 17,292
  • 1
  • 42
  • 60
  • Excellent and very helpful answer. If your dhclient is spawned by NetworkManager, have a look at https://unix.stackexchange.com/questions/38641/how-to-set-dhclient-options-for-networkmanager – JFlo Mar 21 '18 at 20:25
  • Caveats: I wanted to shorten a ridiculously long lease time (8 days) to something like 5 minutes for testing DHCP event hook scripts. While the above does affect the lifetime (as seen for `valid_lft` in `ip addr` output), once the time is up, the IP address is revoked rather than renewed. I'm guessing renewal would still occur 8 days out, but that's not what I'd hoped for. – JFlo Mar 21 '18 at 20:38
  • Follow up to my caveat. Instead of superseding the `dhcp-lease-time`, I found the following to give me frequent renewals: `supersede dhcp-rebinding-time 300; supersede dhcp-renewal-time 200;` – JFlo Mar 21 '18 at 21:05
1

The documentation on client side says

option dhcp-lease-time uint32; 

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.

deimus
  • 9,565
  • 12
  • 63
  • 107
-2

I changed lease duration from router settings

LAN interface -> DHCP server -> lease duration