判断局域网内是否有冲突的IP

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/bin/bash

# yum -y install arp-scan

#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