标签:dhcp mac ip
通过局域网MAC地址得到IP地址
[root@localhost cli]# cat tmp.sh
function get_all_arp_info()
{
ip -s -s neigh flush all > /dev/nul &
for ip in `seq 2 254`
do
ping 192.168.50.$ip -c1 > /dev/null &
done
}
function from_mac_get_ip()
{
get_all_arp_info
MAC_ADDR=$1
if [[ -n `ip neigh |grep $MAC_ADDR` ]];then
IP_ADDR=`ip neigh |grep $MAC_ADDR|awk ‘{print $1}‘`
echo "MAC_ADDR=$MAC_ADDR IP_ADDR=$IP_ADDR"
else
echo "did match"
fi
}
from_mac_get_ip $1
[root@localhost cli]# sh tmp.sh 52:54:00:51:cd:8e
MAC_ADDR=52:54:00:51:cd:8e IP_ADDR=192.168.50.191
[root@localhost cli]#
本文出自 “Storage” 博客,请务必保留此出处http://xmwang.blog.51cto.com/9889672/1665951
标签:dhcp mac ip
原文地址:http://xmwang.blog.51cto.com/9889672/1665951