标题:
[网络连接]
请教如何用批处理在路由器中提取端口信息?
[打印本页]
作者:
ccccpp
时间:
2011-8-31 17:12
标题:
请教如何用批处理在路由器中提取端口信息?
单位要统计多处地方的路由一体机端口IP信信息,手工要TELNET到路由器上,通过sh mac 查出全部在用IP及对应的MAC地址,再通过sh arp 查出路由器上48个口的在用MAC地地址,再手工列表,一一对应出IP、端口号、MAC址,手工操作非常慢,效率低,请问各位达人如何用批处理提取路由器中提取端口信息?
作者:
caruko
时间:
2011-8-31 17:58
截取数据包,再NetCat来提交。
作者:
ccccpp
时间:
2011-9-1 10:32
请问如何写?
以下为SH的记录
apen#sh arp
Protocol Address Age(min) Hardware Type Interface
Internet 192.29.68.225 20 001e.4a49.5b02 arpa FastEthernet 0/0
Internet 192.29.68.226 -- 001a.a93a.20f6 arpa FastEthernet 0/0
Internet 192.29.68.5 20 001d.a25a.7181 arpa FastEthernet 0/1
Internet 192.29.68.6 -- 001a.a93a.20f7 arpa FastEthernet 0/1
Internet 192.27.219.1 1 0021.973f.45ee arpa FastEthernet 6/0.470
Internet 192.27.219.30 -- 001a.a93a.20f9 arpa FastEthernet 6/0.470
Internet 192.27.220.5 14 0040.481c.fbe0 arpa FastEthernet 6/0.440
Internet 192.27.220.3 0 0013.c44a.7615 arpa FastEthernet 6/0.440
Internet 192.27.220.30 -- 001a.a93a.20f9 arpa FastEthernet 6/0.440
Internet 192.27.223.20 3 000d.6034.78f3 arpa FastEthernet 6/0.410
Internet 192.27.223.8 7 0011.250c.85ed arpa FastEthernet 6/0.410
Internet 192.27.223.10 3 0015.58e5.b8db arpa FastEthernet 6/0.410
Internet 192.27.223.7 3 0015.58e9.8936 arpa FastEthernet 6/0.410
Internet 192.27.223.13 2 001c.25c1.1453 arpa FastEthernet 6/0.410
Internet 192.27.223.16 0 0040.63f5.ab0c arpa FastEthernet 6/0.410
Internet 192.27.223.17 1 5078.aa20.0a11 arpa FastEthernet 6/0.410
Internet 192.27.223.18 0 0040.63f5.ab11 arpa FastEthernet 6/0.410
Internet 192.27.223.19 0 5078.aa20.0a10 arpa FastEthernet 6/0.410
Internet 192.27.223.12 8 0011.250c.a21a arpa FastEthernet 6/0.410
Internet 192.27.223.6 4 0015.58de.d7b7 arpa FastEthernet 6/0.410
Internet 192.27.223.15 1 0010.c6a5.64bf arpa FastEthernet 6/0.410
Internet 192.27.223.14 56 0800.3786.59ad arpa FastEthernet 6/0.410
Internet 192.27.223.11 3 0009.f602.d0d6 arpa FastEthernet 6/0.410
Internet 192.27.223.30 -- 001a.a93a.20f9 arpa FastEthernet 6/0.410
Internet 192.27.208.12 3 0001.6c9f.5444 arpa FastEthernet 6/0.400
Internet 192.27.208.15 2 0015.58e2.a311 arpa FastEthernet 6/0.400
Internet 192.27.208.10 4 0001.6c9f.43ff arpa FastEthernet 6/0.400
Internet 192.27.208.13 7 0015.58ec.8029 arpa FastEthernet 6/0.400
Internet 192.27.208.14 1 0015.58ec.80db arpa FastEthernet 6/0.400
Internet 192.27.208.11 7 001c.25c1.8b5e arpa FastEthernet 6/0.400
Internet 192.27.208.6 4 0015.58e5.c090 arpa FastEthernet 6/0.400
Internet 192.27.208.16 1 0015.58e2.c3e3 arpa FastEthernet 6/0.400
Internet 192.27.208.29 6 0015.5844.692d arpa FastEthernet 6/0.400
Internet 192.27.208.24 0 0001.29a3.de47 arpa FastEthernet 6/0.400
Internet 192.27.208.20 8 001c.25ac.4e0a arpa FastEthernet 6/0.400
Internet 192.27.208.22 9 001c.25ac.5288 arpa FastEthernet 6/0.400
Internet 192.27.208.28 10 00e0.270b.395d arpa FastEthernet 6/0.400
Internet 192.27.208.27 2 00e0.270b.35d4 arpa FastEthernet 6/0.400
Internet 192.27.208.26 4 00e0.270b.3540 arpa FastEthernet 6/0.400
Internet 192.27.208.25 9 0001.29a3.d4ee arpa FastEthernet 6/0.400
Internet 192.27.208.21 7 001c.25de.758b arpa FastEthernet 6/0.400
Internet 192.27.208.23 5 0001.29a3.d4ea arpa FastEthernet 6/0.400
Internet 192.27.208.30 -- 001a.a93a.20f9 arpa FastEthernet 6/0.400
Internet 192.27.211.11 32 001a.a915.b5c0 arpa FastEthernet 6/0.399
Internet 192.27.211.10 32 001a.a915.b54e arpa FastEthernet 6/0.399
Internet 192.27.211.14 -- 001a.a93a.20f9 arpa FastEthernet 6/0.399
Total number of ARP entries: 46
apen#sh mac
Vlan MAC Address Type Interface
---------- -------------------- -------- -------------------
400 0001.6c9f.43ff DYNAMIC FastEthernet 0/24
400 0015.5844.692d DYNAMIC FastEthernet 5/1
400 001c.25ac.4e0a DYNAMIC FastEthernet 5/3
400 001c.25ac.5288 DYNAMIC FastEthernet 5/7
410 0009.f602.d0d6 DYNAMIC FastEthernet 5/18
410 000d.6034.78f3 DYNAMIC FastEthernet 5/12
410 0010.c6a5.64bf DYNAMIC FastEthernet 5/10
410 0011.250c.85ed DYNAMIC FastEthernet 5/11
410 0011.250c.a21a DYNAMIC FastEthernet 5/8
410 0015.58de.d7b7 DYNAMIC FastEthernet 5/18
410 0015.58e5.b8db DYNAMIC FastEthernet 5/15
410 0015.58e9.8936 DYNAMIC FastEthernet 5/16
410 001c.25c1.1453 DYNAMIC FastEthernet 5/17
410 0040.63f5.ab0c DYNAMIC FastEthernet 5/13
410 0040.63f5.ab11 DYNAMIC FastEthernet 5/14
410 0800.3786.59ad DYNAMIC FastEthernet 5/18
410 5078.aa20.0a10 DYNAMIC FastEthernet 5/14
410 5078.aa20.0a11 DYNAMIC FastEthernet 5/13
440 0013.c44a.7615 DYNAMIC FastEthernet 5/23
440 0040.481c.fbe0 DYNAMIC FastEthernet 5/22
470 001a.a93a.20f9 DYNAMIC FastEthernet 5/24
470 0021.973f.45ee DYNAMIC FastEthernet 5/20
Vlan MAC Address Type Interface
---------- -------------------- -------- -------------------
399 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
400 0001.29a3.d4ea DYNAMIC FastEthernet 6/17
400 0001.29a3.d4ee DYNAMIC FastEthernet 6/14
400 0001.29a3.de47 DYNAMIC FastEthernet 6/23
400 0001.6c9f.43ff DYNAMIC FastEthernet 6/2
400 0001.6c9f.5444 DYNAMIC FastEthernet 6/11
400 0015.58e2.a311 DYNAMIC FastEthernet 6/4
400 0015.58e2.c3e3 DYNAMIC FastEthernet 6/8
400 0015.58e5.c090 DYNAMIC FastEthernet 6/10
400 0015.58ec.8029 DYNAMIC FastEthernet 6/12
400 0015.58ec.80db DYNAMIC FastEthernet 6/13
400 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
400 001c.25c1.8b5e DYNAMIC FastEthernet 6/9
400 001c.25de.758b DYNAMIC FastEthernet 6/22
400 00e0.270b.3540 DYNAMIC FastEthernet 6/21
400 00e0.270b.35d4 DYNAMIC FastEthernet 6/18
400 00e0.270b.395d DYNAMIC FastEthernet 6/19
410 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
440 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
440 0040.481c.fbe0 DYNAMIC FastEthernet 6/24
470 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
470 0021.973f.45ee DYNAMIC FastEthernet 6/24
apen#
作者:
telnet
时间:
2011-9-1 13:10
好高 期待
作者:
ccccpp
时间:
2011-9-5 10:39
请问二楼中的数据如何才能通过批处理,删剩下:
Internet 192.29.68.225 20 001e.4a49.5b02 arpa FastEthernet 0/0
Internet 192.29.68.226 -- 001a.a93a.20f6 arpa FastEthernet 0/0
Internet 192.29.68.5 20 001d.a25a.7181 arpa FastEthernet 0/1
Internet 192.29.68.6 -- 001a.a93a.20f7 arpa FastEthernet 0/1
Internet 192.27.219.1 1 0021.973f.45ee arpa FastEthernet 6/0.470
Internet 192.27.219.30 -- 001a.a93a.20f9 arpa FastEthernet 6/0.470
Internet 192.27.220.5 14 0040.481c.fbe0 arpa FastEthernet 6/0.440
Internet 192.27.220.3 0 0013.c44a.7615 arpa FastEthernet 6/0.440
Internet 192.27.220.30 -- 001a.a93a.20f9 arpa FastEthernet 6/0.440
Internet 192.27.223.20 3 000d.6034.78f3 arpa FastEthernet 6/0.410
Internet 192.27.223.8 7 0011.250c.85ed arpa FastEthernet 6/0.410
Internet 192.27.223.10 3 0015.58e5.b8db arpa FastEthernet 6/0.410
Internet 192.27.223.7 3 0015.58e9.8936 arpa FastEthernet 6/0.410
Internet 192.27.223.13 2 001c.25c1.1453 arpa FastEthernet 6/0.410
Internet 192.27.223.16 0 0040.63f5.ab0c arpa FastEthernet 6/0.410
Internet 192.27.223.17 1 5078.aa20.0a11 arpa FastEthernet 6/0.410
Internet 192.27.223.18 0 0040.63f5.ab11 arpa FastEthernet 6/0.410
Internet 192.27.223.19 0 5078.aa20.0a10 arpa FastEthernet 6/0.410
Internet 192.27.223.12 8 0011.250c.a21a arpa FastEthernet 6/0.410
Internet 192.27.223.6 4 0015.58de.d7b7 arpa FastEthernet 6/0.410
Internet 192.27.223.15 1 0010.c6a5.64bf arpa FastEthernet 6/0.410
Internet 192.27.223.14 56 0800.3786.59ad arpa FastEthernet 6/0.410
Internet 192.27.223.11 3 0009.f602.d0d6 arpa FastEthernet 6/0.410
Internet 192.27.223.30 -- 001a.a93a.20f9 arpa FastEthernet 6/0.410
Internet 192.27.208.12 3 0001.6c9f.5444 arpa FastEthernet 6/0.400
Internet 192.27.208.15 2 0015.58e2.a311 arpa FastEthernet 6/0.400
Internet 192.27.208.10 4 0001.6c9f.43ff arpa FastEthernet 6/0.400
Internet 192.27.208.13 7 0015.58ec.8029 arpa FastEthernet 6/0.400
Internet 192.27.208.14 1 0015.58ec.80db arpa FastEthernet 6/0.400
Internet 192.27.208.11 7 001c.25c1.8b5e arpa FastEthernet 6/0.400
Internet 192.27.208.6 4 0015.58e5.c090 arpa FastEthernet 6/0.400
Internet 192.27.208.16 1 0015.58e2.c3e3 arpa FastEthernet 6/0.400
Internet 192.27.208.29 6 0015.5844.692d arpa FastEthernet 6/0.400
Internet 192.27.208.24 0 0001.29a3.de47 arpa FastEthernet 6/0.400
Internet 192.27.208.20 8 001c.25ac.4e0a arpa FastEthernet 6/0.400
Internet 192.27.208.22 9 001c.25ac.5288 arpa FastEthernet 6/0.400
Internet 192.27.208.28 10 00e0.270b.395d arpa FastEthernet 6/0.400
Internet 192.27.208.27 2 00e0.270b.35d4 arpa FastEthernet 6/0.400
Internet 192.27.208.26 4 00e0.270b.3540 arpa FastEthernet 6/0.400
Internet 192.27.208.25 9 0001.29a3.d4ee arpa FastEthernet 6/0.400
Internet 192.27.208.21 7 001c.25de.758b arpa FastEthernet 6/0.400
Internet 192.27.208.23 5 0001.29a3.d4ea arpa FastEthernet 6/0.400
Internet 192.27.208.30 -- 001a.a93a.20f9 arpa FastEthernet 6/0.400
Internet 192.27.211.11 32 001a.a915.b5c0 arpa FastEthernet 6/0.399
Internet 192.27.211.10 32 001a.a915.b54e arpa FastEthernet 6/0.399
Internet 192.27.211.14 -- 001a.a93a.20f9 arpa FastEthernet 6/0.399
400 0001.6c9f.43ff DYNAMIC FastEthernet 0/24
400 0015.5844.692d DYNAMIC FastEthernet 5/1
400 001c.25ac.4e0a DYNAMIC FastEthernet 5/3
400 001c.25ac.5288 DYNAMIC FastEthernet 5/7
410 0009.f602.d0d6 DYNAMIC FastEthernet 5/18
410 000d.6034.78f3 DYNAMIC FastEthernet 5/12
410 0010.c6a5.64bf DYNAMIC FastEthernet 5/10
410 0011.250c.85ed DYNAMIC FastEthernet 5/11
410 0011.250c.a21a DYNAMIC FastEthernet 5/8
410 0015.58de.d7b7 DYNAMIC FastEthernet 5/18
410 0015.58e5.b8db DYNAMIC FastEthernet 5/15
410 0015.58e9.8936 DYNAMIC FastEthernet 5/16
410 001c.25c1.1453 DYNAMIC FastEthernet 5/17
410 0040.63f5.ab0c DYNAMIC FastEthernet 5/13
410 0040.63f5.ab11 DYNAMIC FastEthernet 5/14
410 0800.3786.59ad DYNAMIC FastEthernet 5/18
410 5078.aa20.0a10 DYNAMIC FastEthernet 5/14
410 5078.aa20.0a11 DYNAMIC FastEthernet 5/13
440 0013.c44a.7615 DYNAMIC FastEthernet 5/23
440 0040.481c.fbe0 DYNAMIC FastEthernet 5/22
470 001a.a93a.20f9 DYNAMIC FastEthernet 5/24
470 0021.973f.45ee DYNAMIC FastEthernet 5/20
399 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
400 0001.29a3.d4ea DYNAMIC FastEthernet 6/17
400 0001.29a3.d4ee DYNAMIC FastEthernet 6/14
400 0001.29a3.de47 DYNAMIC FastEthernet 6/23
400 0001.6c9f.43ff DYNAMIC FastEthernet 6/2
400 0001.6c9f.5444 DYNAMIC FastEthernet 6/11
400 0015.58e2.a311 DYNAMIC FastEthernet 6/4
400 0015.58e2.c3e3 DYNAMIC FastEthernet 6/8
400 0015.58e5.c090 DYNAMIC FastEthernet 6/10
400 0015.58ec.8029 DYNAMIC FastEthernet 6/12
400 0015.58ec.80db DYNAMIC FastEthernet 6/13
400 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
400 001c.25c1.8b5e DYNAMIC FastEthernet 6/9
400 001c.25de.758b DYNAMIC FastEthernet 6/22
400 00e0.270b.3540 DYNAMIC FastEthernet 6/21
400 00e0.270b.35d4 DYNAMIC FastEthernet 6/18
400 00e0.270b.395d DYNAMIC FastEthernet 6/19
410 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
440 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
440 0040.481c.fbe0 DYNAMIC FastEthernet 6/24
470 001a.a93a.20f9 DYNAMIC GigabitEthernet 6/25
470 0021.973f.45ee DYNAMIC FastEthernet 6/24
作者:
ccccpp
时间:
2011-9-5 14:57
@echo off
for /f "delims=" %%a in (11.txt) do echo %%a|find "Ethernet"&&echo %%a>2.txt
type 2.txt>11.txt
代码执行后只有最后一行保留!!
470 0021.973f.45ee DYNAMIC FastEthernet 6/24
作者:
ccccpp
时间:
2011-9-5 15:11
本帖最后由 ccccpp 于 2011-9-5 15:15 编辑
@findstr Ethernet 11.txt>22.txt
完全搞定
紧接就是要端口--IP--MAC ?!!如何写?
作者:
ccccpp
时间:
2011-9-13 10:54
删贴吧,谢谢
作者:
caruko
时间:
2011-9-13 11:17
看来你网络协议方面的知识不过关啊..
你可以安装一个抓包工具,监视CMD.EXE的发包记录,然后开始telnet到一个路由器上进行操作。
telnet 基本上就等于一个tcp连接,你把记录下来的数据包(不要16进制,转为ascii字符)保存为cmdline.txt,然后把路由器地址做一个列表list.txt。
然后写一个批,做到通过遍历 list.txt,用netcat将cmdline.txt的数据提交出去,最后将接收到得数据进行提取,这才是全自动化啊。
不过你需要tcp/ip知识。
作者:
ccccpp
时间:
2011-9-13 12:52
不用这么麻烦吧,用"超级终端"中的"捕获文字"就可以生成一个list.txt
还有只是提取端口数据用于统计,不用提交
欢迎光临 批处理之家 (http://bathome.net./)
Powered by Discuz! 7.2