I was thinking about this some more...  if we simply took the leased IP address 
and stuffed it up into:

config 'wan'
        option ipaddr x.x.x.x

in network, the /lib/network/config.sh script would then try to request that 
address the next time the box rebooted.

If the address was in use, then we'd be NAK'd the address by the DHCP server, 
and we'd retry with no address, right?

So it wouldn't really matter if the lease had expired or not, in the end... 
because the server knows if it has in any case.

-Philip

On 4/12/11 5:02 PM, Nuno Gonçalves wrote:
> Please also note that the real time clock is important for knowing if
> the DHCP lease is still valid.
> Since most routers don't have a hardware RTC, there is no way to know
> it the DHCP lease is still valid before you get WAN connectivity to
> update the time with NTP.
> 
> Nuno
> 
> On Tue, Apr 12, 2011 at 05:15, Stefan Monnier <monn...@iro.umontreal.ca> 
> wrote:
>>> I note that the file /tmp/state/network contains the interface, ip address,
>>> and expiration time of the WAN DHCP lease...  I'm wondering what's
>>> involved in writing that information into somewhere persistent where it
>>> can be reused on reboot?
>>
>> You may want to start by replacing the /var symlink to /tmp by
>> a real directory.  OpenWRT should be using the /var/state/network
>> filename, so after performing the above change, the file will be
>> preserved across reboots.  If not, report it as a bug.
>> I'm not sure if OpenWRT will later start udhcpd in such a way as to take
>> advantage of this pre-existing file, but that's a second step.
>>
>>
>>        Stefan
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to