我想ping一个已知的MAC地址,我尝试使用nmap:
sudo nmap -sP 192.168.15.1/24 | grep 20:64:32:3F:B1:A9但在本例中,它ping所有255个IP地址(从192.168.15.1到192.168.15.255),直到获得我的MAC地址,这需要大约4秒的长时间。!
有什么想法吗?
发布于 2013-01-31 00:04:54
使其更快的唯一方法是测试mac地址是否已经存在于arp表中。
#!/bin/bash
# extract ip from local arp table
ip=$(arp | grep 20:64:32:3F:B1:A9 | awk ' { print $1 } ')
# found an ip tied to the mac address?
if [ ! -z $ip ]; then
# if found, do you want to ping it?
ping $ip
else
echo "Not found into local arp table. Trying another way..."
# wanna try your nmap strategy?
# sudo nmap -sP 192.168.15.1/24 | grep 20:64:32:3F:B1:A9
fi;发布于 2013-03-20 06:01:29
您无法ping通MAC地址。您只能ping一个IP地址,因此您要做的是找出哪个IP地址属于某个MAC地址,然后ping该IP。ARP用于查找具有特定IP地址的机器的MAC地址,但您不能真正地进行相反的操作(从技术上讲,存在一种称为Reverse ARP的协议,但它从未在典型操作系统中使用过)。一旦找到MAC地址,它将被保存在ARP缓存中,这样您就不必在几分钟内再次查找它,但这不是查找MAC的可靠方法,因为条目不会在缓存中停留很长时间。您已经知道如何创建静态条目,但是如果您将192.168.15.196硬编码到该MAC地址,为什么不直接ping 192.168.15.196 (这就是您要做的全部工作)?
发布于 2013-08-15 22:18:59
nmap提供了-T选项来加速这类操作。-T 5是最快的。
您还可以尝试使用--min-parallelism选项。
https://stackoverflow.com/questions/14600466
复制相似问题