Dear brothers, I'm a new comer and have some questions to ask you!!! (Double binding batch processing)
The following batch processing is for binding the IP and MAC of the Internet cafe client machine, and it can also bind the MAC and IP of the gateway.
But now there is a problem that this batch processing can only realize the binding of the IP and MAC of the client machine.
If I run arp -d on the client machine to delete the ARP table, or if the ARP table on this machine is empty, this batch can no longer bind the MAC and IP of the gateway of the client machine. ... arp -a %GateIP% >GateMac.txt The content written into gatemac.txt is just -----No ARP Entries Found
Brothers, can you improve this batch processing?
This batch is not written by me, and I can't write this thing. I don't even know how to use for.
I hope you can help me. ...
I have thought of a method by myself: add a ping to the gateway IP in front of this batch, so that the MAC of the gateway can be found in the ARP table. ... or add an arp -s gateway IP gateway MAC at the back, but I wonder if there are other better methods to realize it?
@echo off
::Read the local Mac address
if exist ipconfig.txt del ipconfig.txt
ipconfig /all >ipconfig.txt
if exist phyaddr.txt del phyaddr.txt
find "Physical Address" ipconfig.txt >phyaddr.txt
for /f "skip=2 tokens=12" %%M in (phyaddr.txt) do set Mac=%%M
::Read the local ip address
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
::Bind the local IP address and MAC address
arp -s %IP% %Mac%
::Read the gateway address
if exist GateIP.txt del GateIP.txt
find "Default Gateway" ipconfig.txt >GateIP.txt
for /f "skip=2 tokens=13" %%G in (GateIP.txt) do set GateIP=%%G
::Read the gateway Mac address
if exist GateMac.txt del GateMac.txt
arp -a %GateIP% >GateMac.txt
for /f "skip=3 tokens=2" %%H in (GateMac.txt) do set GateMac=%%H
::Bind the gateway Mac and IP
arp -s %GateIP% %GateMac%
exit
[ Last edited by lovehack2006 on 2006-12-25 at 01:41 AM ]
The following batch processing is for binding the IP and MAC of the Internet cafe client machine, and it can also bind the MAC and IP of the gateway.
But now there is a problem that this batch processing can only realize the binding of the IP and MAC of the client machine.
If I run arp -d on the client machine to delete the ARP table, or if the ARP table on this machine is empty, this batch can no longer bind the MAC and IP of the gateway of the client machine. ... arp -a %GateIP% >GateMac.txt The content written into gatemac.txt is just -----No ARP Entries Found
Brothers, can you improve this batch processing?
This batch is not written by me, and I can't write this thing. I don't even know how to use for.
I hope you can help me. ...
I have thought of a method by myself: add a ping to the gateway IP in front of this batch, so that the MAC of the gateway can be found in the ARP table. ... or add an arp -s gateway IP gateway MAC at the back, but I wonder if there are other better methods to realize it?
@echo off
::Read the local Mac address
if exist ipconfig.txt del ipconfig.txt
ipconfig /all >ipconfig.txt
if exist phyaddr.txt del phyaddr.txt
find "Physical Address" ipconfig.txt >phyaddr.txt
for /f "skip=2 tokens=12" %%M in (phyaddr.txt) do set Mac=%%M
::Read the local ip address
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
::Bind the local IP address and MAC address
arp -s %IP% %Mac%
::Read the gateway address
if exist GateIP.txt del GateIP.txt
find "Default Gateway" ipconfig.txt >GateIP.txt
for /f "skip=2 tokens=13" %%G in (GateIP.txt) do set GateIP=%%G
::Read the gateway Mac address
if exist GateMac.txt del GateMac.txt
arp -a %GateIP% >GateMac.txt
for /f "skip=3 tokens=2" %%H in (GateMac.txt) do set GateMac=%%H
::Bind the gateway Mac and IP
arp -s %GateIP% %GateMac%
exit
[ Last edited by lovehack2006 on 2006-12-25 at 01:41 AM ]
