ARP double bind script, no temporary file (lz-myst version) horizontal below, save in BAT format can be used.
Copy Code code as follows:
for/f "Tokens=13"%%i in (' Ipconfig/all ^|find "Default Gateway") do set gatewayip=%%i
for/f "tokens=1,2"%%i in (' Arp-a ^|find '%gatewayip% "') do if%%i==%gatewayip% arp-s%%i
for/f "Tokens=15"%%i in (' Ipconfig/all ^|find IP addresses ') do set ip=%%i
for/f "Tokens=12"%%i in (' Ipconfig/all ^|find ' Physical address ') do set mac=%%i
Arp-s%ip%%mac%
Note that the above code in the actual application will have some problems, because if the local area network if there is an ARP virus in the machine, he will continue to send cheat packets, so the automatic access to the gateway will be problematic, to modify another piece of code, handwritten real Gateway MAC address. You do not need to write the IP address of the real gateway. The code is as follows.
Change the red word in the following code box to your real MAC address!!!
The MAC address format is: 00-14-78-32-14-F2 is the ARP-A display format.
Copy Code code as follows:
for/f "tokens=13"%%i in (' Ipconfig/all ^|find ' Default Gateway ') do set Ga Tewayip=%%i
Arp-s%gatewayip% Real Gateway mac
for/f "Tokens=15"%%i in (' Ipconfig/all ^|find IP address ') do set ip=%%i
F or/f "Tokens=12"%%i in (' Ipconfig/all ^|find ' Physical address ') do set mac=%%i
arp-s%ip%%mac%