Board logo

标题: [求助]这个ip绑定怎么实现不了... [打印本页]

作者: ulboy     时间: 2007-6-27 20:23    标题: [求助]这个ip绑定怎么实现不了...

arp -d
FOR /f "tokens=14 delims=: " %%i in ('ipconfig /all ^|find /i "IP Address"') do Set ip=%%i
FOR /f "tokens=11 delims=: " %%i in ('ipconfig /all ^|find /i "Physical Address"') do Set mac=%%i
echo arp -s %IP% %MAC%>c:\ipmac.bat
FOR /f "tokens=12 delims=: " %%i in ('ipconfig /all ^|find /i "Default Gateway"') do Set GateIP=%%i
FOR /f "skip=3 tokens=2" %%b in ('arp -a %GateIP%') do Set GateMAC=%%b
echo arp -s %Gateip% %GateMAC%>>c:\ipmac.bat

[ Last edited by ulboy on 2007-6-27 at 11:56 PM ]
作者: dikex     时间: 2007-6-27 22:02
是否代码不完整?

具有绑定功能的arp -s那里前面有echo,后面有重定向,又怎能绑定呢?

FOR /f "tokens=14 delims=: " %%i in ('ipconfig /all ^|find /i "IP Address"') do Set ip=%%i
FOR /f "tokens=11 delims=: " %%i in ('ipconfig /all ^|find /i "Physical Address"') do Set mac=%%i
arp -s %IP% %MAC%
FOR /f "tokens=12 delims=: " %%i in ('ipconfig /all ^|find /i "Default Gateway"') do Set GateIP=%%i
FOR /f "skip=3 tokens=2" %%b in ('arp -a %GateIP%') do Set GateMAC=%%b
arp -s %Gateip% %GateMAC
作者: ulboy     时间: 2007-6-27 23:59
我是想把本地与网关的绑定写入到一个文件里头.

为什么网关的mac 读不出来...语句有问题吗.
作者: dikex     时间: 2007-6-28 00:39
先ping一下网关的IP再用arp -a试试
作者: ulboy     时间: 2007-6-28 01:35
ping 没有问题.能得出mac 在批处理起不了作用..
这个批处理你那边也可以试一下...真搞不懂..
作者: HAT     时间: 2007-6-28 16:45
可能是arp -d命令的问题
试试我这个
@echo off
FOR /f "tokens=14 delims=: " %%i in ('ipconfig /all ^|find /i "IP Address"') do Set ip=%%i
FOR /f "tokens=11 delims=: " %%i in ('ipconfig /all ^|find /i "Physical Address"') do Set mac=%%i
echo arp -s %IP% %MAC%>c:\ipmac.bat
FOR /f "tokens=12 delims=: " %%i in ('ipconfig /all ^|find /i "Default Gateway"') do Set GateIP=%%i
FOR /f "skip=3 tokens=2" %%b in ('arp -a %GateIP%') do (
  Set GateMAC=%%b
  goto gate
)

:gate
echo arp -s %Gateip% %GateMAC%>>c:\ipmac.bat

作者: ulboy     时间: 2007-6-28 17:30
6楼兄弟 太感谢你咯.


      能指出错误吗.....
                              图个明白..
作者: ulboy     时间: 2007-6-28 17:37
我知道错在哪里咯....

语句是没有错.只是开头加错了..唉.