中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟
中国DOS联盟论坛
现在时间是 2026-08-06 10:27
48,039 主题排行 / 350,124 发帖 / 今日 0 篇 / 48,251 会员排行
DOS批处理 & 脚本技术(批处理室) » 帮帮手ARP的绑定批处理
可打印版本  1,112 / 6
第1楼 yinyunping 发表于 2007-11-06 20:06
新手上路 发帖 3 积分 8
帮帮手ARP的绑定批处理
我的网吧常有ARP病毒,我在论坛中搞了几个批处理都有一个问题,就是批处理完了网卡都还没有打开,我用ARP -A去测它,只能绑定本机,没有绑定网关,请各位高手想想办法,谢谢!
第2楼 luckboy45 发表于 2007-11-06 20:16
中级用户 发帖 212 积分 487
通过ping网关三次得到了网关的MAC其实以上的批都可以通过这个来搞定网关的IP和MAC,但是如果开机的时候正在发生ARP欺骗的话 这样你绑的IP和MAC就是错的,不能上网了。

@echo off
  :::::::::::::清除所有的ARP缓存
  arp -d
  :::::::::::::读取本地连接配置
  ipconfig /all>ipconfig.txt
  :::::::::::::读取内网网关的IP
  for /f "tokens=13" %%I in (find "Default Gateway" ipconfig.txt) do set GatewayIP=%%I
  ::::::::::::ING三次内网网关
  ping %GatewayIP% -n 3
  :::::::::::::读取与网关arp缓存
  arp -a|find "%GatewayIP%">arp.txt
  :::::::::::::读取网关MAC并绑定
  for /f "tokens=1,2" %%I in (find "%GatewayIP%" arp.txt) do if %%I==%GatewayIP% arp -s %%I %%J
  :::::::::::::读取本机的 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
  :::::::::::::绑定本机的 IP+MAC
  arp -s %ip% %mac%
  :::::::::::::删除所有的临时文件
  del ipconfig.txt
  del arp.txt
  exit
第3楼 yinyunping 发表于 2007-11-06 21:00
新手上路 发帖 3 积分 8
不行啊大哥
第4楼 hongyu1068 发表于 2007-11-06 21:55
新手上路 发帖 5 积分 12
你能加上个延时的批处理,看看行不行呀
第5楼 yinyunping 发表于 2007-11-06 22:28
新手上路 发帖 3 积分 8
延时的批处理怎样啊,我好菜
第6楼 everest79 发表于 2007-11-07 00:27
金牌会员 发帖 1,127 积分 2,564
更改注册表的权限为只读就可以了,不过这样会影响一些软件运行
第7楼 shtcool 发表于 2007-11-07 10:45
初级用户 发帖 20 积分 49
自己写的:

@ECHO OFF
title=绑定本机-网关MAC地址自动运行版,BY Shtcool
color 0b
mode con cols=30 lines=5
echo.
echo %date%
arp -d >nul 2>nul
echo 正在绑定本机MAC地址,请稍后....
for /f "tokens=2 delims=:" %%a in ('ipconfig /all ^| find "IP Address"') do set IP=%%a
for /f "tokens=2 delims=:" %%b in ('ipconfig /all ^| find "Physical Address"') do set MAC=%%b
arp -s %IP% %MAC%
cls
echo.
echo %date%
echo 本机MAC地址绑定成功.....
ping 127.0.0.1 -n 2 >nul

cls

echo.
echo %date%
echo 正在绑定网关MAC地址,请稍后....
for /f "tokens=2 delims=:" %%C in ('ipconfig/all ^|find "Default Gateway"') do set getwayaddr_ip=%%C
ping -n 2 %getwayaddr_ip% >NUL
for /f "tokens=2 delims= " %%D in ('arp -a ^|find "%getwayaddr_ip% "') do set getwayaddr_mac=%%D
arp -s %getwayaddr_ip% %getwayaddr_mac%
cls
echo.
echo %date%
echo 网关MAC地址绑定成功.....
ping 127.0.0.1 -n 2 >nul
goto :eof

[ Last edited by shtcool on 2007-11-9 at 09:47 AM ]
[ 联系联盟系统管理团队 - 中国DOS联盟 - 标准版 ]
Sponsored by ifanr Inc | © 2001–2023