dhcpcd-discuss

Re: How can I reduce time taken to switch from DHCP to Link-local address & vice versa

Roy Marples

Fri Feb 14 10:40:52 2014

Hi

On 14/02/2014 7:05, Jyothsna Rajan wrote:
I use dhcpcd_5.2.12 on my devices , running linux, to obtain DHCP IP.
I have been testing the switch-over from DHCP to link local on loss of
network connectivity and vice-versa when connectivity is restored. I
found that it takes >8mins for the address to change from DHCP to link
local and 2-3 mins to change from link-local to DHCP.

I am using the dhcpcd.conf(5) file as available with the source.
I invoke the client with following command:
dhcpcd -q --reboot 0 --hostname "" -t 16 <ifname>

DHCP server is authoritative and lease-time is set to 600.

I have the following questions:
1. Once a valid DHCP address has been obtained, does the client
take-no-action-but-wait until the lease renewal time has expired ?

 2. What IP will the device have if someone disconnects the device in
the interval after a DHCP address has been obtained but before its
time to renew the lease? Will the device retain its DHCP IP until it
is time to renew at which time dhcpcd "wakes up" and detects there is
no connection and obtains a link local address?
3. How can I force dhcpcd to monitor connection status and switch to
link-local soon as a loss of connection is detected? Can I use the
"NOCARRIER" reason to detect connection status and invoke a hook
script to force change to link-local address?
 4. Similarly, for the case where a device having link-local address
is connected back into a network, is there any configuration parameter
that I can tweak to reduce the time taken to switch back to DHCP
address?
5. Will reducing the DHCP lease time setting help? If so, what is the
minimum value I can set without jeopardizing any other functionality?
I haven't been able to try this because the server is company wide and
i cannot reboot it on a working day.

1. dhcpcd does take action when the kernel reports network connection goes down/up 2. it will start with none. with your config it will discover, timeout after 30 seconds [1] and then negotiate a link local address. 3. it should do this. You cannot force an address change from the commandline, just a reconfigure. 4. when a link local address is configured, dhcpcd will sill periodically ask for a DHCP lease. The timings of this are from RFC2131, but essentially we send one request every few seconds and then more slowly, upto a minute between messages.
5. No

Taking this into account, it seems that your dhcpcd is not listening correctly to link messages or the kernel driver is not correctly reporting them. It could very well be a bug in dhcpcd and it's probably best to try a newer version. If you need to stick with 5.x for whatever reason, you could try and merge the latest code from if-linux.c, link_netlink function into your sources.

Thanks

Roy

[1] In dhcpcd-6.x the default timeout is 30 seconds, I think earlier versions could have been 1 minute or more. You can adjust this with the --timeout <seconds> option.
References:
How can I reduce time taken to switch from DHCP to Link-local address & vice versaJyothsna Rajan
Archive administrator: postmaster@marples.name