Tuesday, July 12, 2011

Access to the same network segment the MAC address of all machines

#! / Bin / bash 
for  ( ( i = 1 ; i <  254 ; i + + ) ) 
do 
        arping -I eth0 192.168.0. $ i  -c  1 
done 
arp -a  >  / tmp / mactable.txt
The following is the result of testing and revision:
#! / Bin / bash 
for i in $ ( seq  1  255 ) 
do 
        ping  -C1  -W1 192.168.0. $ i   2 > & 1  >  / dev / null
         IF  [  $?  -eq  0  ] 
        then 
              arp -a   |  grep  "(192.168.0. $ i ) "  >> mac.txt
          Fi 
done