标题: [网络工具] 批处理IP绑定MAC(本机和网关)效率版 [打印本页]
作者: youxi01 时间: 2008-1-6 11:16 标题: 批处理IP绑定MAC(本机和网关)效率版
-
- ::==================IP绑定MAC(本机和网关)==============
- ::code by youxi01@bbs.bathome.net 2008-1-6
- ::优点:不产生临时文件、速度较快;
- ::缺点:可能不支持多网卡
- @echo off & setlocal enabledelayedexpansion
- title IP绑定MAC(本机和网关)@bbs.bathome.net
- Rem '/*===========设置要提取的字符串===========*/
- set "IP_addr=IP Address"
- set "MAC_addr=Physical Address"
- set "GW_addr=Default Gateway"
- for /f "delims=. tokens=1,*" %%i in ('ipconfig /all') do (
- Rem '/*=========下面这行是去掉字符串两端的空格=======*/
- for /f "tokens=*" %%a in ("%%i") do set "var=%%~nxa"
- for %%a in (IP_addr MAC_addr GW_addr) do (
- if "!%%a!"=="!var!" (
- set %%a=%%j
- )
- )
- )
- arp -s %IP_addr:*:=% %MAC_addr:*:=%
- for /f "skip=3 tokens=2" %%i in ('arp -a %GW_addr:*:=%') do set GW_MAC=%%i
- arp -s %GW_addr:*:=% %GW_MAC%
-
- pause>nul
-
复制代码
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |