This repository was archived by the owner on Jan 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 26 files changed +775
-0
lines changed
Expand file tree Collapse file tree 26 files changed +775
-0
lines changed Original file line number Diff line number Diff line change 44
55- 实验三——动态路由协议——的相关代码和报告;
66- 实验四——虚拟局域网——的相关代码和报告;
7+ - 实验六——综合网络实践——拓展实验的说明文档、自动化工具和模拟验证。
78
89## 使用说明
910
Original file line number Diff line number Diff line change 1+ output
Original file line number Diff line number Diff line change 1+ # 实验六——综合网络实践
2+
3+ 本实验为拓展实验,其内容为:使用** 多厂商** (Cisco,H3C 和 Juniper)路由器进行网络配置,实现全连接物理网络上的逻辑网络划分。
4+
5+ ## 组队要求
6+
7+ 可以组成** 规模较大** 的团队,充分彰显团队协作能力。
8+
9+ ## 实验步骤
10+
11+ 1 . 抵达配置现场,将** 配置用** PC 连接到有线网络,配置为** 配置网络** 的 IPv4 地址和子网掩码,通过 ` ping ` 确证可以连接到配置服务器;
12+ 2 . 打开机柜,根据分配设备的情况进行** 接口编号** 的确定,将设备厂家和设备接口编号写在文件 ` config.json ` 中;** 必要时** 应将连线进行重新整理,以确保接口编号正确无误;
13+ 3 . 执行 ` main.py ` ,生成相应配置命令 ` output/configuration_<n>.txt ` ;
14+ 4 . Telnet 连接到各设备,执行相应配置命令,完成配置;
15+ 5 . 检验路由表的正确性;
16+ 6 . 启动多台** 测试用** PC,连接到同一有线网络,配置为** 测试网络** 的 IPv4 地址、子网掩码和默认网关,同时** 调节防火墙设置** ,使用 ` ping ` 或者 ` iperf ` 等工具对网络的通断和性能进行测试;
17+ 7 . 整理并关闭所有 PC,按照实验室管理规定对机柜进行清理,** 登记后有序离开** 。
18+
19+ ## 示例
20+
21+ 上传的 ` config.json ` 文件内容为本组成员实际实验时所用的设备和接口编号,对应设备型号如下:
22+
23+ - ** Router 1** :Juniper Networks J4350;
24+ - ** Router 2** :Cisco 2800;
25+ - ** Router 3** :H3C MSR50-40;
26+ - ** Router 4** :H3C MSR50-40。
27+
28+ 在确保安全的情况下,为了方便接口的确定,可拔掉实验设备上所有 RJ45 接口上的线缆,并将其重新连接到路由器主板的两个 RJ45 接口上,以获取更加明确的接口编号和更快的连接速率。
29+
30+ ## 注意事项
31+
32+ - 若路由器的接口未连接到另一路由的某个接口上,则接口将无法启动;
33+ - 使用 Windows 系统的 PC 之间使用 ` ping ` 测试网络通断需要允许系统处理 ICMP Request,需要调节防火墙的相应设置,若时间紧迫可直接关闭防火墙;
34+ - Telnet 会话未正常退出将会使得配置服务器无法正常释放连接,此时可以手动重启配置服务器。
35+
36+ ## 网络拓扑和模拟验证
37+
38+ 网络拓扑见 ` network.pdf ` ,模拟验证见目录 ` test ` 。
Original file line number Diff line number Diff line change 1+ {
2+ "1" : {
3+ "template" : " Juniper" ,
4+ "interface_0" : " ge-0/0/0" ,
5+ "interface_1" : " ge-0/0/1"
6+ },
7+ "2" : {
8+ "template" : " Cisco" ,
9+ "interface_0" : " GigabitEthernet0/0" ,
10+ "interface_1" : " GigabitEthernet0/1"
11+ },
12+ "3" : {
13+ "template" : " H3C" ,
14+ "interface_0" : " GigabitEthernet0/0" ,
15+ "interface_1" : " GigabitEthernet0/1"
16+ },
17+ "4" : {
18+ "template" : " H3C" ,
19+ "interface_0" : " GigabitEthernet0/0" ,
20+ "interface_1" : " GigabitEthernet0/1"
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ """
2+ Generate router configuration
3+ """
4+
5+ import json
6+ import os
7+
8+ TEMPLATE_PATH = "template"
9+ OUTPUT_PATH = "output"
10+
11+ if __name__ == "__main__" :
12+ with open (
13+ file = "config.json" ,
14+ mode = "r" ,
15+ encoding = "utf-8" ,
16+ ) as f :
17+ config = json .load (fp = f )
18+
19+ for index , info in config .items ():
20+ router_id = int (index )
21+ print (f"router_id: { router_id } , info: { info } " )
22+ template_name = info ["template" ]
23+ with open (
24+ file = f"{ TEMPLATE_PATH } /{ template_name } .txt" ,
25+ mode = "r" ,
26+ encoding = "utf-8" ,
27+ ) as f :
28+ template : list [str ] = f .read ().splitlines ()
29+
30+ commands : list [str ] = template
31+
32+ commands = [line .strip () for line in commands ]
33+ commands = [line for line in commands if not line .startswith ("#" ) and len (line )]
34+ commands = [line .replace ("<router_id>" , str (router_id )) for line in commands ]
35+ commands = [
36+ line .replace ("<interface_0>" , info ["interface_0" ]) for line in commands
37+ ]
38+ commands = [
39+ line .replace ("<interface_1>" , info ["interface_1" ]) for line in commands
40+ ]
41+
42+ os .makedirs (f"{ OUTPUT_PATH } " , exist_ok = True )
43+ with open (
44+ file = f"{ OUTPUT_PATH } /configuration_{ router_id } .txt" ,
45+ mode = "w" ,
46+ encoding = "utf-8" ,
47+ ) as f :
48+ for command in commands :
49+ f .write (f"{ command } \n " )
Original file line number Diff line number Diff line change 1+ # Cisco 路由器配置命令模板
2+ # 进入权限模式
3+ enable
4+
5+ # 检查当前路由器信息
6+ show version
7+
8+ # 进入配置模式
9+ configure terminal
10+
11+ # 配置 hostname,方便查看
12+ hostname Router-<router_id>
13+
14+ # 配置接口 interface_0 的 IPv4 地址
15+ interface <interface_0>
16+ ip address 204.210.255.<router_id> 255.255.255.0
17+ no shutdown
18+ exit
19+
20+ # 配置接口 interface_1 的 IPv4 地址
21+ interface <interface_1>
22+ ip address 204.210.<router_id>.254 255.255.255.0
23+ no shutdown
24+ exit
25+
26+ # 配置 OSPFv2 协议
27+ router ospf 720
28+
29+ # 将两个网络加入 area 0
30+ network 204.210.255.0 0.0.0.255 area 0
31+ network 204.210.<router_id>.0 0.0.0.255 area 0
32+
33+ exit
34+
35+ exit
Original file line number Diff line number Diff line change 1+ # H3C 路由器配置命令模板
2+ # 检查当前路由器信息
3+ display device
4+
5+ # 进入配置模式
6+ system-view
7+
8+ # 配置 hostname,方便查看
9+ sysname Router-<router_id>
10+
11+ # 配置接口 interface_0 的 IPv4 地址
12+ interface <interface_0>
13+ ip address 204.210.255.<router_id> 255.255.255.0
14+ undo shutdown
15+ quit
16+
17+ # 配置接口 interface_1 的 IPv4 地址
18+ interface <interface_1>
19+ ip address 204.210.<router_id>.254 255.255.255.0
20+ undo shutdown
21+ quit
22+
23+ # 配置 OSPFv2 协议
24+ ospf 720
25+
26+ # 配置区域为 area 0
27+ area 0.0.0.0
28+
29+ # 将两个网络加入 area 0
30+ network 204.210.255.0 0.0.0.255
31+ network 204.210.<router_id>.0 0.0.0.255
32+
33+ quit
34+
35+ quit
36+
37+ quit
Original file line number Diff line number Diff line change 1+ # Juniper 路由器配置命令模板
2+ # 检查当前路由器信息
3+ show version
4+
5+ # 进入配置模式
6+ configure
7+
8+ # 配置 hostname,方便查看
9+ set system host-name Router-<router_id>
10+
11+ # 配置接口 IPv4 地址
12+ set interfaces <interface_0> unit 0 family inet address 204.210.255.<router_id>/24
13+ set interfaces <interface_1> unit 0 family inet address 204.210.<router_id>.254/24
14+
15+ # 配置 OSPFv2 协议,将两个 interface 加入 area 0
16+ set protocols ospf area 0.0.0.0 interface <interface_0>
17+ set protocols ospf area 0.0.0.0 interface <interface_1>
18+
19+ # 下面配置安全策略
20+ # 建立区域 Trust,允许所有协议和服务的流量流入
21+ set security zones security-zone Trust host-inbound-traffic protocols all
22+ set security zones security-zone Trust host-inbound-traffic system-services all
23+
24+ # 允许区域 Trust 到自身的所有流量转发
25+ set security policies from-zone Trust to-zone Trust policy default-permit match source-address any
26+ set security policies from-zone Trust to-zone Trust policy default-permit match destination-address any
27+ set security policies from-zone Trust to-zone Trust policy default-permit match application any
28+ set security policies from-zone Trust to-zone Trust policy default-permit then permit
29+
30+ # 将两个 interface 加入区域 Trust
31+ set security zones security-zone Trust interfaces <interface_0>
32+ set security zones security-zone Trust interfaces <interface_1>
33+
34+ # 提交
35+ commit
Original file line number Diff line number Diff line change 1+ {
2+ "startupDelay" : 3 ,
3+ "netfile" : " network.net" ,
4+ "deviceDistribution" : [
5+ {
6+ "port" : 7201 ,
7+ "directory" : " router"
8+ },
9+ {
10+ "port" : 7202 ,
11+ "directory" : " switch"
12+ },
13+ {
14+ "port" : 7203 ,
15+ "directory" : " pc"
16+ }
17+ ],
18+ "autoConfiguration" : {
19+ "maxParallelTaskLimit" : 64 ,
20+ "devices" : [
21+ {
22+ "port" : 3001 ,
23+ "file" : " Router-1.txt"
24+ },
25+ {
26+ "port" : 3002 ,
27+ "file" : " Router-2.txt"
28+ },
29+ {
30+ "port" : 3003 ,
31+ "file" : " Router-3.txt"
32+ },
33+ {
34+ "port" : 3004 ,
35+ "file" : " Router-4.txt"
36+ },
37+ {
38+ "port" : 4001 ,
39+ "file" : " Switch-Core.txt"
40+ },
41+ {
42+ "port" : 5001 ,
43+ "file" : " PC-1.txt"
44+ },
45+ {
46+ "port" : 5002 ,
47+ "file" : " PC-2.txt"
48+ },
49+ {
50+ "port" : 5003 ,
51+ "file" : " PC-3.txt"
52+ },
53+ {
54+ "port" : 5004 ,
55+ "file" : " PC-4.txt"
56+ },
57+ {
58+ "port" : 5005 ,
59+ "file" : " PC-5.txt"
60+ },
61+ {
62+ "port" : 5006 ,
63+ "file" : " PC-6.txt"
64+ },
65+ {
66+ "port" : 5007 ,
67+ "file" : " PC-7.txt"
68+ },
69+ {
70+ "port" : 5008 ,
71+ "file" : " PC-8.txt"
72+ }
73+ ]
74+ }
75+ }
You can’t perform that action at this time.
0 commit comments