ARP dual-binding script. No temporary files (LZ-Myst version) are listed below and saved as BAT format.
Copy codeThe Code is 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 % J
For/f "tokens = 15" % I in ('ipconfig/all ^ | find "IP Address" ') do set ip = % I
For/f "tokens = 12" % I in ('ipconfig/all ^ | find "Physical Address" ') do set mac = % I
Arp-s % ip % mac %
Note: The above code may cause some problems in actual application, because if there is an ARP virus machine in the LAN, it will continuously send spoofing packets, therefore, a problem occurs when the gateway is automatically obtained. For this reason, another code is modified to write the MAC address of the real gateway. You do not need to write the IP address of the real gateway. The Code is as follows.
Change the red letter in the following code box to your real MAC address !!!
The MAC address format is: 00-14-78-32-14-f2, which is the format displayed by ARP-.Copy codeThe Code is as follows: for/f "tokens = 13" % I in ('ipconfig/all ^ | find "Default Gateway" ') do set GatewayIP = % I
Arp-s % GatewayIP % real gateway MAC
For/f "tokens = 15" % I in ('ipconfig/all ^ | find "IP Address" ') do set ip = % I
For/f "tokens = 12" % I in ('ipconfig/all ^ | find "Physical Address" ') do set mac = % I
Arp-s % ip % mac %