Discovering DHCP linux device

This is a discussion on Discovering DHCP linux device within the Linux Networking forums, part of the Linux Forums category; Hi, I have built a small linux machine that I take with me to work on customer's sites, but ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-17-2007
thewozza
 
Posts: n/a
Default Discovering DHCP linux device

Hi,

I have built a small linux machine that I take with me to work on
customer's sites, but one thing I would like is a way to detect the
machine on their network.

If I were the systems administrator there, I could go through the DHCP
server logs and find it. But I'm not, and it just seems a little
unprofessional to have to ask for help to find my own hardware.

I know I could sniff the traffic and look for DHCP transactions, but
this is (by and large) a one time event which means I have to be
watching while the thing comes online. And it is again a little
unprofessional as it is quite cumbersome to be poring through sniffer
data to find my own hardware.

What I would do is write a script with netcat that broadcasts the
device's presence periodically, and have another application on my
laptop to listen for these broadcasts. As long as we're on the same
LAN I should be able to detect those broadcasts, and then I will know
the IP to manage the machine.

I can create this script, but I'm posting this to see if there are any
linux projects already underway that meet my requirements. I know
that my NAS (Infrant) uses a similar approach to managing those
systems, so something like that would do the trick.

Thanks,

Paul
Reply With Quote
  #2 (permalink)  
Old 12-18-2007
thewozza
 
Posts: n/a
Default Re: Discovering DHCP linux device

On Dec 17, 3:03 pm, thewozza <paulwoz...@gmail.com> wrote:
> Hi,
>
> I have built a small linux machine that I take with me to work on
> customer's sites, but one thing I would like is a way to detect the
> machine on their network.
>
> If I were the systems administrator there, I could go through the DHCP
> server logs and find it. But I'm not, and it just seems a little
> unprofessional to have to ask for help to find my own hardware.
>
> I know I could sniff the traffic and look for DHCP transactions, but
> this is (by and large) a one time event which means I have to be
> watching while the thing comes online. And it is again a little
> unprofessional as it is quite cumbersome to be poring through sniffer
> data to find my own hardware.
>
> What I would do is write a script with netcat that broadcasts the
> device's presence periodically, and have another application on my
> laptop to listen for these broadcasts. As long as we're on the same
> LAN I should be able to detect those broadcasts, and then I will know
> the IP to manage the machine.
>
> I can create this script, but I'm posting this to see if there are any
> linux projects already underway that meet my requirements. I know
> that my NAS (Infrant) uses a similar approach to managing those
> systems, so something like that would do the trick.
>
> Thanks,
>
> Paul


Okay so I got impatient and just ended up writing my own stuff. It
isn't pretty, but I can output periodic broadcasts with netcat on my
headless linux device, and I have a reasonably cumbersome method of
capturing and parsing the data from tshark on my laptop. So now I can
show up and be confident that I can find my hardware without having to
go through too many hoops.

RADAR-ADVERTISE.pl
#!/usr/bin/perl

$interval = 10; # defines the broadcast period in seconds

# open netcat as a filehandle
open (FILE, "|nc -b -u 255.255.255.255 9999 -p 9999");

# mark the NC filehandle as hot, so we're not buffering the output
{ my $ofh = select FILE;
$| = 1;
select $ofh;
}

# go forever! because I can't think of any good reason to stop
# it would probably be better to kill the loop and move this into a
cronjob if you're doing it once a minute
while (1) {
print FILE "LOOK IT IS ME!\n";
sleep $interval;
}

exit 0; # clear memory on exit

RADAR-DETECT.pl
#!/usr/bin/perl

# use tshark to grab data from the network port. we're watching for
udp port 9999 and IP broadcast
# this is very flexible, I used both vectors to ensure that most real
network data is filtered out
# you probably need to be root to sniff with tshark - sorry
# if being root is a big deal for you, you could probably use netcat
to grab the data
open (FILE, "tshark -l -R \"ip.dst == 255.255.255.255 and udp.dstport
== 9999\"|");

while (<FILE>) {
chomp;
$_ =~ s/^\W*//; # whitespaces are bad
($tdata, $source, $cruft) = split / /, $_;
print "$source\n"; # print the source IP of the device broadcasting
}

exit 0;
Reply With Quote
  #3 (permalink)  
Old 12-18-2007
Joe Beanfish
 
Posts: n/a
Default Re: Discovering DHCP linux device

thewozza wrote:
> Hi,
>
> I have built a small linux machine that I take with me to work on
> customer's sites, but one thing I would like is a way to detect the
> machine on their network.
>
> If I were the systems administrator there, I could go through the DHCP
> server logs and find it. But I'm not, and it just seems a little
> unprofessional to have to ask for help to find my own hardware.
>
> I know I could sniff the traffic and look for DHCP transactions, but
> this is (by and large) a one time event which means I have to be
> watching while the thing comes online. And it is again a little
> unprofessional as it is quite cumbersome to be poring through sniffer
> data to find my own hardware.
>
> What I would do is write a script with netcat that broadcasts the
> device's presence periodically, and have another application on my
> laptop to listen for these broadcasts. As long as we're on the same
> LAN I should be able to detect those broadcasts, and then I will know
> the IP to manage the machine.
>
> I can create this script, but I'm posting this to see if there are any
> linux projects already underway that meet my requirements. I know
> that my NAS (Infrant) uses a similar approach to managing those
> systems, so something like that would do the trick.
>
> Thanks,
>
> Paul


A different way to look at it might be to stick an lcd on the device
so it can display it's ip.

http://www.seetron.com/slcds.htm
http://www.hobbyengineering.com/H2078.html
Reply With Quote
  #4 (permalink)  
Old 12-23-2007
Stefan Monnier
 
Posts: n/a
Default Re: Discovering DHCP linux device

> I have built a small linux machine that I take with me to work on
> customer's sites, but one thing I would like is a way to detect the
> machine on their network.


If you know the network's IP range, then `nmap' should have no trouble
finding your device.


Stefan
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:28 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0