Linuxでarp-scan1.9をインストール、競合IPを判断する方法
1.libpcapとlibcap-develのインストール
[root@localhost src]# yum install -y libcap libcap-devel
[root@localhost arp-scan-1.9]# yum list|grep libpcap
libpcap.x86_64 14:1.4.0-1.20130826git2dbcaa1.el6
libpcap-devel.x86_64 14:1.4.0-1.20130826git2dbcaa1.el6
libpcap.i686 14:1.4.0-4.20130826git2dbcaa1.el6
libpcap.x86_64 14:1.4.0-4.20130826git2dbcaa1.el6
libpcap-devel.i686 14:1.4.0-4.20130826git2dbcaa1.el6
libpcap-devel.x86_64 14:1.4.0-4.20130826git2dbcaa1.el6
2.arp-scan1.9のダウンロード
[root@localhost src]# wget http://www.nta-monitor.com/files/arp-scan/arp-scan-1.9.tar.gz
3.arp-scan1.9のインストール
tar xvf arp-scan-1.9.tar.gz
cd arp-scan-1.9
./configure
make && make install
4.シェルコード:
#!/bin/bash
#check whether the ip is conflict
conflict_ip=`arp-scan -I eth0 -l | grep “^[172.16|192.168|10]" | sort | uniq -c | sort -nr|sed 's/^[ \t]*//g’|grep “^2″`
count=`arp-scan -I eth0 -l | grep “^[172.16|192.168|10]" | sort | uniq -c | sort -nr|sed 's/^[ \t]*//g’|grep “^2″|wc -l`
if [ $count -gt 0 ];then
echo -e “\033[31m conflict \033[0m"
echo -e “conflict ip is \n $conflict_ip "
else
echo “not conflict."
fi