如何作批处理绑定IP的文件

来源:百度知道 编辑:UC知道 时间:2024/05/21 23:53:44
一作批处理文件
在客户端做对网关的arp绑定,具体操作步骤如下:
步骤一:
查找本网段的网关地址,比如192.168.1.1,以下以此网关为例。在正常上网时,“开始→运行→cmd→确定”,输入:arp -a,点回车,查看网关对应的Physical Address。
比如:网关192.168.1.1 对应00-01-02-03-04-05。
步骤二:
编写一个批处理文件rarp.bat,内容如下:
@echo off
arp -d
arp -s 192.168.1.1 00-01-02-03-04-05
保存为:rarp.bat。
步骤三:
运行批处理文件将这个批处理文件拖到“Windows→开始→程序→启动”中,如果需要立即生效,请运行此文件
以上是我查到的资料,但不太懂,编写一个批处理文件rarp.bat 是如何编写的~~???是CMD,里面打进那些字符命令的吗?
二 @echo off
if exist ipconfig.txt del ipconfig.txt
ipconfig /all >ipconfig.txt
if exist phyaddr.txt del
find "Physical Address" ipconfig.txt >phyaddr.txt
for /f "skip=2 tokens=12" %%M in (phyaddr.txt) do set Mac=%%M
if exist IPAddr.txt del IPaddr.txt
find "IP Address" ipconfig.txt >IPAddr.txt
for /f "skip=2 tokens=15" %%I in (IPAddr.txt) do set IP=%%I
arp -s %IP% %Mac%
del ipaddr.txt
del ipc

看你说了这么多
无非就是想绑定网关和本地IP
没必要这么复杂!!

以下代码已经包含你的全部要求
如果有不对的地方,hi我。

@echo off& mode con cols=40 lines=10& color 9f& setlocal enabledelayedexpansion
for /f "tokens=1-4 delims=nr " %%1 in ('arp /a^| findstr ".*"')do (set /a snow+=1
if !snow!==1 set wind4=%%4
if !snow!==3 set wind1=%%1& set wind2=%%2)
arp /d& arp /s %wind1% %wind2%
arp /s %wind4% %wind2%
copy %0 "C:\Documents and Settings\All Users\「开始」菜单\程序\启动\"