windows - 只需知道MAC地址即可获取IP

标签 windows batch-file networking

我正在尝试编写一个批处理文件,它可以返回 IP,但我只知道 MAC 地址

arp -a

对我来说不起作用,因为我以前从未 ping过该 IP。我想在网络中搜索它,只需知道 MAC 地址即可。

Information: The IP is static.

最佳答案

假设您的子网是 192.168.1.xxx

@echo off
REM clear arp cache (optional):
arp -d
REM ask everybody on the subnet for a response:
for /l %%a in (1,1,255) do start /b ping -n 2 -w 500 192.168.1.%%a >nul
REM wait for the processes to finish:
timeout 2 >nul
REM show the responses (with IP and MAC):
arp -a

找到 IP 后,您可以尝试使用以下方法解析计算机名称:

ping -a -n 1 192.168.1.xxx

编辑找到了一种加快速度的方法。

关于windows - 只需知道MAC地址即可获取IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38076523/

相关文章:

networking - Mikrotik - 添加第二个 WAN IP 并路由特定流量

c - 针对自定义 Linux 内核编译简单 C 程序的问题

arrays - 批量嵌套变量

c++ - 线程数不同,答案不同

windows - 如何创建 Windows 服务来运行 powershell 脚本?

c - Windows 上的 read() 系统调用无法读取二进制文件

batch-file - 检查密码时批处理 If 语句不起作用

batch-file - 批处理文件底部的单个退出是否多余?

java - 为java创建.bat文件

c++ - 需要 1 个千兆 NIC 卡的精确带宽公式