HCIP中期考试考题与eNSP配置
实验背景
本次实验为企业园区网络综合配置,结合前期课程学习的 VLAN、链路聚合、STP、VRRP、OSPF、单臂路由等技术,完成企业网络的部署,实现全网连通与冗余可靠性,覆盖中期考试前的全部核心知识点。
拓扑与 IP 规划
已提供的 IP 地址规划如下,拓扑为核心路由器全互联 + 分层汇聚的园区网络结构:
|---------|-----------------------------------------------------------------------|----------------------------------|-----------------------------------------------------------------------------------------------------------|
| 设备 | 网段 | 网关 | 备注 |
| PC1 | 192.168.1.0/24(192.168.1.0/24) | 192.168.1.254(192.168.1.254) | IP : 192.168.1.1(192.168.1.1) |
| PC2 | 192.168.1.0/24(192.168.1.0/24) | 192.168.1.254(192.168.1.254) | IP : 192.168.1.2(192.168.1.2) |
| PC3 | 192.168.2.0/24(192.168.2.0/24) | 192.168.2.254(192.168.2.254) | IP : 192.168.2.1(192.168.2.1) |
| PC4 | 192.168.2.0/24(192.168.2.0/24) | 192.168.2.254(192.168.2.254) | IP : 192.168.2.2(192.168.2.2) |
| PC5 | 192.168.3.0/24(192.168.3.0/24) | 192.168.3.254(192.168.3.254) | IP : 192.168.3.1/vlan10(192.168.3.1/vlan10) |
| PC6 | 192.168.4.0/24(192.168.4.0/24) | 192.168.4.254(192.168.4.254) | IP : 192.168.4.1/vlan20(192.168.4.1/vlan20) |
| R3-R4 | 192.168.100.0/30(192.168.100.0/30) | - | R3:192.168.100.1/30(192.168.100.1/30) ; R4:192.168.100.2/30(192.168.100.2/30) |
| R3-R2 | 192.168.100.4/30(192.168.100.4/30) | - | R2:192.168.100.5/30(192.168.100.5/30) ; R3:192.168.100.6/30(192.168.100.6/30) |
| R3-R1 | 192.168.100.8/30(192.168.100.8/30) | - | R1:192.168.100.9/30(192.168.100.9/30) ; R3:192.168.100.10/30(192.168.100.10/30) |
| R2-R4 | 192.168.100.12/30(192.168.100.12/30) | - | R2:192.168.100.13/30(192.168.100.13/30) ; R4:192.168.100.14/30(192.168.100.14/30) |
| R1-R4 | 192.168.100.16/30(192.168.100.16/30) | - | R1:192.168.100.17/30(192.168.100.17/30) ; R4:192.168.100.18/30(192.168.100.18/30) |
| R1-R2 | 192.168.100.20/30(192.168.100.20/30) | - | R1:192.168.100.21/30(192.168.100.21/30) ; R2:192.168.100.22/30(192.168.100.22/30) |
| R1-R5 | 10.10.10.0/30(10.10.10.0/30) | - | R1:10.10.10.1/30(10.10.10.1/30) ; R5:10.10.10.2/30(10.10.10.2/30) |
| R1-R6 | 10.10.10.4/30(10.10.10.4/30) | - | R1:10.10.10.5/30(10.10.10.5/30) ; R6:10.10.10.6/30(10.10.10.6/30) |
| R2-R5 | 10.10.10.8/30(10.10.10.8/30) | - | R2:10.10.10.9/30;(10.10.10.9/30;) R5:10.10.10.10/30(10.10.10.10/30) |
| R2-R6 | 10.10.10.12/30(10.10.10.12/30) | - | R2:10.10.10.13/30;(10.10.10.13/30;) R6:10.10.10.14/30(10.10.10.14/30) |
| R5-R6 | 10.10.10.16/30(10.10.10.16/30) | - | R5:10.10.10.17/30;(10.10.10.17/30;) R6:10.10.10.18/30(10.10.10.18/30) |
| R5-R7 | 10.10.10.20/30(10.10.10.20/30) | - | R5:10.10.10.21/30;(10.10.10.21/30;) R7:10.10.10.22/30(10.10.10.22/30) |
| R6-R7 | 10.10.10.24/30(10.10.10.24/30) | - | R6:10.10.10.25/30;(10.10.10.25/30;) R7:10.10.10.26/30(10.10.10.26/30) |
| R7-R8 | 10.10.10.28/30(10.10.10.28/30) | - | R7:10.10.10.29/30;(10.10.10.29/30;) R8:10.10.10.30/30(10.10.10.30/30) |
| R8-R9 | 10.10.10.32/30(10.10.10.32/30) | - | R7:10.10.10.33/30;(10.10.10.33/30;) R8:10.10.10.34/30(10.10.10.34/30) |
| R9-R10 | 192.168.200.0/30(192.168.200.0/30) | - | R9:192.168.200.2(192.168.200.2) ; R10 : 192.168.200.1(192.168.200.1) |
| R10 子接口 | 192.168.3.0/24(192.168.3.0/24)、192.168.4.0/24(192.168.4.0/24) | - | GE0/0/1.1 (vlan10):192.168.3.254(192.168.3.254) ; GE0/0/1.2 (vlan20):192.168.4.254(192.168.4.254) |
实验要求
-
终端配置:所有 PC 按照规划配置 IP 地址、子网掩码和网关。
-
VLAN 与 Trunk 配置:
-
将 PC1、PC2 划分至 VLAN 10,PC3、PC4 划分至 VLAN 20;
-
将 PC5 划分至 VLAN 10,PC6 划分至 VLAN 20;
-
接入交换机与核心路由器、R10 相连的接口配置为 Trunk 类型,允许所有 VLAN 通过。
-
-
链路聚合配置:
- 接入交换机 SW1 与 R3、R4 相连的两条链路配置为静态链路聚合,实现链路负载分担与冗余。
-
STP 配置:
- 配置 STP 防止二层环路,指定 R3 为根桥,避免网络环路问题。
-
VRRP 配置:
-
在 R3 和 R4 上配置 VRRP 实现网关冗余:
-
VLAN10 的虚拟网关为 192.168.1.254(192.168.1.254),R3 为主网关(优先级 120),R4 为备份网关;
-
VLAN20 的虚拟网关为 192.168.2.254(192.168.2.254),R4 为主网关(优先级 120),R3 为备份网关;
-
实现网关的负载分担与故障自动切换。
-
-
-
单臂路由配置:
- 在 R10 上配置子接口,实现右侧 VLAN 间的路由,子接口 IP 按照规划配置。
-
OSPF 配置:
-
所有路由器运行 OSPF 协议,进程号为 1,所有接口属于区域 0;
-
将所有直连网段宣告进 OSPF,保证全网路由可达。
-
-
验证要求:
-
所有 PC 之间可以互相 ping 通,验证全网连通性;
-
断开 R3 设备,验证 VLAN10 的业务可以自动切换到 R4,业务不中断;
-
断开 R4 设备,验证 VLAN20 的业务可以自动切换到 R3,业务不中断。
-
华为 eNSP 配置代码
以下为各设备的完整配置命令,可直接在 eNSP 中导入或手动执行:
1. 左侧接入交换机 SW1
system-view sysname SW1 # 创建所需VLAN vlan batch 10 20 # 配置连接PC的Access接口 interface GigabitEthernet0/0/1 port link-type access port default vlan 10 # interface GigabitEthernet0/0/2 port link-type access port default vlan 10 # interface GigabitEthernet0/0/3 port link-type access port default vlan 20 # interface GigabitEthernet0/0/4 port link-type access port default vlan 20 # 配置静态链路聚合 interface Eth-Trunk 1 port link-type trunk port trunk allow-pass vlan all mode manual load-balance # interface GigabitEthernet0/0/5 eth-trunk 1 # interface GigabitEthernet0/0/6 eth-trunk 1 # STP配置,设置为备份根桥 stp root secondary quit
2. 右侧接入交换机 SW2
system-view sysname SW2 vlan batch 10 20 # 连接PC的Access接口 interface GigabitEthernet0/0/1 port link-type access port default vlan 10 # interface GigabitEthernet0/0/2 port link-type access port default vlan 20 # 连接R10的Trunk接口 interface GigabitEthernet0/0/3 port link-type trunk port trunk allow-pass vlan all quit
3. 核心路由器 R3
system-view sysname R3 # 开启STP,设置为根桥 stp enable stp root primary # 配置链路聚合接口 interface Eth-Trunk 1 port link-type trunk port trunk allow-pass vlan all mode manual load-balance # interface GigabitEthernet0/0/1 eth-trunk 1 # interface GigabitEthernet0/0/2 eth-trunk 1 # 配置VLANIF接口与VRRP interface Vlanif10 ip address 192.168.1.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.1.254 vrrp vrid 1 priority 120 # interface Vlanif20 ip address 192.168.2.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.2.254 # 核心互联接口IP配置 interface GigabitEthernet0/0/3 ip address 192.168.100.1 255.255.255.252 # 连接R4 # interface GigabitEthernet0/0/4 ip address 192.168.100.6 255.255.255.252 # 连接R2 # interface GigabitEthernet0/0/5 ip address 192.168.100.10 255.255.255.252 # 连接R1 # OSPF配置 ospf 1 router-id 3.3.3.3 area 0 network 192.168.1.0 0.0.0.255 network 192.168.2.0 0.0.0.255 network 192.168.100.0 0.0.0.255 quit
4. 核心路由器 R4
system-view sysname R4 stp enable # 链路聚合配置 interface Eth-Trunk 1 port link-type trunk port trunk allow-pass vlan all mode manual load-balance # interface GigabitEthernet0/0/1 eth-trunk 1 # interface GigabitEthernet0/0/2 eth-trunk 1 # VLANIF与VRRP配置 interface Vlanif10 ip address 192.168.1.254 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.1.254 # interface Vlanif20 ip address 192.168.2.254 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.2.254 vrrp vrid 2 priority 120 # 核心互联接口 interface GigabitEthernet0/0/3 ip address 192.168.100.2 255.255.255.252 # 连接R3 # interface GigabitEthernet0/0/4 ip address 192.168.100.14 255.255.255.252 # 连接R2 # interface GigabitEthernet0/0/5 ip address 192.168.100.18 255.255.255.252 # 连接R1 # OSPF配置 ospf 1 router-id 4.4.4.4 area 0 network 192.168.1.0 0.0.0.255 network 192.168.2.0 0.0.0.255 network 192.168.100.0 0.0.0.255 quit
5. 核心路由器 R1
system-view sysname R1 # 核心互联接口 interface GigabitEthernet0/0/1 ip address 192.168.100.9 255.255.255.252 # 连接R3 # interface GigabitEthernet0/0/2 ip address 192.168.100.17 255.255.255.252 # 连接R4 # interface GigabitEthernet0/0/3 ip address 192.168.100.21 255.255.255.252 # 连接R2 # 汇聚侧互联接口 interface GigabitEthernet0/0/4 ip address 10.10.10.1 255.255.255.252 # 连接R5 # interface GigabitEthernet0/0/5 ip address 10.10.10.5 255.255.255.252 # 连接R6 # OSPF配置 ospf 1 router-id 1.1.1.1 area 0 network 192.168.100.0 0.0.0.255 network 10.10.10.0 0.0.0.255 quit
6. 核心路由器 R2
system-view sysname R2 # 核心互联接口 interface GigabitEthernet0/0/1 ip address 192.168.100.5 255.255.255.252 # 连接R3 # interface GigabitEthernet0/0/2 ip address 192.168.100.13 255.255.255.252 # 连接R4 # interface GigabitEthernet0/0/3 ip address 192.168.100.22 255.255.255.252 # 连接R1 # 汇聚侧互联接口 interface GigabitEthernet0/0/4 ip address 10.10.10.9 255.255.255.252 # 连接R5 # interface GigabitEthernet0/0/5 ip address 10.10.10.13 255.255.255.252 # 连接R6 # OSPF配置 ospf 1 router-id 2.2.2.2 area 0 network 192.168.100.0 0.0.0.255 network 10.10.10.0 0.0.0.255 quit
7. 汇聚路由器 R5
system-view sysname R5 # 互联接口配置 interface GigabitEthernet0/0/1 ip address 10.10.10.2 255.255.255.252 # 连接R1 # interface GigabitEthernet0/0/2 ip address 10.10.10.10 255.255.255.252 # 连接R2 # interface GigabitEthernet0/0/3 ip address 10.10.10.17 255.255.255.252 # 连接R6 # interface GigabitEthernet0/0/4 ip address 10.10.10.21 255.255.255.252 # 连接R7 # OSPF配置 ospf 1 router-id 5.5.5.5 area 0 network 10.10.10.0 0.0.0.255 quit
8. 汇聚路由器 R6
system-view sysname R6 # 互联接口配置 interface GigabitEthernet0/0/1 ip address 10.10.10.6 255.255.255.252 # 连接R1 # interface GigabitEthernet0/0/2 ip address 10.10.10.14 255.255.255.252 # 连接R2 # interface GigabitEthernet0/0/3 ip address 10.10.10.18 255.255.255.252 # 连接R5 # interface GigabitEthernet0/0/4 ip address 10.10.10.25 255.255.255.252 # 连接R7 # OSPF配置 ospf 1 router-id 6.6.6.6 area 0 network 10.10.10.0 0.0.0.255 quit
9. 汇聚路由器 R7
system-view sysname R7 # 互联接口配置 interface GigabitEthernet0/0/1 ip address 10.10.10.22 255.255.255.252 # 连接R5 # interface GigabitEthernet0/0/2 ip address 10.10.10.26 255.255.255.252 # 连接R6 # interface GigabitEthernet0/0/3 ip address 10.10.10.29 255.255.255.252 # 连接R8 # OSPF配置 ospf 1 router-id 7.7.7.7 area 0 network 10.10.10.0 0.0.0.255 quit
10. 汇聚路由器 R8
system-view sysname R8 # 互联接口配置 interface GigabitEthernet0/0/0 ip address 10.10.10.30 255.255.255.252 # 连接R7 # interface GigabitEthernet0/0/1 ip address 10.10.10.34 255.255.255.252 # 连接R9 # OSPF配置 ospf 1 router-id 8.8.8.8 area 0 network 10.10.10.0 0.0.0.255 quit
11. 汇聚路由器 R9
system-view sysname R9 # 互联接口配置 interface GigabitEthernet0/0/0 ip address 10.10.10.38 255.255.255.252 # 连接R8 # interface GigabitEthernet0/0/1 ip address 192.168.200.2 255.255.255.252 # 连接R10 # OSPF配置 ospf 1 router-id 9.9.9.9 area 0 network 10.10.10.0 0.0.0.255 network 192.168.200.0 0.0.0.255 quit
12. 接入路由器 R10(单臂路由)
system-view sysname R10 # 连接R9的接口 interface GigabitEthernet0/0/0 ip address 192.168.200.1 255.255.255.252 # 单臂路由子接口配置 interface GigabitEthernet0/0/1.1 dot1q termination vid 10 ip address 192.168.3.254 255.255.255.0 # interface GigabitEthernet0/0/1.2 dot1q termination vid 20 ip address 192.168.4.254 255.255.255.0 # OSPF配置 ospf 1 router-id 10.10.10.10 area 0 network 192.168.3.0 0.0.0.255 network 192.168.4.0 0.0.0.255 network 192.168.200.0 0.0.0.255 quit
13. PC 终端配置
所有 PC 手动配置 IP 参数,以 PC1 为例:
-
IP 地址:192.168.1.1(192.168.1.1)
-
子网掩码:255.255.255.0(255.255.255.0)
-
网关:192.168.1.254(192.168.1.254)
-
DNS:可配置公共 DNS 如 8.8.8.8(8.8.8.8)
其余 PC 按照 IP 规划表对应配置即可。
配置验证
完成所有配置后,可通过以下命令验证配置有效性:
-
查看 VRRP 状态:
display vrrp -
查看 OSPF 邻居:
display ospf peer -
查看链路聚合状态:
display eth-trunk 1 -
查看 STP 状态:
display stp -
PC 之间互相 ping 测试,验证全网连通性与故障切换功能。