Re: DHCP connection time



On Wed, 28 Mar 2007 19:58:52 -0500, Rehceb Rotkiv wrote:
On Wed, 28 Mar 2007 22:21:46 +0000, Bit Twister wrote:

That is kinda funny question.

Why?


You asked
"where can I see how long my DHCP internet connection is already running"

and I was refering to /how long has the connection been running/ part
of the question.

Doing an "uptime" on my box shows
23:04:54 up 16 days, 11:05,

So for me, the dhcp connection has been up 16 days, 11 hours, minutes,
because I have yet to reboot the network.

But checking time stamp on the lease file
ls -al /var/lib/dhcp/dhclient-eth1.leases
-rw-r--r-- 1 root root 8702 Mar 28 13:05 /var/lib/dhcp/dhclient-eth1.leases
and using it's contents we see

Obtained Wed Mar 28 13:05:58 CDT 2007
Renewal 2007/3/29 04:55:22;
Rebind 2007/3/29 15:05:56;
Expires 2007/3/29 18:05:56;

with a option dhcp-lease-time 86400; which is like yours, a 24 hour
lease time.


I'll guess you look at the lease file and
current date/time and do some math.

man dhclient for location of lease file. hint: ls /var/lib/dhcp/*

The content of the relevant file makes no sense to me:

lease {
interface "eth1";
<snip>
expire 2 2007/3/27 22:22:54;
}

The connection is definitely not from 2007-03-27 as I switched on the PC
a few hours ago, that is on 2007-03-28. After a reconnect the file looks
like this:

Lease file is looking pretty normal as far as it goes.
You get a new "lease" stanza every time you get a new lease.

The last stanza is normally the one of interest, assuming it is within
the lease time as the dhcp server is concerned.


lease {
interface "eth1";
fixed-address 192.168.0.5;
option subnet-mask 255.255.255.0;
option routers 192.168.0.1;
option dhcp-lease-time 86400;
option dhcp-message-type 5;
option domain-name-servers 192.168.0.1;
option dhcp-server-identifier 192.168.0.1;
option dhcp-renewal-time 43200;
option dhcp-rebinding-time 75600;
renew 4 2007/3/29 10:04:03;
rebind 4 2007/3/29 21:45:52;
expire 5 2007/3/30 00:45:52;
}

Now I see the correct lease time (00:45), strangely in GMT and not in my
local timezone.

Curious, how do you know it is in GMT. :)
Then again it would depend on what time your router/dhcp server has.

"Expire 5" is also clear, it's the expiration time
(+24h). But I do not understand what the other times are supposed to
mean, as they refer to the past!?

I guess you are talking about the lease { } stanza times.
They are the old dhcp lease event stanzas.

The /option dhcp*time/ lines are seconds to their event relative to the last
lease obtained from the dhcp server.

And why didn't I get the correct lease time before the reconnect?

I maintain you received the correct lease time and did not know the
stanzas are the old values from network/bootup/renew events.

I would be glad if you could shed some light on this!

In a nutshell, your dhcp client will contact the dhcp server to renew the
"lease". The renew, rebind and expire times are when they need/may happen.

The client can attempt to get a renewal 43200 seconds from the last
renewal time. See that is a relative value and is not going to be
easy to get the /how long has the connection been running/ time. :)

Looking at the lease { } data all you know is the lease was renewed
sometime before the "expire" date/time. :(

If you are wanting to keep the same ip address, you need to renew the
"lease" before the rebind time expires and if you want to keep the
connection you need to renew before the expire time.

.



Relevant Pages

  • Re: Advanced WinINet - Please HELP!
    ... You'd have to actually verify that DHCP packets are making it through the ... when the lease expires without the device being able to renew it first. ... You can detect that a connection has changed and terminate your current ... or whatever), you could trigger the FTP process, again. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: dhcp-client cleanup
    ... Internet Systems Consortium DHCP Client V3.0.3 ... when the client gets it's first lease. ... and leaves me in a "funny" state where further attempts to bring up the connection manually just fail..otoh as I mentioned earlier.. ...
    (comp.os.linux.networking)
  • Re: DHCP too slow - trying to cache
    ... wi-fi television remote control designed to be used in the home. ... the wi-fi connection is to be kept off as much as possible ... I'm seeing 30 seconds or more when DHCP is ... Even if you've reconnected before the lease expires, ...
    (microsoft.public.windowsce.app.development)
  • Re: DHCP too slow - trying to cache
    ... So, when you *don't* use DHCP, the connection is 20-30 seconds faster? ... > wi-fi television remote control designed to be used in the home. ... Even if you've reconnected before the lease expires, ...
    (microsoft.public.windowsce.app.development)
  • Re: dhclient in 6.0
    ... Not really, no, except when DHCP options appear to turn off IPv4LL, or ... I think it's pretty obvious you have a rogue client ... if there was a prior lease matching the ... Ironically, ISC DHCP was built from this mindset, from what I read. ...
    (freebsd-stable)