windows – 从MAC地址获取IP. arp -a没有显示设备

前端之家收集整理的这篇文章主要介绍了windows – 从MAC地址获取IP. arp -a没有显示设备前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试编写一个批处理文件,当它连接到网络(Tenda WiFi路由器)时,应该找到我的 Android手机动态分配的IP.

所以我正在尝试使用arp -a并搜索我手机的MAC地址,以便从表中获取IP.

  1. C:\Users\Leeroy>arp -a
  2.  
  3. Interface: 192.168.0.100 --- 0xb
  4. Internet Address Physical Address Type
  5. 192.168.0.1 c8-3a-35-35-f6-68 dynamic
  6. 192.168.0.255 ff-ff-ff-ff-ff-ff static
  7. 224.0.0.22 01-00-5e-00-00-16 static
  8. 224.0.0.251 01-00-5e-00-00-fb static
  9. 224.0.0.252 01-00-5e-00-00-fc static
  10. 239.255.255.250 01-00-5e-7f-ff-fa static
  11. 255.255.255.255 ff-ff-ff-ff-ff-ff static

问题是它没有出现在表中!我试过ping 192.168.0.255,但它仍然没有出现.我尝试从手机的浏览器请求192.168.0.100(我的桌面电脑的IP),这确实足以让手机上雷.但是每次我希望它出现在arp表中时,我都没有选择手动执行此操作.

如何让Android手机出现在arp表中(除了连​​接到WiFi之外没有做任何事情)?

解决解决ping.它不会超过一两秒钟.
编辑2:更新了一些.这是最终的批处理文件

  1. @echo off
  2. :top
  3. :: Loop through arp table entries and look for my Android device's MAC address
  4. for /f "tokens=1-5 skip=3" %%f in ('arp -a') do (if "%%g"=="xx-xx-xx-xx-xx-xx" set ip=%%f)
  5.  
  6. if "%ip%"=="" (
  7. echo Discovering network...
  8. :: Ping all IPs from 192.168.0.1 to 254
  9. for /L %%N in (1,1,254) do start /b ping -n 1 -w 200 192.168.0.%%N >nul
  10. timeout 1 >nul
  11. goto :top
  12. ) else (
  13. echo Mapping network location to drive K
  14. net use k: http://%ip%:8080 /user:francis underwood /persistent:no
  15. if exist k: explorer k:
  16. :: Using FTP (please configure user and pass)
  17. :: explorer ftp://user:pass@%%f:6262
  18. )
  19. )
我试过这个并且它有效:
  1. for /L %N in (1,254) do start /b ping -n 1 -w 200 192.168.0.%N

如果手机启用了ICMP,您应该没有问题.

猜你在找的Windows相关文章