[plug] ip address and interface question (new)

Daniel Foote freefoote at gmail.com
Mon Jun 26 17:37:28 WST 2006


> > I do the same thing at home - also works really great for LAN
> > parties... (Plus PHP magic for a intranet list of connected computers,
> > with their names).
>
> Sounds interesting... Want to share? I assume if a computer reboot's,
> then it'll still be on the list until the DHCP Lease expires?

Attached to this email is a PHP script that will do this.

It's not pretty... especially the output. I've modified it a bit from
my original copy, because my original does other things like integrate
nicely with the rest of the pages that machine was serving up during
the last LAN party.

It reads the leases information from the dhcpd.leases file that dhcpd
writes. The code itself only shows machines that sent a hostname, and
also only shows the most recent lease for a host, due to some oddities
with the dhcpd.leases file.

If you reboot a specific machine... the lease remains the same because
the leases last for 15 hours on my network (I don't recall why that
number was chosen - must have sounded good at the time).

The only thing to keep in mind is that Debian Linux, by default, will
not send its hostname when it grabs a DHCP lease. You have to edit
/etc/dhclient.conf and add a 'send host-name "calmah";' line to it
(replacing "calmah" with the name of your machine).

When I ran that script a few moments ago on my fileserver, I got from it:

IP  	Hostname  	Mac  	Granted (UTC)  	Expires (UTC)
10.41.61.75 	homeinventory.lan 	00:50:8b:72:37:8e 	1151200333 	1151286733
10.41.61.138 	moose.lan 	00:30:65:17:1d:55 	1151208614 	1151295014
10.41.61.101 	hebridan.lan 	00:a0:c9:71:bc:53 	1151213509 	1151299909
10.41.61.148 	velona.lan 	00:80:a3:18:09:10 	1151266256 	1151352656
10.41.61.48 	quokka.lan 	00:13:72:1a:7a:18 	1151273278 	1151359678
10.41.61.102 	calmah.lan 	00:a0:c9:2a:dc:01 	1151283490 	1151369890

(In the list above, moose.lan isn't currently on the network, but it
was less than 15 hours ago - once the lease expires, dhcpd purges it
from the list and then you won't see it anymore. Use shorter leases if
this really bothers you).

I have not converted the times into anything - they are just unix
timestamps. For the "production" one I was running the final array was
pumped into a smarty template for rendering... so the date/time
formatting was trivial in that.

Anyway, have fun. All licenced under the LGPL, if you do use it.

Daniel Foote.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.php
Type: application/x-php
Size: 4103 bytes
Desc: not available
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20060626/954d241f/attachment.bin>


More information about the plug mailing list