Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 从ARP命令批处理解析IP地址_Batch File_Ip Address_Mac Address_Arp - Fatal编程技术网

Batch file 从ARP命令批处理解析IP地址

Batch file 从ARP命令批处理解析IP地址,batch-file,ip-address,mac-address,arp,Batch File,Ip Address,Mac Address,Arp,好的,我需要将ARP-a命令中mac地址的IP地址设置为一个变量 下面是我从arp-a命令中得到的信息: C:>arp-a Interface: 192.168.1.17 --- 0xb Internet Address Physical Address Type 192.168.1.1 74-41-01-42-aa-df dynamic 192.168.1.5 d8-d8-cb-23-28-ab dynam

好的,我需要将ARP-a命令中mac地址的IP地址设置为一个变量

下面是我从arp-a命令中得到的信息:

C:>arp-a

Interface: 192.168.1.17 --- 0xb
  Internet Address      Physical Address      Type
  192.168.1.1           74-41-01-42-aa-df     dynamic
  192.168.1.5           d8-d8-cb-23-28-ab     dynamic
  192.168.1.13          18-e6-f4-86-75-9e     dynamic
  192.168.1.14          20-9c-8f-3f-03-9b     dynamic
  192.168.1.255         ff-ff-ff-ff-ff-ff     static
  224.0.0.22            06-00-5e-00-00-16     static
  224.0.0.252           01-05-5e-00-00-fc     static
  239.255.255.250       01-00-4e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

我需要一个批处理文件来查找mac地址为18-e6-f4-86-75-9e的行,然后将左侧列出的IP地址作为变量进行设置。

您可以使用
find
命令来隔离mac地址为所需的行,然后使用
for
命令提取IP地址:

@echo off
for /f "tokens=1 delims= " %%i in ('arp -a ^| find /i "18-e6-f4-86-75-9e"') do set ip=%%i
echo %ip%