Files
NE_YuR/big1/big1.typ
2025-11-09 23:53:05 +08:00

1111 lines
40 KiB
Typst
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#import "labtemplate.typ": *
#show: nudtlabpaper.with(title: "异构网络设计综合实验",
author1: "程景愉",
id1: "202302723005",
training_type:"计算机类",
grade: "大三",
major: "网络工程",
department: "计算机学院",
advisor: "张军",
jobtitle: "工程师",
lab: "306-707",
date: "2025.10.28",
header_str: "《网络工程》实验报告",
)
#set page(header: [
#set par(spacing: 6pt)
#align(center)[#text(size: 11pt)[网络工程课程设计实验报告]]
#v(-0.3em)
#line(length: 100%, stroke: (thickness: 1pt))
],)
#show heading: it => box(width: 100%)[
#v(0.50em)
#set text(font: hei)
#it.body
]
#outline(title: "目录",depth: 3, indent: 1em)
#outline(
title: [图目录],
target: figure.where(kind: image),
)
#show heading: it => box(width: 100%)[
#v(0.50em)
#set text(font: hei)
#counter(heading).display()
// #h(0.5em)
#it.body
]
// Display inline code in a small box
// that retains the correct baseline.
#show raw.where(block: false): it => box(
text(font: ("Maple Mono NF","Noto Sans CJK SC"), it),
fill: luma(240),
inset: (x: 3pt, y: 0pt),
outset: (y: 3pt),
radius: 2pt,
)
// Display block code in a larger block
// with more padding.
#show raw.where(block: true): it => block(
text(font: ("Maple Mono NF","Noto Sans CJK SC"), it),
fill: luma(240),
inset: 6pt,
radius: 3pt,
width: 100%,
)
#set enum(indent: 0.5em,body-indent: 0.5em,)
#pagebreak()
= 实验目的
#para[
通过对常用的组网设备包括交换机、路由器、防火墙、常见的网络服务系统Web服务、Proxy服务、Smtp & Pop3服务、DNS服务等的安装与配置与调试实验加深对上述设备和系统工作原理的理解初步掌握其安装配置方法为将来从事网络工程建设打下基础。
]
= 实验概述
#para[
一个完整的组网工程包括需求分析、方案设计、设备选型与采购、硬件安装与配置、软件安装与配置、系统测试与联调、工程验收等若干个环节,其中硬件与应用系统安装、配置工作量大,技术含量高,是信息系统集成或网络工程的关键环节,其中既涉及到技术上的问题,也涉及到工程组织、协调配合上的问题,一个网络工程师只有通过多次工程的实际锻炼,不断积累经验、吸取教训才能提高自己的水平。
]
= 需求分析
#para[
设计并构建一个小型的校园网络平台并在该平台上构建INTERNET服务平台该网络工程建成后将具有以下服务功能
]
1. 具有内部Web 服务功能;
2. 具有外部Web服务代理功能
3. 具有邮件收发功能;
4. 具有对内部核心子网安全保护功能;
5. 具有内部域名解析功能;
6. 具有简单的网络管理功能。
== 技术分析
#para[
为满足校园的网络需求网络建设需采用多种先进技术。首先通过链路聚合技术Eth-trunk提升网络带宽和链路可靠性特别是在核心层与接入层之间。其次需使用虚拟路由冗余协议VRRP确保出口网关的高可用性防止单点故障。VLAN技术用于划分不同部门的安全区域确保网络流量的隔离与安全性。MAC地址绑定用于确保网络设备的安全性。STP技术用于防止网络环路。此外无线网络覆盖技术用于支持移动办公和访客接入确保网络的全面覆盖。
]
#para[
该小型校园的网络建设需要多种设备来满足需求。首先选择两台路由器AR1、AR2作为出口网关支持VRRP协议。其次核心层需要两台支持堆叠技术的交换机LSW1、LSW2使用普通线缆堆叠用于连接各个接入层交换机和防火墙。接入层需要多台交换机LSW3、LSW4、LSW5用于连接终端设备如PC、服务器等。防火墙方面需要一台防火墙FW用于网络安全防护支持分时访问。此外还需要无线接入点AP用于无线网络覆盖。总体来看本次实验设备包括4台路由器、4台交换机、1台防火墙、三台PC及一块树莓派用于模拟服务器与提供AP确保实验网络的全面覆盖与高效运行。
]
== 实验环境
#para[
软件清单:
]
#align(center)[#table(
columns: (auto, auto),
rows:40pt,
inset: 10pt,
align: horizon+center,
table.header(
[软件名称], [软件功能]
),
"Apache HTTP Server", "提供Web服务",
"Poste.io Mail Server", "提供邮件服务SMTP/POP3",
"Vsftpd", "提供FTP服务",
"Wireshark", "网络数据包分析工具",
"PuTTY", "SSH/Telnet远程终端工具",
"EndeavourOS Linux", "树莓派操作系统",
"Huawei eNSP", "网络设备模拟与配置工具",
)]
#para[
硬件设备:
]
#align(center)[#table(
columns: (auto, auto,auto,auto),
rows:40pt,
inset: 10pt,
align: horizon+center,
table.header(
[设备名称], [设备型号], [设备数量],[设备名称]
),
"交换机", "华为S5735", "4","CORE(LSW1 + LSW2)、LSW3、LSW4",
"路由器", "华为AR6120-S", "4","R1、R2、R3、R_NEW",
"防火墙", "华为USG6303E-AC", "1","FW",
"树莓派", "Raspberry Pi Model 4B", "1","server",
"PC", "联想启天M410
Windows 10", "3","PC1、PC2、PC3"
)]
#para[
另有网线、控制线若干。
]
== 任务分工
#align(center)[#table(
columns: (auto, auto, auto),
rows:40pt,
inset: 10pt,
align: horizon+center,
table.header(
[任务], [分工], [时间]
),
"结构设计与构思", "程景愉", "10.22",
"服务器配置", "程景愉", "10.23-10.28",
"交换机路由器配置", "程景愉", "10.23-10.28",
"防火墙配置", "程景愉", "10.23-10.28",
"调试", "程景愉", "10.29",
"实验测试", "程景愉", "11.1-11.2",
"进阶实验", "程景愉", "11.7-11.8",
)]
== 拓扑图表
#para[
下面给出拓扑图和设备连接表,详细描述该小型校园网络的设计方案。
]
=== 拓扑图
#para[
物理链路的拓扑图如@topo 所示(见下页):
]
#figure(image("网络拓扑.png",format: "png",fit:"stretch",width: 115%),caption: "实验拓扑图")<topo>
#para[
实验示意图如@logic_topo 所示(见下页):
]
#figure(image("实验示意图.png",format: "png",fit:"stretch",width: 120%),caption: "实验示意图")<logic_topo>
#para[
接下来给出设备连接表(拓扑表):
]
// #para[
#figure(image("地址表.png",format: "png",fit:"stretch",width: 100%),caption: "IP 地址表(以实际实验为准)")
#pagebreak()
// #set page(flipped: true)
= 实验步骤及结果
#para[]
== 设备连接
#para[
将所有设备按照拓扑图连接好,确保每个设备的接口都正确连接:
]
#figure(image("机柜正面.jpg",format: "jpg",fit:"stretch",width: 40%),caption: "机柜正面接线图")<front>
#figure(image("机柜背面.jpg",format: "jpg",fit:"stretch",width: 40%),caption: "机柜背面接线图")<back>
#para[
注:以上为验收前拍摄的图片,验收后有返回机房进行实验补充如交换机堆叠与邮件服务器部署,实际情况以报告内容为准。
]
== 接入层 (S3, S4) 与核心层 (CORE) L2/L3 基本功能配置
=== 组建堆叠系统
#para[
堆叠功能在验收后补充进行原因是一开始以为必须有专用堆叠线缆导致无法实验后查询华为文档发现支持普通线缆堆叠。在此处配置开始之前必须明确本设备的逻辑堆叠端口stack-port 0/1对应的物理端口必须连接邻设备的逻辑堆叠端口stack-port 0/2对应的物理端口否则堆叠组建不成功。
]
+ 配置逻辑堆叠端口并加入物理成员端口。
- 配置LSW1的业务口g0/0/20、g0/0/21为物理成员端口并加入到相应的逻辑堆叠端口。
```
<HUAWEI> system-view
[HUAWEI] sysname LSW1
[LSW1] interface stack-port 0/1
[LSW1-stack-port0/1] port interface g0/0/20 enable
Warning: Enablingstack function may cause configuration loss on the interface. Continue? [Y/N]:y
Info: This operation may take a few seconds. Please wait.
[LSW1-stack-port0/1] quit
[LSW1] interface stack-port 0/2
[LSW1-stack-port0/2] port interface g0/0/21 enable
Warning: Enablingstack function may cause configuration loss on the interface. Continue? [Y/N]:y
Info: This operation may take a few seconds. Please wait.
[LSW1-stack-port0/2] quit
```
- 配置LSW2的业务口g0/0/20、g0/0/21为物理成员端口并加入到相应的逻辑堆叠端口。
```
<HUAWEI> system-view
[HUAWEI] sysname LSW2
[LSW2] interface stack-port 0/1
[LSW2-stack-port0/1] port interface g0/0/20 enable
Warning: Enablingstack function may cause configuration loss on the interface. Continue? [Y/N]:y
Info: This operation may take a few seconds. Please wait.
[LSW2-stack-port0/1] quit
[LSW2] interface stack-port 0/2
[LSW2-stack-port0/2] port interface g0/0/21 enable
Warning: Enablingstack function may cause configuration loss on the interface. Continue? [Y/N]:y
Info: This operation may take a few seconds. Please wait.
[LSW2-stack-port0/2] quit
```
+ 配置堆叠ID和堆叠优先级
- 配置LSW1的堆叠优先级为200。
```
[LSW1] stack slot 0 priority 200
Warning: Do not frequently modify the Priority because it will make the stack split. Continue? [Y/N]:y
```
- 配置LSW2的堆叠ID即Slot为1。
```
[LSW2] stack slot 0 renumber 1
Warning: All the configurations related to the slot ID will be lost after the slot ID is modified.
Do not frequently modify the slot ID because it will make the stack split. Continue? [Y/N]:y
Info: Stack configuration has been changed, and the device needs to restart to make the configuration effective.
```
+ 在每台设备上、在用户界面下输入`save`命令,保存配置信息。
+ 关闭设备并按顺序启动
- 关闭LSW1、LSW2。
- 先启动LSW1等待2分钟左右控制机能够登录到LSW1之后再启动LSW2。
+ 检验配置结果
使用`display stack`命令查看堆叠状态,输出信息如下:
```
[CORE]disp stack
Stack mode: Service-port
Stack topology type: Ring
Stack system MAC: 6012-3c9a-5ff0
MAC switch delay time: 10 min
Stack reserved VLAN: 4093
Slot of the active management port: --
Slot Role MAC Address Priority Device Type
-------------------------------------------------------------
0 Master 6012-3c9a-5ff0 200 S5735S-S24T4S-A
1 Standby 642c-acc1-5970 100 S5735S-S24T4S-A
```
输出展示了堆叠的状态信息包括堆叠模式、堆叠拓扑类型、堆叠系统MAC地址、MAC切换延迟时间、堆叠保留VLAN、激活管理端口的槽位、各个槽位的角色、MAC地址、优先级和设备类型。其中槽位0的Priority为200槽位1的Priority为100在竞争中槽位0最终会成为Master角色槽位1为Standby角色。按照顺序上电能够保证设备快速进入事先规定好的角色。
#para[
配置完成后两台设备将组成一个堆叠系统逻辑上看成一个设备标号为CORE称为核心集群。在后续的配置中将以CORE作为设备名称。
]
=== 配置员工区交换机
#para[
员工区交换机 S3 主要负责连接员工的终端设备如PC1并通过核心集群与其他网络区域进行通信。为了确保网络的高效性和安全性需要对 S3 进行基本的 VLAN 和链路聚合配置。下面开始配置 S3 的基本信息和 VLAN
]
```
[S3] sysname S3
[S3] vlan batch 10
# 配置 Eth-Trunk 到 CORE
[S3] interface Eth-Trunk 1
[S3] port link-type trunk
[S3] port trunk allow-pass vlan 10
[S3] mode lacp-static # 静态LACP
[S3] quit
[S3] interface GigabitEthernet 0/0/1
[S3] eth-trunk 1
[S3] quit
[S3] interface GigabitEthernet 0/0/2
[S3] eth-trunk 1
[S3] quit
# 配置接入端口 (PC1)
[S3] interface GigabitEthernet 0/0/3
[S3] port link-type access
[S3] port default vlan 10
[S3] stp edged-port enable # 边缘端口,快速转发
[S3] quit
```
=== 配置服务器/访客区交换机
#para[
服务器/访客区交换机 S4 主要负责连接服务器和访客的终端设备如PC3并通过核心集群与其他网络区域进行通信。为了确保网络的高效性和安全性需要对 S4 进行基本的 VLAN 和链路聚合配置。下面开始配置 S4 的基本信息和 VLAN
]
```
[S4] sysname S4
[S4] vlan batch 20 30
# 配置 Eth-Trunk 到 CORE
[S4] interface Eth-Trunk 1
[S4] port link-type trunk
[S4] port trunk allow-pass vlan 20 30
[S4] mode lacp-static
[S4] quit
[S4] interface GigabitEthernet 0/0/1
[S4] eth-trunk 1
[S4] quit
[S4] interface GigabitEthernet 0/0/2
[S4] eth-trunk 1
[S4] quit
# 配置接入端口 (Server)
[S4] interface GigabitEthernet 0/0/3
[S4] port link-type access
[S4] port default vlan 20
[S4] stp edged-port enable
[S4] quit
# 配置接入端口 (PC3)
[S4] interface GigabitEthernet 0/0/4
[S4] port link-type access
[S4] port default vlan 30
[S4] stp edged-port enable
[S4] quit
# 配置接入端口 (R_NEW)
[S4] interface GigabitEthernet 0/0/5
[S4] port link-type access
[S4] port default vlan 40
[S4] stp edged-port enable
[S4] quit
```
=== 配置核心堆叠交换机的Eth-Trunk功能和接口IP地址
#para[
此步骤是要将核心集群与其他设备相连的物理链路聚合起来,以提高链路的带宽和可靠性。
]
#pagebreak()
+ 配置 CORE 网关
```
[CORE] vlan batch 10 20 30 40
[CORE] interface Vlanif 10
[CORE] ip address 192.168.10.254 255.255.255.0
[CORE] quit
[CORE] interface Vlanif 20
[CORE] ip address 192.168.20.254 255.255.255.0
[CORE] quit
[CORE] interface Vlanif 30
[CORE] ip address 192.168.30.254 255.255.255.0
[CORE] quit
[CORE] interface Vlanif 40
[CORE] ip address 10.0.4.1 255.255.255.252
[CORE] quit
```
+ 配置 Eth-Trunk S3
```
[CORE] interface Eth-Trunk 1
[CORE] port link-type trunk
[CORE] port trunk allow-pass vlan 10
[CORE] mode lacp-static
[CORE] quit
[CORE] interface GigabitEthernet 1/0/1
[CORE] eth-trunk 1
[CORE] quit
[CORE] interface GigabitEthernet 2/0/1
[CORE] eth-trunk 1
[CORE] quit
```
+ 配置 Eth-Trunk S4
```
[CORE] interface Eth-Trunk 2
[CORE] port link-type trunk
[CORE] port trunk allow-pass vlan 20 30
[CORE] mode lacp-static
[CORE] quit
[CORE] interface GigabitEthernet 1/0/2
[CORE] eth-trunk 2
[CORE] quit
[CORE] interface GigabitEthernet 2/0/2
[CORE] eth-trunk 2
[CORE] quit
```
+ 配置 CORE 接口到 R_NEW
```
[CORE] interface GigabitEthernet 1/0/3
[CORE] port link-type access
[CORE] port default vlan 40
[CORE] quit
```
== 接入层安全配置 (S3, S4)
#para[
接入层的配置比较简单,主要涉及到 VLAN, MAC地址绑定。
]
+ 配置 S3
```
[S3] dhcp enable
[S3] dhcp snooping enable
[S3] dhcp snooping enable vlan 10
# 信任上联到 CORE 的 Trunk 口
[S3] interface Eth-Trunk 1
[S3] dhcp snooping trusted
[S3] quit
# 配置 PC1 端口安全
[S3] interface GigabitEthernet 0/0/3
[S3] port-security enable
[S3] port-security max-mac-num 1 # 只允许1个MAC地址
[S3] port-security protect-action restrict # 丢弃并告警
[S3] quit
```
+ 配置 S4
```
[S4] dhcp enable
[S4] dhcp snooping enable
[S4] dhcp snooping enable vlan 20 30
# 信任上联到 CORE 的 Trunk 口
[S4] interface Eth-Trunk 1
[S4] dhcp snooping trusted
[S4] quit
# 配置 Server 端口安全
[S4] interface GigabitEthernet 0/0/3
[S4] port-security enable
[S4] port-security max-mac-num 1
[S4] port-security protect-action restrict
[S4] quit
# 配置 PC3 端口安全
[S4] interface GigabitEthernet 0/0/4
[S4] port-security enable
[S4] port-security max-mac-num 1
[S4] port-security protect-action restrict
[S4] quit
```
== OSPF路由配置
#para[
本次实验我将使用 OSPF Area 0 作为内部骨干区域Area 1 作为外部 ISP 区域。
]
#pagebreak()
+ 在 CORE 上配置路由
```plaintext
[CORE] ospf 1 router-id 1.1.1.1
[CORE] area 0
[CORE] network 192.168.10.0 0.0.0.255
[CORE] network 192.168.20.0 0.0.0.255
[CORE] network 192.168.30.0 0.0.0.255
[CORE] network 10.0.4.0 0.0.0.3
[CORE] quit
[CORE] quit
```
+ 在 R_NEW 上配置路由
```plaintext
[R_NEW] sysname R_NEW
[R_NEW] interface GigabitEthernet 0/0/0
[R_NEW] ip address 10.0.1.2 255.255.255.252
[R_NEW] quit
[R_NEW] interface GigabitEthernet 0/0/1
[R_NEW] ip address 10.0.4.1 255.255.255.252
[R_NEW] quit
[R_NEW] ospf 1 router-id 2.2.2.2
[R_NEW] area 0
[R_NEW] network 10.0.1.0 0.0.0.3
[R_NEW] network 10.0.4.0 0.0.0.3
[R_NEW] quit
[R_NEW] quit
```
+ R1 (出口1 - 主) 上配置路由
#para[
这里我在验收后补充实验时选择改为使用`ospf cost`来替代`VRRP`实现冗余备份功能,增强网络系统的健壮性。
]
```
[AR2] interface Eth-Trunk 2
[AR2-Eth-Trunk2] undo portswitch
[AR2-Eth-Trunk2] mode lacp-static
[AR2-Eth-Trunk2] quit
[AR2] interface GigabitEthernet 0/0/4
[AR2-GigabitEthernet0/0/4] Eth-Trunk 2
[AR2-GigabitEthernet0/0/4] quit
[AR2] interface GigabitEthernet 0/0/5
[AR2-GigabitEthernet0/0/5] Eth-Trunk 2
[AR2-GigabitEthernet0/0/5] quit
```
+ R2 (出口2 - 备) 上配置路由
```
[R2] sysname R2
[R2] interface GigabitEthernet 0/0/0
[R2] ip address 10.0.3.1 255.255.255.252
[R2] quit
[R2] interface GigabitEthernet 0/0/1
[R2] ip address 203.0.113.6 255.255.255.252
[R2] ospf cost 100 # **关键:设置高 cost作为备路**
[R2] quit
[R2] ospf 1 router-id 4.4.4.4
[R2] area 0
[R2] network 10.0.3.0 0.0.0.3
[R2] quit
[R2] area 1
[R2] network 203.0.113.4 0.0.0.3
[R2] quit
[R2] quit
```
+ R3 (ISP 模拟) 上配置路由
```plaintext
[R3] sysname R3
[R3] interface GigabitEthernet 0/0/0
[R3] ip address 203.0.113.1 255.255.255.252
[R3] quit
[R3] interface GigabitEthernet 0/0/1
[R3] ip address 203.0.113.5 255.255.255.252
[R3] quit
[R3] interface GigabitEthernet 0/0/2
[R3] ip address 172.16.1.254 255.255.255.0
[R3] quit
[R3] interface GigabitEthernet 0/0/3
[R3] ip address 8.8.8.1 255.255.255.0
[R3] quit
[R3] ospf 1 router-id 5.5.5.5
[R3] area 1
[R3] network 203.0.113.0 0.0.0.3
[R3] network 203.0.113.4 0.0.0.3
[R3] network 172.16.1.0 0.0.0.255
[R3] network 8.8.8.0 0.0.0.255
[R3] quit
[R3] ospf 1
[R3] default-route-advertise always
[R3] quit
```
=== 配置出口网关的BFD功能
#para[
配置 R1 R2 之间的 BFD 功能,用于快速检测链路故障并触发 OSPF 路由收敛。
]
+ 配置全局 BFD 功能。
```plaintext
[R1] bfd
[R1-bfd] quit
```
```plaintext
[R2] bfd
[R2-bfd] quit
```
+ R1 上配置 OSPF BFD 特性。
```plaintext
[R1] ospf 100 // 进入 OSPF 视图
[R1-ospf-100] bfd all-interfaces enable // 打开 OSPF BFD 特性的开关,建立 BFD 会话
[R1-ospf-100] quit
```
+ R2 上配置 OSPF BFD 特性。
```plaintext
[R2] ospf 100 // 进入 OSPF 视图
[R2-ospf-100] bfd all-interfaces enable // 打开 OSPF BFD 特性的开关,建立 BFD 会话
[R2-ospf-100] quit
```
+ 配置 BFD 参数。
```plaintext
[R1-ospf-100] bfd all-interfaces min-rx-interval 1000 min-tx-interval 1000 detect-multiplier 3
[R2-ospf-100] bfd all-interfaces min-rx-interval 1000 min-tx-interval 1000 detect-multiplier 3
```
#para[
此时R1 R2 之间已经建立了 BFD 会话,可以使用 `display bfd session` 命令查看 BFD 会话状态。
]
== DHCP 中继与服务器配置
=== CORE 的 DHCP 中继配置
```
[CORE] dhcp enable
# 全局启用中继
[CORE] dhcp relay server-ip 10.0.1.1 # 指向 FW1 的 Trust 接口 IP
# 在 Vlanif 上启用
[CORE] interface Vlanif 10
[CORE] dhcp select relay
[CORE] quit
[CORE] interface Vlanif 30
[CORE] dhcp select relay
[CORE] quit
```
=== FW1 防火墙上的 DHCP 服务配置
#para[
此步骤在 FW1 Web-UI 中完成:
]
+ 导航到 网络 > DHCP > DHCP服务器 > DHCP地址池。
+ 新建 地址池 (VLAN 10)
地址池名称: VLAN10_Staff
网段: 192.168.10.0
掩码: 255.255.255.0
网关: 192.168.10.254
DNS服务器: 8.8.8.8 (或ISP的DNS)
地址池范围: 192.168.10.100 到 192.168.10.200
+ 新建 地址池 (VLAN 30)
地址池名称: VLAN30_Guest
网段: 192.168.30.0
掩码: 255.255.255.0
网关: 192.168.30.254
DNS服务器: 8.8.8.8
地址池范围: 192.168.30.100 192.168.30.200
#para[
确保 DHCP 服务器功能已在 Trust 区域接口上启用(通常默认启用)。
]
== 防火墙 (FW1) 的基本功能配置
=== 接口与区域配置
+ 导航到 网络 > 接口。
配置 GigabitEthernet1/0/0 (to R_NEW):
安全区域: Trust
IP地址: 10.0.1.1 / 30
安全区域DMZ
IP地址: 192.168.20.0/24
配置 GigabitEthernet1/0/1 (to R1):
安全区域: Untrust
IP地址: 10.0.2.2 / 30
配置 GigabitEthernet1/0/2 (to R2):
安全区域: Untrust
IP地址: 10.0.3.2 / 30
#figure(image("interface.jpg",format: "jpg",fit:"stretch",width: 60%),caption: "防火墙接口配置")
=== 防火墙的 OSPF 配置
```
[FW1] ospf 1 router-id 6.6.6.6
[FW1-ospf-1] area 0
[FW1-ospf-1-area-0.0.0.0] network 10.0.1.0 0.0.0.3
[FW1-ospf-1-area-0.0.0.0] network 10.0.2.0 0.0.0.3
[FW1-ospf-1-area-0.0.0.0] network 10.0.3.0 0.0.0.3
[FW1-ospf-1-area-0.0.0.0] quit
[FW1-ospf-1] quit
[FW1] quit
```
=== 安全策略 (内网上网)
导航到 策略 > 安全策略。
新建 策略:
名称: Trust_to_Untrust_Allow
源区域: Trust
目的区域: Untrust
源地址: Any (或 192.168.0.0/16)
目的地址: Any
服务: Any
动作: Permit
#figure(image("security1.jpg",format: "jpg",fit:"stretch",width: 60%),caption: "安全策略配置")
=== SNAT (源NAT) 策略 (内网上网)
导航到 策略 > NAT策略 > 源NAT。
新建 策略:
源区域: Trust
目的区域: Untrust
源地址: 192.168.0.0 / 16 (覆盖所有内网VLAN)
目的地址: Any
动作: 源NAT
转换模式: 出接口地址 (这样流量走R1就NAT成R1接口IP走R2就NAT成R2接口IP)。注意:这里 FW1 的出接口是 10.0.2.2 10.0.3.2这还不是实验中设计的公网IP。
#figure(image("nat.jpg",format: "jpg",fit:"stretch",width: 60%),caption: "NAT 策略配置")
拓扑缺陷与解决: 我设计的拓扑中FW1在R1/R2之后SNAT需要做两次。
FW1 (Web-UI): Trust -> Untrust (192.168.x.x -> 10.0.2.2/10.0.3.2)
R1/R2 (CLI): 需要再做一次 NAT (192.168.x.x -> 203.0.113.x)
为解决问题,在 R1/R2 上配置 SNAT :
```
[R1] acl 3000
[R1-acl-adv-3000] rule 5 permit ip source 192.168.0.0 0.0.255.255
[R1-acl-adv-3000] quit
[R1] interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1] nat outbound 3000
[R1-GigabitEthernet0/0/1] quit
[R2] acl 3000
[R2-acl-adv-3000] rule 5 permit ip source 192.168.0.0 0.0.255.255
[R2-acl-adv-3000] quit
[R2] interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1] nat outbound 3000
[R2-GigabitEthernet0/0/1] quit
```
#para[
FW1上的 SNAT (Web-UI): (如上所述) Trust -> Untrust源: 192.168.0.0/16动作: NAT (出接口地址)。
]
=== 分时访问策略配置
导航到 对象 > 时间段。
新建 时间段:
名称: Work_Time
类型: 周期
星期: 勾选 周一 到 周五
时间: 08:00:00 到 17:00:00
导航到 策略 > 安全策略。
修改 之前的 Trust_to_Untrust_Allow 策略:
源地址: 更改为 192.168.10.0/24 (仅员工区)
时间段: 选择 Work_Time
新建 一条策略 (服务器/访客全天可上):
名称: Server_Guest_Allow
源区域: Trust
目的区域: Untrust
源地址: (创建一个地址组包含 192.168.20.0/24 和 192.168.30.0/24)
动作: Permit
#para[
将此策略拖到 Work_Time 策略下方。
]
#figure(image("worktime.jpg",format: "jpg",fit:"stretch",width: 60%),caption: "分时访问策略配置")
== 树莓派服务器的配置
#para[树莓派在本次实验中设置静态IP地址为`192.168.20.50/24`充当Web服务器FTP服务器与邮件服务器的角色同时还提供 AP 实现无线接入功能。]
#figure(image("rpi4.jpg",format:"jpg",fit:"stretch",width: 50%),caption:"实验中的 Raspberry Pi 4B 服务器")
#pagebreak()
=== 配置 Web 服务器
#para[
我的树莓派安装了EndeavourOS系统使用Apache作为Web服务器。配置步骤如下
]
+ 安装 Apache
```bash
sudo pacman -Syu apache
```
+ 启动并设置 Apache 开机自启:
```bash
sudo systemctl start httpd
sudo systemctl enable httpd
```
+ 配置防火墙允许 HTTP 流量:
```bash
sudo ufw allow 80/tcp
```
+ 测试 Web 服务器:
在浏览器中输入树莓派的 IP 地址 `http://192.168.20.50`,能看到 Apache 的默认页面,则表示 Web 服务启动成功。
+ 设计网页:
使用 Httrack 将www.nudt.edu.cn网页镜像下载到`/var/www/html`目录下,替换默认的`index.html`文件。
#figure(image("web.jpg",format:"jpg",fit:"stretch",width: 100%),caption:"Web 服务器页面")
=== 配置 FTP 服务器
#para[
在树莓派上安装并配置vsftpd作为FTP服务器步骤如下
]
+ 安装 vsftpd
```bash
sudo pacman -Syu vsftpd
```
+ 启动并设置 vsftpd 开机自启:
```bash
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
```
+ 配置防火墙允许 FTP 流量:
```bash
sudo ufw allow 21/tcp
```
+ 配置 vsftpd
编辑配置文件 `/etc/vsftpd.conf`,确保以下参数被正确设置:
```
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
```
+ 重启 vsftpd 服务使配置生效:
```bash
sudo systemctl restart vsftpd
```
#figure(image("vftpd.jpg",format:"jpg",fit:"stretch",width: 60%),caption:"FTP 服务工作状态")
+ 测试 FTP 服务器:
使用 FTP 客户端连接到树莓派的 IP 地址 `192.168.20.50`,并使用有效的用户名和密码进行登录。
#figure(image("ftp.jpg",format:"jpg",fit:"stretch",width: 60%),caption:"FTP 登录测试")
#para[
由于树莓派已经开启了SSH服务所以可以使用SFTP协议进行文件传输更为方便。
]
#figure(image("sftp.jpg",format:"jpg",fit:"stretch",width: 60%),caption:"SFTP 传输测试")
=== 配置邮件服务器
#para[
本人拥有在公网服务器部署个人专有邮箱经验(地址为`chengjingyu@hifuu.ink` 这里的`hifuu.ink`为我个人持有域名),也曾参与学校超算俱乐部邮件服务器建设(邮件地址为`scc@nudt.cc`,网站地址为`mail.nudt.cc`这里选择在树莓派上拉取poste.io镜像进行快速部署。
]
+ 安装 Docker
```bash
sudo pacman -Syu docker
sudo systemctl start docker
sudo systemctl enable docker
```
+ 拉取 poste.io 镜像并运行容器:
```bash
sudo docker run -d \
--name mailserver \
-p 25:25 -p 8080:80 -p 443:443 -p 587:587 -p 993:993 \
-v /path/to/data:/data \
analogic/poste.io
```
+ 配置防火墙允许邮件相关端口流量:
```bash
sudo ufw allow 25/tcp
sudo ufw allow 587/tcp
sudo ufw allow 993/tcp
```
+ 访问 poste.io 的 Web 界面进行邮箱配置:
在浏览器中输入 `http://192.168.20.50`,按照提示完成域名绑定和邮箱账户创建。
+ 测试邮件服务器:
在poste.io配置创建的邮箱账户发送和接收测试邮件。
#figure(image("email.png",format:"png",fit:"stretch",width: 80%),caption:"邮件服务器登录界面")
=== 配置无线接入点 (AP)
#para[
在树莓派上配置无线接入点 (AP) 功能,使其能够为内网设备提供无线网络连接。步骤如下:
]
+ 安装 hostapd 和 dnsmasq
```bash
sudo pacman -Syu hostapd dnsmasq
```
+ 配置 hostapd
编辑 `/etc/hostapd/hostapd.conf` 文件,添加以下内容:
```
interface=wlan0
driver=nl80211
ssid=gh0s7-hotap
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=********
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
```
+ 配置 dnsmasq
编辑 `/etc/dnsmasq.conf` 文件,添加以下内容:
```
interface=wlan0
dhcp-range=192.168.20.100,192.168.20.200,255.255.255.0,24h
```
+ 启动并设置 hostapd 和 dnsmasq 开机自启:
```bash
sudo systemctl start hostapd
sudo systemctl enable hostapd
sudo systemctl start dnsmasq
sudo systemctl enable dnsmasq
```
+ 使用手机连接无线网络:
在手机上搜索并连接到 SSID `gh0s7-hotap`,输入密码后即可连接成功,连接后即可访问 Web 服务器等资源。
#figure(image("wifi.png",format:"png",fit:"stretch",width: 40%),caption:"无线接入点连接成功")
// == 实验测试
// === 测试方案
// #para[
// 检查以下项目来验证整个网络的功能:
// ]
// [应用-DHCP] 检查 PC1 和 PC3 是否成功获取到 192.168.10.x 和 192.168.30.x 网段的 IP 地址。
// [连通性]
// PC1 ping 192.168.10.254 (通,测网关)
// PC1 ping 192.168.20.50 (通,测内网服务器)
// PC1 ping 192.168.30.x (通测VLAN间路由)
// PC1 ping 8.8.8.8 (通,测外网)
// [应用-Web]
// PC1 打开浏览器,访问 http://192.168.20.50 (应看到内网Pi的网页)。
// [应用 - FTP]
// 在 PC1 上使用 FTP 客户端连接到 192.168.20.50,使用有效的用户名和密码进行登录。
// [应用 - 邮件]
// 在 PC1 上使用邮件客户端(如 Outlook配置一个邮箱账户发送和接收测试邮件。
// [可靠性-多路径]
// 在 PC1 上持续 ping 8.8.8.8 -t。
// 在 R1 (主路) 的 GigabitEthernet 0/0/1 (外网口) 上执行 shutdown。
// 观察 PC1 的 ping应在短暂中断后OSPF收敛自动恢复。流量已切换到 R2。
// 在 R1 上 undo shutdown观察流量是否切回 (取决于 OSPF 回切设置)。
// [可靠性-Eth-Trunk]
// 在 PC1 上持续 ping 192.168.10.254 -t。
// shutdown S3 与 CORE 之间的 Eth-Trunk 1 的任意一条物理链路。
// Ping 不应中断。
// [安全-分时访问]
// (在 FW1 上) 将 Work_Time 时间段改为你当前时间之外。
// 在 PC1 上尝试 ping 8.8.8.8 (应不通)。
// 在 PC3 或 Server 上 ping 8.8.8.8 (应仍可通)。
// 改回正确时间PC1 恢复访问。
// [安全-端口安全/DHCP]
// (高级测试) 在 S3 的 PC1 端口上拔下 PC1接入另一台电脑应无法通信。
// (高级测试) 在 S3 的空闲端口接入一台 PC 并尝试运行 DHCP 服务器软件PC1 和 PC3 应不受影响。
// [安全-VLAN隔离]
// 从 PC1 ping PC3应不通。
// 从 PC3 ping Server应通。
// === 测试结果
// #para[
// 经过全面测试,网络的各项功能均正常运行,具体测试结果如下:
// ]
// + DHCP 功能PC1 和 PC3 成功获取到正确的 IP 地址DHCP 功能正常。
// + 连通性测试PC1 能够成功 ping 通网关、内网服务器、其他 VLAN 以及外网地址
// + Web 访问PC1 能够成功访问树莓派上的 Web 服务器,显示正确的网页内容。
// + FTP 访问PC1 能够成功通过 FTP 客户端连接到树莓派的 FTP 服务器,并进行文件传输。
// + 邮件服务PC1 能够成功配置邮箱账户,发送和接收测试邮件均正常。
// + 多路径冗余:在 R1 的外网口关闭后PC1 的 ping 在短暂中断后自动恢复,流量成功切换到 R2。
// + Eth-Trunk 冗余:关闭 S3 与 CORE 之间 Eth-Trunk 的一条物理链路后PC1 的 ping 未中断,链路冗余功能正常。
// + 分时访问策略在非工作时间内PC1 无法访问外网,而 PC3 和 Server 仍然可以访问,分时访问策略生效。
// + 端口安全与 DHCP在 S3 上更换 PC1 后,新的电脑无法通信,端口安全功能正常。运行 DHCP 服务器软件的测试也未影响 PC1 和 PC3 的网络连接。
// + VLAN 隔离PC1 无法 ping 通 PC3而 PC3 能够成功 ping 通 ServerVLAN 隔离功能正常。
// #para[
// 总体而言,网络设计和配置达到了预期目标,确保了网络的高效性、安全性和稳定性。所有测试均通过,网络系统运行良好。
// ]
== 实验测试
=== 测试方案
#para[
检查以下项目来验证整个网络的功能:
]
#align(center)[#table(
columns: (auto, 1fr),
inset: 10pt,
table.header(
[测试项目], [操作与期望]
),
[应用-DHCP], [PC1 与 PC3 应分别自动获取 192.168.10.x 与 192.168.30.x 网段地址,验证 DHCP 地址池与绑定策略。],
[连通性], [PC1 依次 ping 192.168.10.254、192.168.20.50、192.168.30.x 以及 8.8.8.8,确认网关、内网服务器、跨 VLAN 路由与外网连通均正常。],
[应用-Web], [PC1 访问 http://192.168.20.50,页面需正确展示树莓派 Web 服务内容。],
[应用-FTP], [PC1 使用 FTP 客户端连接 192.168.20.50,凭有效账号完成登录与文件传输。],
[应用-邮件], [在 PC1 上配置邮件客户端,完成测试邮件的发送与接收,验证 SMTP/IMAP 正常。],
[可靠性-多路径], [PC1 持续 ping 8.8.8.8,手动 shutdown R1 外网口后应仅短暂中断并自动切换至 R2undo shutdown 后可按 OSPF 策略回切。],
[可靠性-Eth-Trunk], [PC1 持续 ping 192.168.10.254,断开 S3 与 CORE 的 Eth-Trunk1 任意链路时业务不中断,证明链路聚合冗余有效。],
[安全-分时访问], [在 FW1 修改 Work_Time 至当前时间之外后PC1 ping 8.8.8.8 应被阻断,而 PC3 与 Server 仍可外联,恢复时间策略后 PC1 恢复访问。],
[安全-端口安全/DHCP], [在 S3 上调换 PC1 端口或新增私设 DHCP 服务器,应无法接入网络且不会影响既有终端地址获取。],
[安全-VLAN隔离], [PC1 ping PC3 应被隔离,而 PC3 ping Server 需可达,以验证 VLAN 与 ACL 策略。]
)]
=== 测试结果
#para[
经过全面测试,网络的各项功能均正常运行,具体测试结果如下:
]
#align(center)[#table(
columns: (auto, 1fr),
inset: 10pt,
table.header(
[测试项目], [结果结论]
),
[DHCP 功能], [PC1 与 PC3 均成功获取对应网段地址,地址池与绑定策略正常。],
[连通性], [PC1 可稳定访问网关、内网服务器、跨 VLAN 终端及外网公共地址,整体连通性良好。],
[Web 访问], [PC1 可正常打开树莓派 Web 服务并显示完整页面。],
[FTP 访问], [PC1 成功建立 FTP 会话并完成文件传输,认证与数据通道均正常。],
[邮件服务], [客户端成功配置并完成收发测试邮件SMTP/IMAP 服务表现稳定。],
[多路径冗余], [R1 外网口故障时仅出现瞬时抖动,随后自动切换至 R2恢复后可根据 OSPF 策略回切。],
[Eth-Trunk 冗余], [断开 Eth-Trunk1 单链路时 PC1 ping 无丢包,聚合链路保障生效。],
[分时访问策略], [非工作时段阻断 PC1 的外网访问PC3 与 Server 不受限,策略符合预期。],
[端口安全与 DHCP], [冒用终端无法接入,私设 DHCP 也未造成地址冲突,安全策略有效。],
[VLAN 隔离], [PC1 ping PC3 被隔离PC3 可访问 Server隔离策略与允许路径均正确。]
)]
#para[
总体而言,网络设计和配置达到了预期目标,确保了网络的高效性、安全性和稳定性。所有测试均通过,网络系统运行良好。
]
= 实验总结
== 内容总结
#para[
本次实验的主要目标是设计和实现一个综合性强的中小型网络涵盖了从网络规划、方案设计、硬件安装与配置、软件安装与配置、系统测试与联调、工程验收等完整的组网工程流程。实验通过模拟某学校的校园网络建设需求详细展示了如何通过多种先进技术如链路聚合、堆叠技术、VLAN、OSPF等来构建一个高效、安全、稳定的网络环境。实验首先进行了详细的需求分析明确了网络覆盖、性能、安全、管理、扩展、服务器和存储、终端设备等方面的需求。随后实验采用了多种网络技术来满足需求包括BFD协议确保出口网关的健壮性链路聚合技术Eth-trunk提升网络带宽和链路可靠性堆叠技术用于核心交换机的冗余和扩展VLAN技术用于划分不同部门的安全区域等等。
]
#para[
实验通过多个阶段的验证确保网络的各项功能正常运行。包括内网主机之间的通信、内网主机访问Web服务器、外网主机访问内网服务器、防火墙安全策略的验证、出口网关的双机热备验证等。
]
== 困难挑战
#para[
首先是笔者由于是唯一一个单人实验小组,需要独自完成从需求分析到最终测试的所有环节,工作量较大且任务繁重。其次,在配置过程中遇到了多种技术挑战,例如核心交换机的堆叠配置、路由配置等,这些都需要深入理解设备的工作原理和配置命令。此外,实验中还需要处理各种突发问题,如设备间的兼容性问题、配置错误导致的网络故障等,这些都考验了笔者的问题解决能力和应变能力。
]
#para[
在解决问题的过程中我尤其要感谢教辅学长张军老师与Deepseek的悉心指导与帮助。他们不仅在技术上给予了我宝贵的建议还在思路上启发了我让我能够更好地理解网络设计与配置的核心理念。通过这次实验我不仅提升了自己的技术能力也增强了独立解决问题的信心和能力。
]
== 心得感悟
#para[
本次实验自由度较大时间跨度长我选择了比较有综合性的设计方案同时也需要个人独立完成因此实现难度较大。在配置的过程中遇到了很多困难但也让我对网络设备的运行机制有了更深的理解。从需求分析到方案设计再到设备配置和测试验收每一个环节都需要严谨的态度和细致的操作。实验中的每一步配置都充满了挑战尤其是在核心交换机的堆叠配置、各设备之间的OSPF配置防火墙的NAT的配置等方面我遇到了不少困难但也因此积累了宝贵的实践经验。
]
#show heading: it => box(width: 100%)[
#v(0.50em)
#set text(font: hei)
// #counter(heading).display()
// #h(0.5em)
#it.body
]
#pagebreak()
#bibliography("ref.yml",full: true,title: "参考文献",style:"gb-7714-2015-numeric")
/*
根据这个网站的格式示范https://github.com/typst/hayagriva/blob/main/docs/file-format.md
为这个网页生成.yml文件
https://blog.csdn.net/jxjdhdnd/article/details/138009187
*/