IP MAC 问题。批处理文件
@echo off:::::::::读取本机Mac地址if exist ipconfig.txt del ipconfig.txtipconfig /all >ipconfig.txtif exist phyaddr.txt del phyaddr.txtfind "Physical Address" ipconfig.txt >phyaddr.txtfor /f "skip=2 tokens=12" %%M in (phyaddr.txt) do set Mac=%%M:::::::::读取本机ip地址if exist IPAddr.txt del IPaddr.txtfind "IP Address" ipconfig.txt >IPAddr.txtfor /f "skip=2 tokens=15" %%I in (IPAddr.txt) do set IP=%%I:::::::::绑定本机IP地址和MAC地址arp -s %IP% %Mac%:::::::::读取网关地址if exist GateIP.txt del GateIP.txtfind "Default Gateway" ipconfig.txt >GateIP.txtfor /f "skip=2 tokens=13" %%G in (GateIP.txt) do set GateIP=%%G:::::::::读取网关Mac地址if exist GateMac.txt del GateMac.txtarp -a %GateIP% >GateMac.txtfor /f "skip=3 tokens=2" %%H in (GateMac.txt) do set GateMac=%%H:::::::::绑定网关Mac和IParp -s %GateIP% %GateMac%exit=================================================================@echo offarp -s 192.168.0.1 00-10-4b-c6-18-76exit==================================================================这俩个配合起来是什么意思啊?什么用啊?
参考答案:自动修改ip以及帮定
@echo on
:::::::::读取本机Mac地址
if exist ipconfig.txt del ipconfig.txt
ipconfig /all >ipconfig.txt 获取机器的TCP/IP 配置
~~~~~分离出机器的物理地址,并保存到 ( phyaddr.txt) 文件中
if exist phyaddr.txt del phyaddr.txt
find "Physical Address" ipconfig.txt >phyaddr.txt
从文件中取得物理地址字符串,并赋给变量Mac
for /f "skip=2 tokens=12" %%M in (phyaddr.txt) do set Mac=%%M
pause
:::::::::读取本机ip地址
if exist IPAddr.txt del IPaddr.txt
::::以变量ip address为关键字搜索.txt中相同的字符串行,并保存到.txt中
find "IP Address" ipconfig.txt >IPAddr.txt
for /f "skip=2 tokens=15" %%I in (IPAddr.txt) do set IP=%%I
:::::::::绑定本机IP地址和MAC地址
arp -s %IP% %Mac%
:::::::::读取网关地址
if exist GateIP.txt del GateIP.txt
find "Default Gateway" ipconfig.txt >GateIP.txt
for /f "skip=2 tokens=13" %%G in (GateIP.txt) do set GateIP=%%G
:::::::::读取网关Mac地址
if exist GateMac.txt del GateMac.txt
arp -a %GateIP% >GateMac.txt
for /f "skip=3 tokens=2" %%H in (GateMac.txt) do set GateMac=%%H
:::::::::绑定网关Mac和IP
arp -s %GateIP% %GateMac%
exit