中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-03 00:41
48,038 topics / 350,123 posts / today 1 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » Please provide the batch processing content that needs to be improved so that I can help you translate and improve it.
Printable Version  2,103 / 16
Floor1 lovehack2006 Posted 2006-12-23 14:52
初级用户 Posts 64 Credits 135
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 ]
Floor2 lovehack2006 Posted 2006-12-23 17:39
初级用户 Posts 64 Credits 135
Floor3 lovehack2006 Posted 2006-12-24 04:11
初级用户 Posts 64 Credits 135
No way, no one replies?
Floor4 lxmxn Posted 2006-12-24 09:59
版主 Posts 4,938 Credits 11,386


It should work. If you want to test it, just remove the echo in front of the last two lines. If it doesn't work, discuss in the reply.
Floor5 lovehack2006 Posted 2006-12-25 14:30
初级用户 Posts 64 Credits 135
Thanks to the elder brother upstairs,, but only can bind local IP and MAC.

The gateway is not okay.

'getmac /nh /s %local_ip%'

When I run it directly in CMD, it gets like this...

C:\WINDOWS\system32>getmac /nh /s 10.0.0.14

00-14-78-37-51-BD \Device\Tcpip_{C9058030-7FD6-4855-8753-443BBFD6A661},
\Device\NwlnkIpx

Can't get the MAC address of the gateway, don't know why?

When displaying it is like this!

arp -s 10.0.1.1 \Device\NwlnkIpx is wrong here..

The others are all correct, can be fixed correctly!!!1

[ Last edited by lovehack2006 on 2006-12-25 at 01:40 AM ]
Floor6 lovehack2006 Posted 2006-12-25 14:40
初级用户 Posts 64 Credits 135
My gateway IP is 10.0.1.1. My current test machine is 10.0.0.14.
Floor7 lovehack2006 Posted 2006-12-25 14:43
初级用户 Posts 64 Credits 135
Directly in CMD, C:\WINDOWS\system32>getmac

Physical Address Transport Name
=================== ==========================================================
00-14-78-37-51-BD \Device\Tcpip_{C9058030-7FD6-4855-8753-443BBFD6A661},
\Device\NwlnkIpx

The one obtained is the above.
Floor8 everest79 Posted 2006-12-26 01:08
金牌会员 Posts 1,127 Credits 2,564


I also have one for dynamic ARP binding in internet cafes

The owner needs to know that binding two ARPs locally is not what is called double binding
Bidirectional binding means the gateway binds to the local and the local binds to the gateway
Furthermore, a secure local binding should be loaded into the boot script. Dynamic binding is not a good approach
Floor9 lovehack2006 Posted 2006-12-27 07:32
初级用户 Posts 64 Credits 135
Thanks to the elder brother upstairs, what I did is the script executed at startup, heh heh!

Thank you for the batch processing, and I am testing it...
Floor10 lxmxn Posted 2006-12-27 07:40
版主 Posts 4,938 Credits 11,386
Originally posted by lovehack2006 at 2006-12-25 01:30:
Thank you, elder brother upstairs, but it can only bind the local IP and MAC.

It's not possible for the gateway.

'getmac /nh /s %local_ip%'

When I run it directly in CMD, I get this. 㠮..


  No way?

  I got the correct one. Look at my operation:

  Prove that the correct MAC is obtained.
Floor11 lovehack2006 Posted 2006-12-28 00:13
初级用户 Posts 64 Credits 135
I don't know why either!!

When displaying it's like this!

arp -s 10.0.1.1 \Device\NwlnkIpx is where it's wrong...

The others are all correct and can be done correctly!!!1

Brothers, help out!
Floor12 lxmxn Posted 2006-12-28 01:32
版主 Posts 4,938 Credits 11,386

  Try this again, see if it works?
Floor13 everest79 Posted 2006-12-28 05:39
金牌会员 Posts 1,127 Credits 2,564
Originally posted by lxmxn at 2006-12-26 06:40 PM:


  Can't be?

  I got the correct one. Look at my operation:
Floor14 tao0610 Posted 2006-12-28 06:53
高级用户 Posts 218 Credits 579
Binding the MAC address of the local network card is not really meaningful.
The one that really needs to be bound is the gateway MAC, and this needs to be handwritten instead of dynamically obtained.
Add in the boot script
Floor15 lovehack2006 Posted 2007-01-01 03:20
初级用户 Posts 64 Credits 135
Originally posted by lxmxn at 2006-12-27 12:32 PM:

  Try this again, see if it works?
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023