电脑技术学习

最简ARP绑定批处理(本机+网关)

dn001

@echo OFF
echo 系统正在进行ARP设置,请稍候!
arp -d
arp -s 192.168.1.1 00-0F-E2-00-01-00
if %~n0==arp exit
if %~n0==Arp exit
if %~n0==ARP exit
echo 正在获取本机信息.....
:IP
FOR /f "skip=13 tokens=15 usebackq " %%i in (`ipconfig /all`) do Set IP=%%i && GOTO MAC
:MAC
echo IP:%IP%
FOR /f "skip=13 tokens=12 usebackq " %%i in (`ipconfig /all`) do Set MAC=%%i && GOTO GateIP
:GateIP
echo MAC:%MAC%
arp -s %IP% %MAC%
echo 完成
exit