我的学号后三位是235,姓名拼音是wyw,按照这个实验文档给出了我的实验拓扑图和具体的实验步骤

Created on: April 27, 2026

Answered using GPT-5.5 Thinking by Chat01

Question

实验8 交换实验手册.docx

我的学号后三位是235,姓名拼音是wyw,按照这个实验文档给出了我的实验拓扑图和具体的实验步骤

Thought

Configuring STP priorities for VLANs

For VLANs 135 and 235, I need to set STP root and secondary priorities. SW1 will have a priority base of 24576 for these VLANs, while SW2 will use 28672. Each switch’s Bridge ID combines base priority with the VLAN ID. For example, for VLAN 135, SW1’s Bridge ID will be 24711.

Thought for 1m 15s

Answer

下面是按你上传的《实验8 交换实验手册》定制后的版本:学号后三位 235,所以学号后两位为 35;姓名拼音为 wyw。文档中要求“IP 第 2 字节改为学号后 2 位、VLAN 后两位改为学号后 2 位、VTP 域名改为姓名、密码改为姓名+学号后三位”等,我已统一替换。(实验8 交换实验手册.docx)

一、你的实验参数

项目你的值
学号后三位235
学号后两位35
姓名拼音wyw
VTP domainwyw
VTP passwordwyw235
EtherChannel 编号35
OSPF 进程号35
ACL 编号35

二、VLAN 与地址规划

文档中的 VLAN 100、200、300、400 按“后两位改为 35”处理:

原 VLAN你的 VLAN网段网关/HSRP 虚拟 IP
VLAN100VLAN135172.35.4.0/24172.35.4.254
VLAN200VLAN235172.35.5.0/24172.35.5.254
VLAN300VLAN335172.35.6.0/24172.35.6.254
VLAN400VLAN435172.35.7.0/24172.35.7.254

三、实验拓扑图

可按下面关系在 Packet Tracer 中连线:

mermaid
flowchart TB Server1["Server1\nVLAN135\n172.35.4.1/24\nGW 172.35.4.254"] -->|F0/3| SW3 PC1["PC1\nVLAN235\n172.35.5.1/24\nGW 172.35.5.254"] -->|F0/4| SW3 PC2["PC2\nVLAN335\n172.35.6.1/24\nGW 172.35.6.254"] -->|F0/5| SW3 PC3["PC3\nVLAN235\n172.35.5.2/24\nGW 172.35.5.254"] -->|F0/3| SW4 PC4["PC4\nVLAN335\n172.35.6.2/24\nGW 172.35.6.254"] -->|F0/4| SW4 PC5["PC5\nVLAN435\n172.35.7.1/24\nGW 172.35.7.254"] -->|F0/5| SW4 SW3 <-->|Trunk F0/1| SW1 SW3 <-->|Trunk F0/2| SW2 SW4 <-->|Trunk F0/1| SW1 SW4 <-->|Trunk F0/2| SW2 SW1 <-->|EtherChannel 35\nF0/3-F0/4| SW2 SW1 -->|G0/1\n172.35.1.2/24| R1["R1\nF0/0 172.35.1.1/24\nF0/1 172.35.2.1/24\nS1/0 222.21.133.1/24"] SW2 -->|G0/1\n172.35.2.2/24| R1 R1 <-->|Serial\n222.21.133.0/24| R2["R2\nS1/0 222.21.133.2/24\nF0/0 222.21.132.254/24"] R2 --> Server2["Server2\n222.21.132.1/24\nGW 222.21.132.254"]

说明:Packet Tracer 中接口名可能显示为 S0/0/0S0/0/1,如果不是 S1/0,按你设备实际接口名替换即可。


四、具体实验步骤与配置命令

1. 终端 IP 地址配置

设备VLANIP 地址子网掩码网关接入交换机接口
Server1135172.35.4.1255.255.255.0172.35.4.254SW3 F0/3
PC1235172.35.5.1255.255.255.0172.35.5.254SW3 F0/4
PC2335172.35.6.1255.255.255.0172.35.6.254SW3 F0/5
PC3235172.35.5.2255.255.255.0172.35.5.254SW4 F0/3
PC4335172.35.6.2255.255.255.0172.35.6.254SW4 F0/4
PC5435172.35.7.1255.255.255.0172.35.7.254SW4 F0/5
Server2-222.21.132.1255.255.255.0222.21.132.254R2 F0/0

2. R1 基础接口配置

bash
enable configure terminal hostname R1 interface f0/0 ip address 172.35.1.1 255.255.255.0 no shutdown exit interface f0/1 ip address 172.35.2.1 255.255.255.0 no shutdown exit interface s1/0 ip address 222.21.133.1 255.255.255.0 clock rate 64000 no shutdown exit

如果你的串口不是 DCE 端,clock rate 64000 可以不配。


3. R2 基础接口配置

bash
enable configure terminal hostname R2 interface s1/0 ip address 222.21.133.2 255.255.255.0 no shutdown exit interface f0/0 ip address 222.21.132.254 255.255.255.0 no shutdown exit

4. SW1 三层接口与基础配置

bash
enable configure terminal hostname SW1 ip routing interface g0/1 no switchport ip address 172.35.1.2 255.255.255.0 no shutdown exit

5. SW2 三层接口与基础配置

bash
enable configure terminal hostname SW2 ip routing interface g0/1 no switchport ip address 172.35.2.2 255.255.255.0 no shutdown exit

6. SW1 与 SW2 配置 EtherChannel 35

SW1

bash
configure terminal interface range f0/3 - 4 channel-protocol pagp channel-group 35 mode desirable no shutdown exit interface port-channel 35 switchport trunk encapsulation dot1q switchport mode trunk no shutdown exit port-channel load-balance dst-ip

SW2

bash
configure terminal interface range f0/3 - 4 channel-protocol pagp channel-group 35 mode desirable no shutdown exit interface port-channel 35 switchport trunk encapsulation dot1q switchport mode trunk no shutdown exit port-channel load-balance dst-ip

若交换机提示不支持 switchport trunk encapsulation dot1q,直接跳过该命令,继续配置 switchport mode trunk


7. 配置 VTP

SW1:VTP Server

bash
configure terminal vtp mode server vtp domain wyw vtp version 2 vtp password wyw235

SW2:VTP Server / 备份服务器

bash
configure terminal vtp mode server vtp domain wyw vtp version 2 vtp password wyw235

SW3:VTP Client

bash
enable configure terminal hostname SW3 vtp mode client vtp domain wyw vtp version 2 vtp password wyw235

SW4:VTP Client

bash
enable configure terminal hostname SW4 vtp mode client vtp domain wyw vtp version 2 vtp password wyw235

8. 在 SW1、SW2 创建 VLAN

SW1

bash
configure terminal vlan 135 name VLAN135_Server exit vlan 235 name VLAN235_PC exit vlan 335 name VLAN335_PC exit vlan 435 name VLAN435_PC exit

SW2

bash
configure terminal vlan 135 name VLAN135_Server exit vlan 235 name VLAN235_PC exit vlan 335 name VLAN335_PC exit vlan 435 name VLAN435_PC exit

在 SW3、SW4 上检查是否通过 VTP 学到 VLAN:

bash
show vlan brief

9. SW1、SW2、SW3、SW4 上联口配置 Trunk

SW1

bash
configure terminal interface range f0/1 - 2 switchport trunk encapsulation dot1q switchport mode trunk no shutdown exit

SW2

bash
configure terminal interface range f0/1 - 2 switchport trunk encapsulation dot1q switchport mode trunk no shutdown exit

SW3

bash
configure terminal interface range f0/1 - 2 switchport mode trunk no shutdown exit

SW4

bash
configure terminal interface range f0/1 - 2 switchport mode trunk no shutdown exit

10. SW3 接入端口配置

bash
configure terminal interface f0/3 switchport mode access switchport access vlan 135 no shutdown exit interface f0/4 switchport mode access switchport access vlan 235 no shutdown exit interface f0/5 switchport mode access switchport access vlan 335 no shutdown exit

11. SW4 接入端口配置

bash
configure terminal interface f0/3 switchport mode access switchport access vlan 235 no shutdown exit interface f0/4 switchport mode access switchport access vlan 335 no shutdown exit interface f0/5 switchport mode access switchport access vlan 435 no shutdown exit

五、HSRP 配置

12. SW1 配置 HSRP

SW1 作为 VLAN135、VLAN235 的 Active,VLAN335、VLAN435 的 Standby。

bash
configure terminal interface vlan 135 ip address 172.35.4.250 255.255.255.0 standby 10 ip 172.35.4.254 standby 10 priority 115 standby 10 preempt standby 10 track g0/1 no shutdown exit interface vlan 235 ip address 172.35.5.250 255.255.255.0 standby 20 ip 172.35.5.254 standby 20 priority 115 standby 20 preempt standby 20 track g0/1 no shutdown exit interface vlan 335 ip address 172.35.6.250 255.255.255.0 standby version 2 standby 30 ip 172.35.6.254 standby 30 priority 110 standby 30 preempt standby 30 track g0/1 no shutdown exit interface vlan 435 ip address 172.35.7.250 255.255.255.0 standby version 2 standby 40 ip 172.35.7.254 standby 40 priority 110 standby 40 preempt standby 40 track g0/1 no shutdown exit

13. SW2 配置 HSRP

SW2 作为 VLAN335、VLAN435 的 Active,VLAN135、VLAN235 的 Standby。

bash
configure terminal interface vlan 135 ip address 172.35.4.251 255.255.255.0 standby 10 ip 172.35.4.254 standby 10 priority 110 standby 10 preempt standby 10 track g0/1 no shutdown exit interface vlan 235 ip address 172.35.5.251 255.255.255.0 standby 20 ip 172.35.5.254 standby 20 priority 110 standby 20 preempt standby 20 track g0/1 no shutdown exit interface vlan 335 ip address 172.35.6.251 255.255.255.0 standby version 2 standby 30 ip 172.35.6.254 standby 30 priority 115 standby 30 preempt standby 30 track g0/1 no shutdown exit interface vlan 435 ip address 172.35.7.251 255.255.255.0 standby version 2 standby 40 ip 172.35.7.254 standby 40 priority 115 standby 40 preempt standby 40 track g0/1 no shutdown exit

检查命令:

bash
show standby brief

六、PVST 生成树配置

14. SW1 配置

bash
configure terminal spanning-tree mode pvst spanning-tree vlan 135,235 root primary spanning-tree vlan 335,435 root secondary

15. SW2 配置

bash
configure terminal spanning-tree mode pvst spanning-tree vlan 135,235 root secondary spanning-tree vlan 335,435 root primary

检查命令:

bash
show spanning-tree vlan 135 show spanning-tree vlan 235 show spanning-tree vlan 335 show spanning-tree vlan 435

预期结果:

VLAN根交换机备份根
VLAN135SW1SW2
VLAN235SW1SW2
VLAN335SW2SW1
VLAN435SW2SW1

七、OSPF 配置

16. SW1 配置 OSPF

bash
configure terminal router ospf 35 network 172.35.1.0 0.0.0.255 area 0 network 172.35.4.0 0.0.0.255 area 0 network 172.35.5.0 0.0.0.255 area 0 network 172.35.6.0 0.0.0.255 area 0 network 172.35.7.0 0.0.0.255 area 0 exit

17. SW2 配置 OSPF

bash
configure terminal router ospf 35 network 172.35.2.0 0.0.0.255 area 0 network 172.35.4.0 0.0.0.255 area 0 network 172.35.5.0 0.0.0.255 area 0 network 172.35.6.0 0.0.0.255 area 0 network 172.35.7.0 0.0.0.255 area 0 exit

18. R1 配置 OSPF

bash
configure terminal router ospf 35 network 172.35.1.0 0.0.0.255 area 0 network 172.35.2.0 0.0.0.255 area 0 exit

检查命令:

bash
show ip ospf neighbor show ip route ospf

八、默认路由与默认路由下发

19. R1 配置默认路由

bash
configure terminal ip route 0.0.0.0 0.0.0.0 222.21.133.2

20. R1 将默认路由注入 OSPF

bash
router ospf 35 default-information originate exit

在 SW1、SW2 上检查:

bash
show ip route

应能看到类似:

bash
O*E2 0.0.0.0/0 via 172.35.1.1

或:

bash
O*E2 0.0.0.0/0 via 172.35.2.1

九、R1 动态 NAT 配置

21. 配置动态 NAT,使内网访问 Server2

bash
configure terminal access-list 35 permit 172.35.0.0 0.0.255.255 ip nat pool xcu 222.21.133.10 222.21.133.20 netmask 255.255.255.0 interface f0/0 ip nat inside exit interface f0/1 ip nat inside exit interface s1/0 ip nat outside exit ip nat inside source list 35 pool xcu overload

测试:

bash
PC1> ping 222.21.132.1

如果配置正确,PC1 应能 ping 通 Server2。

查看 NAT 转换:

bash
show ip nat translations

十、静态 NAT 发布 Server1

22. R1 配置静态 NAT

bash
configure terminal ip nat inside source static 172.35.4.1 222.21.133.21

公网用户 Server2 访问 Server1 时,应访问:

text
222.21.133.21

原因:Server1 的真实地址 172.35.4.1 是内网私有地址,公网不能直接访问;R1 通过静态 NAT 把它映射为公网侧地址 222.21.133.21

测试:

bash
Server2> ping 222.21.133.21

十一、SW3 F0/4 端口安全配置

PC1 连接在 SW3 的 F0/4,配置端口安全如下:

bash
configure terminal interface f0/4 switchport mode access switchport access vlan 235 switchport port-security switchport port-security maximum 1 switchport port-security mac-address sticky switchport port-security violation shutdown exit

查看配置:

bash
show running-config

查看端口安全状态:

bash
show port-security interface f0/4

修改 PC1 MAC 地址后再次 ping PC4,预期结果是:

text
ping 不通,SW3 的 F0/4 会进入 err-disabled / shutdown 状态。

恢复方法:

bash
configure terminal interface f0/4 shutdown no shutdown exit

必要时还需要清除旧的 sticky MAC:

bash
clear port-security sticky interface f0/4

十二、实验问题参考答案

问题1:以太通道协议有哪些?模式有什么不同?

主要有三类:

类型模式说明
PAgPdesirable / autoCisco 私有协议;desirable 主动协商,auto 被动等待
LACPactive / passiveIEEE 标准协议;active 主动协商,passive 被动等待
Onon强制形成 EtherChannel,不进行协商

常见组合:

组合是否能形成 EtherChannel
desirable + desirable可以
desirable + auto可以
auto + auto不可以
active + active可以
active + passive可以
passive + passive不可以
on + on可以,但无协商,要求两端配置完全一致

问题2:负载平衡方式有哪些?

常见方式有:

text
src-mac dst-mac src-dst-mac src-ip dst-ip src-dst-ip src-port dst-port src-dst-port

如果按源进行负载均衡,通常使用:

bash
port-channel load-balance src-ip

如果按目的进行负载均衡,通常使用:

bash
port-channel load-balance dst-ip

本实验文档给出的方式是:

bash
port-channel load-balance dst-ip

问题3:只配置 VLAN 和 Trunk 后,PC1 ping PC3、PC4、PC5 连通性如何?

PC1 属于 VLAN235。

测试结果原因
PC1 ping PC3同属 VLAN235
PC1 ping PC4不通PC4 属于 VLAN335,尚未配置三层网关/HSRP
PC1 ping PC5不通PC5 属于 VLAN435,尚未配置三层网关/HSRP

问题4:配置 HSRP 后,PC1 ping PC3、PC4、PC5 连通性如何?

测试结果
PC1 ping PC3
PC1 ping PC4
PC1 ping PC5

原因:SW1、SW2 已经通过 SVI 和 HSRP 实现 VLAN 间三层转发。

问题5:PVST 配置后哪个是根?

VLAN根桥备份根说明
VLAN135SW1SW2SW1 root primary
VLAN235SW1SW2SW1 root primary
VLAN335SW2SW1SW2 root primary
VLAN435SW2SW1SW2 root primary

通常 root primary 会把优先级设置为 24576root secondary 会设置为 28672,普通交换机默认优先级为 32768。实际显示时,Cisco 可能会把 VLAN ID 加入 Bridge ID,例如 VLAN135 上 SW1 可能显示为 24576 + 135 = 24711

问题6:PC1 ping PC4 时数据经过哪些交换机?

PC1 在 VLAN235,PC4 在 VLAN335。

推荐观察路径:

text
PC1 → SW3 → SW1 → SW2 → SW4 → PC4

原因:

  • VLAN235 的根桥是 SW1;
  • PC1 的网关 VLAN235 Active 在 SW1;
  • PC4 属于 VLAN335,而 VLAN335 的根桥是 SW2;
  • 因此跨 VLAN 转发后,数据可能经过 SW1 到 SW2,再到 SW4。

问题7:Server1 ping PC3 时数据经过哪些交换机?

Server1 在 VLAN135,PC3 在 VLAN235。

推荐观察路径:

text
Server1 → SW3 → SW1 → SW4 → PC3

原因:

  • VLAN135 和 VLAN235 的根桥都是 SW1;
  • 这两个 VLAN 的 HSRP Active 也主要在 SW1;
  • 所以流量通常经 SW3 上行到 SW1,再从 SW1 转发到 SW4。

问题8:PC1 ping Server2 是否能通?

配置 OSPF、默认路由和动态 NAT 后,PC1 ping Server2:

text
应能 ping 通。

若不通,重点检查:

bash
show ip route show ip ospf neighbor show ip nat translations show access-lists show ip interface brief

问题9:Server2 访问 Server1 应访问哪个地址?

应访问:

text
222.21.133.21

原因:Server1 的内网地址是 172.35.4.1,通过 R1 静态 NAT 映射为公网地址 222.21.133.21

问题10:启用端口安全后,F0/4 配置有什么变化?

使用:

bash
show running-config

可以看到 F0/4 下多出类似配置:

bash
switchport port-security switchport port-security maximum 1 switchport port-security mac-address sticky switchport port-security mac-address sticky xxxx.xxxx.xxxx switchport port-security violation shutdown

其中 xxxx.xxxx.xxxx 是 PC1 自动学习到的 MAC 地址。

问题11:修改 PC1 的 MAC 地址后有什么变化?

修改 PC1 MAC 地址后再 ping PC4:

text
ping 不通。

SW3 的 F0/4 会因为安全违规进入:

text
err-disabled / secure-shutdown

查看命令:

bash
show port-security interface f0/4 show interface f0/4 status

恢复接口:

bash
configure terminal interface f0/4 shutdown no shutdown exit

Share this Q&A