Changeset 9

Show
Ignore:
Timestamp:
12/07/06 13:47:24 (2 years ago)
Author:
Karl Vollmer
Message:

added auto eth/hwa detection

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dhcpdetector.pl

    r8 r9  
    4949use Net::SMTP; 
    5050use Sys::Syslog; 
     51use Data::Dumper; 
    5152 
    5253use strict; 
     
    6566# CONFIG SECTION 
    6667#  
    67 # list of IP addresses of authorized DHCP servers on your network 
    6868# put the hwa of any 'legitimate' dhcp servers or dhcp forwarding  
    6969# routers in this list. 
     
    7777# the bait is sent from these addresses 
    7878# XXX - cant we just use our real one(s) automagically??? 
    79 my %ifaces = ('eth0.0237' => '00:00:00:00:00:00', 
    80               'eth0.0238' => '00:00:00:00:00:00', 
    81               'eth0.0255' => '00:00:00:00:00:00', 
    82 ); 
     79my @iface = split("\n",`ifconfig | grep "HWaddr"`); 
     80my %ifaces = ''; 
     81 
     82for my $row (@iface) {  
     83        $row =~ /(eth\d\.?\d*)\s+Link encap:Ethernet\s+HWaddr\s+([\d\:\A-Fa-f]+)\s*/; 
     84        $ifaces{$1} = $2; 
     85
    8386 
    8487