@echo off
rem 经测试,能在客户端绑定自己的IP与MAC,网关的IP与MAC.注意:多网卡环境下要保证只开一个网卡,否则不能正确绑定.
rem 清除所有的ARP缓存
arp -d
rem 读取本地连接配置
ipconfig /all>ipconfig.txt
rem 读取内网网关的IP
for /f "tokens=13" %%I in ('find "Default Gateway" ipconfig.txt') do set GatewayIP=%%I
rem PING一次内网网关
ping %GatewayIP% -n 1
rem 读取与网关arp缓存
arp -a|find "%GatewayIP%">arp.txt
rem 读取网关MAC并绑定
for /f "tokens=1,2" %%I in ('find "%GatewayIP%" arp.txt') do if %%I==%GatewayIP% arp -s %%I %%J
rem 读取本机的 IP+MAC
for /f "tokens=15" %%i in ('find "IP Address" ipconfig.txt') do set ip=%%i
for /f "tokens=12" %%i in ('find "Physical Address" ipconfig.txt') do set mac=%%i
rem 绑定本机的 IP+MAC
arp -s %ip% %mac%
rem 删除所有的临时文件
del ipconfig.txt
del arp.txt
exit 这么老的帖子也翻出来了呀
页:
1
[2]