WalkingZero has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use Net::ARP; use Net::Netmask; use Net::Frame::Simple; use Net::Frame::Dump::Online; my $dev= "eth1"; $interface= shift; $ifconf= `ifconfig $dev`; $ifconf=~ /\d+\.\d+\.\d+\.\d+/; $ipdec= $&; $ifconf=~ /Mask:\d+\.\d+\.\d+\.\d+/; $nmaskdec= $&; $nmaskdec=~s/Mask://; my $netblock= $ipdec . ":" . $nmaskdec ; $netmask=new Net::Netmask ($netblock); my @iprange = $netmask->enumerate; $arpDump=Net::Frame::Dump::Online->new( dev => $dev, filter => 'arp'); $arpDump->start; my %livehosts; my $reply; $counter=0; while ($counter<3){ for $ipts (@iprange){ Net::ARP::send_packet($dev,$ipdec,$ipts,"00:18:de:34:8e:7b","f +f:ff:ff:ff:ff:ff","request"); } until ($arpDump->timeout){ if ($next=$arpDump->next){ my $r=Net::Frame::Simple->newFromDump($next); $opc=$r->ref->{ARP}->opCode; next unless $opc == 2; $livehosts{$r->ref->{ARP}->srcIp}=$r->ref->{ARP}->src; } } $arpDump->timeoutReset; $counter++; } foreach $key (keys %livehosts){ print "IP Address $key is up with mac of $livehosts{$key} \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ARP Lookups
by grinder (Bishop) on May 25, 2008 at 14:56 UTC | |
by oko1 (Deacon) on May 25, 2008 at 18:43 UTC | |
by grinder (Bishop) on May 25, 2008 at 20:24 UTC | |
by oko1 (Deacon) on May 26, 2008 at 02:44 UTC | |
by Anonymous Monk on Jun 01, 2008 at 11:03 UTC | |
| |
by WalkingZero (Sexton) on May 25, 2008 at 18:35 UTC | |
by starbolin (Hermit) on May 25, 2008 at 19:32 UTC | |
by WalkingZero (Sexton) on May 25, 2008 at 23:23 UTC | |
|
Re: ARP Lookups
by kyle (Abbot) on May 25, 2008 at 14:14 UTC | |
by WalkingZero (Sexton) on May 25, 2008 at 14:17 UTC | |
|
Re: ARP Lookups
by Anonymous Monk on May 25, 2008 at 14:49 UTC | |
by WalkingZero (Sexton) on May 25, 2008 at 23:18 UTC |