【问题标题】:convert IP address to mac address cmd将IP地址转换为mac地址cmd
【发布时间】:2014-06-07 03:12:48
【问题描述】:

我已经找到了很多关于这个问题的答案,但不是批量的。 这就是我得到的。

C:\Users\Colton>arp -a

Interface: 192.168.1.12 --- 0xb
  Internet Address      Physical Address      Type
  192.168.1.1           74-44-01-42-aa-df     dynamic
  192.168.1.11          20-7c-8f-3f-03-9b     dynamic
  192.168.1.255         ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  224.0.0.252           01-00-5e-00-00-fc     static
  224.0.0.253           01-00-5e-00-00-fd     static
  239.255.255.250       01-00-5e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

我只需要自己获取给定 IP 地址的 Mac 地址。我认为findstr命令是我需要的,但我不知道如何使用它。

然后我会使用以下命令将其设置为变量:

for /f "delims=" %%A in ('command_that_I_need') do set "macaddress=%%A"
echo the mac address of 192.168.1.11 is %mac%.

我不知道如何从 arp 命令中解析出 Mac 地址,因为这就是我需要做的。

【问题讨论】:

    标签: batch-file arp


    【解决方案1】:
    set "ip=192.168.1.11"
    for /f "tokens=2" %%a in ('arp -a ^| findstr /b /l /c:"  %ip% "') do set "mac=%%a"
    echo %ip% = %mac%
    

    【讨论】:

      猜你喜欢
      • 2013-05-09
      • 2014-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-23
      相关资源
      最近更新 更多