1. 实验目标根据题图本实验需要完成以下 6 个要求内网 IP 地址统一从172.16.0.0/16中规划。LSW1和LSW2之间形成双核心冗余。同时使用VRRP / STP / VLAN / Eth-Trunk。所有终端通过DHCP自动获取 IP 地址。ISP 路由器只能配置 IP不能承担额外策略功能。所有 PC 都能够访问 ISP 路由器的环回地址。原始题图如下2. 拓扑理解与总体设计这个实验本质上是一个小型园区网高可用设计题。拓扑中最关键的不是“把每条命令敲出来”而是先明确每台设备的角色AR1作为企业出口路由器负责DHCP、静态路由和NAT。AR2作为 ISP 路由器只保留接口 IP 和Loopback0满足题目限制。LSW1与LSW2作为双核心三层交换机承担网关冗余与链路冗余。LSW3与LSW4作为接入层交换机负责 PC 接入和 VLAN 划分。如果只做单核心那么虽然可以连通但完全不符合“互为备份”的要求。因此本方案采用双核心设计并让不同 VLAN 的主路径分别落在不同核心上这样既满足冗余也能体现负载分担思想。3. 地址规划3.1 用户网段规划为了满足“内网地址使用172.16.0.0/16分配”的要求我把两个用户 VLAN 规划如下网段用途虚拟网关172.16.2.0/24VLAN 2PC1、PC3172.16.2.254172.16.3.0/24VLAN 3PC2、PC4172.16.3.254其中LSW1 Vlanif2 172.16.2.252/24LSW2 Vlanif2 172.16.2.253/24LSW1 Vlanif3 172.16.3.252/24LSW2 Vlanif3 172.16.3.253/243.2 设备互联网段核心与出口之间以及出口到 ISP 之间单独规划点到点链路地址链路地址规划AR1 - LSW1172.16.254.0/30AR1 - LSW2172.16.254.4/30AR1 - AR212.1.1.0/30AR2 Loopback0100.100.100.100/32具体地址如下AR1 G0/0/1 172.16.254.1/30LSW1 G0/0/5 172.16.254.2/30AR1 G0/0/0 172.16.254.5/30LSW2 G0/0/5 172.16.254.6/30AR1 G0/0/2 12.1.1.1/30AR2 G0/0/0 12.1.1.2/30AR2 LoopBack0 100.100.100.100/324. 二层冗余设计分析4.1 VLAN 规划题图中四台 PC 分别属于两个 VLANPC1、PC3属于VLAN 2PC2、PC4属于VLAN 3这样做的目的是把用户业务拆分到两个广播域中既满足实验要求也方便后续做 VRRP 主备分工。4.2 Eth-Trunk 设计LSW1与LSW2之间有两条并行链路。如果把它们作为普通 Trunk 使用那么生成树最终会阻塞其中一条资源利用率不高。因此这里将两条链路聚合为Eth-Trunk1好处 1带宽叠加好处 2单条成员链路故障时聚合链路仍可工作好处 3更符合企业网络的真实做法4.3 MSTP 设计如果只开启普通 STP网络虽然也能避免环路但流量会长期压在单个根桥上。为了体现双核心分担作用这里使用MSTPMSTI 1绑定VLAN 2MSTI 2绑定VLAN 3根桥角色这样分配LSW1MSTI 1主根MSTI 2备根LSW2MSTI 2主根MSTI 1备根技术上这样设计的意义很明确VLAN 2的二层最优路径偏向LSW1VLAN 3的二层最优路径偏向LSW2冗余链路存在但不会形成环路双核心都有主业务不会出现“一主一闲”的情况5. 三层网关冗余设计分析5.1 为什么使用 VRRP接入终端必须有稳定的默认网关。如果直接把某一台交换机的真实 IP 配成网关那么设备故障时整网就会断。因此这里使用VRRP为两个 VLAN 提供虚拟网关VLAN 2虚拟网关172.16.2.254VLAN 3虚拟网关172.16.3.254主备角色分工如下LSW1做VLAN 2的 VRRP MasterLSW2做VLAN 3的 VRRP Master这和上面的 MSTP 根桥设计是对应的。也就是说VLAN 2的二层主路径和三层主网关都偏向LSW1VLAN 3的二层主路径和三层主网关都偏向LSW2这样不会产生流量绕行。5.2 为什么做接口跟踪如果某台核心交换机还在运行但它和AR1的出口链路断了那么它虽然能继续响应 VRRP却已经无法把流量送出园区。这种状态是“假在线”。因此本方案在 VRRP 中加入了trackLSW1跟踪自己到AR1的三层上联LSW2也跟踪自己到AR1的三层上联一旦上联断开VRRP 优先级下降另一台核心接管虚拟网关。这一步是整个实验里最容易被忽略、但最有技术含量的地方。6. DHCP 与 NAT 设计分析6.1 为什么 DHCP 放在 AR1DHCP 可以放在三层交换机上也可以放在路由器上。这里选择放在AR1原因有三点地址池集中管理结构清晰双核心只做中继不重复维护地址池更接近“出口统一承载服务”的思路因此AR1运行DHCP ServerLSW1和LSW2在各自Vlanif上做DHCP Relay6.2 为什么必须做 NAT题目要求所有 PC 访问 ISP 路由器的环回地址而 ISP 路由器又只能配 IP这意味着AR2不会写回程静态路由。解决办法就是在AR1做源 NAT内网主机发往100.100.100.100的报文源地址是172.16.x.x到达AR1后被转换为12.1.1.1AR2只需要知道如何返回12.1.1.1无需知道内网所有网段业务流向如下图7. 设备配置与配置解释这一节直接把核心配置写进博客正文便于作为作业提交。7.1 AR1 配置sysname AR1 dhcp enable ip pool VLAN2 network 172.16.2.0 mask 255.255.255.0 gateway-list 172.16.2.254 dns-list 114.114.114.114 ip pool VLAN3 network 172.16.3.0 mask 255.255.255.0 gateway-list 172.16.3.254 dns-list 114.114.114.114 acl number 2000 rule 5 permit source 172.16.0.0 0.0.255.255 interface GigabitEthernet0/0/0 ip address 172.16.254.5 255.255.255.252 interface GigabitEthernet0/0/1 ip address 172.16.254.1 255.255.255.252 interface GigabitEthernet0/0/2 ip address 12.1.1.1 255.255.255.252 nat outbound 2000 ip route-static 0.0.0.0 0.0.0.0 12.1.1.2 ip route-static 172.16.2.0 255.255.255.0 172.16.254.2 preference 60 ip route-static 172.16.2.0 255.255.255.0 172.16.254.6 preference 80 ip route-static 172.16.3.0 255.255.255.0 172.16.254.6 preference 60 ip route-static 172.16.3.0 255.255.255.0 172.16.254.2 preference 80配置解释两个ip pool分别给VLAN 2和VLAN 3提供地址。网关写成 VRRP 虚拟 IP而不是某台交换机真实地址。acl 2000匹配整个内网地址段供 NAT 调用。到VLAN 2和VLAN 3的静态路由都采用主备方式对应双核心冗余。7.2 AR2 配置sysname AR2 interface GigabitEthernet0/0/0 ip address 12.1.1.2 255.255.255.252 interface LoopBack0 ip address 100.100.100.100 255.255.255.255配置解释这里只配置接口 IP 和环回地址严格符合题目要求。LoopBack0就是最终联通性测试目标。7.3 LSW1 配置sysname LSW1 dhcp enable vlan batch 2 3 stp mode mstp stp region-configuration region-name CAMPUS revision-level 1 instance 1 vlan 2 instance 2 vlan 3 active region-configuration stp instance 1 root primary stp instance 2 root secondary interface Eth-Trunk1 mode lacp-static port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/1 eth-trunk 1 interface GigabitEthernet0/0/2 eth-trunk 1 interface GigabitEthernet0/0/3 port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/4 port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/5 undo portswitch ip address 172.16.254.2 255.255.255.252 interface Vlanif2 ip address 172.16.2.252 255.255.255.0 vrrp vrid 2 virtual-ip 172.16.2.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 vrrp vrid 2 track interface GigabitEthernet0/0/5 reduced 30 dhcp select relay dhcp relay server-ip 172.16.254.1 interface Vlanif3 ip address 172.16.3.252 255.255.255.0 vrrp vrid 3 virtual-ip 172.16.3.254 vrrp vrid 3 priority 100 vrrp vrid 3 preempt-mode timer delay 20 vrrp vrid 3 track interface GigabitEthernet0/0/5 reduced 30 dhcp select relay dhcp relay server-ip 172.16.254.1 ip route-static 0.0.0.0 0.0.0.0 172.16.254.1配置解释LSW1在MSTI 1中为主根因此更适合承载VLAN 2主业务。Vlanif2上 VRRP 优先级更高所以它是VLAN 2的主网关。Vlanif3保留备份角色实现主备互补。dhcp relay server-ip指向AR1把 DHCP 请求转发给出口路由器。7.4 LSW2 配置sysname LSW2 dhcp enable vlan batch 2 3 stp mode mstp stp region-configuration region-name CAMPUS revision-level 1 instance 1 vlan 2 instance 2 vlan 3 active region-configuration stp instance 1 root secondary stp instance 2 root primary interface Eth-Trunk1 mode lacp-static port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/1 eth-trunk 1 interface GigabitEthernet0/0/2 eth-trunk 1 interface GigabitEthernet0/0/3 port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/4 port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/5 undo portswitch ip address 172.16.254.6 255.255.255.252 interface Vlanif2 ip address 172.16.2.253 255.255.255.0 vrrp vrid 2 virtual-ip 172.16.2.254 vrrp vrid 2 priority 100 vrrp vrid 2 preempt-mode timer delay 20 vrrp vrid 2 track interface GigabitEthernet0/0/5 reduced 30 dhcp select relay dhcp relay server-ip 172.16.254.5 interface Vlanif3 ip address 172.16.3.253 255.255.255.0 vrrp vrid 3 virtual-ip 172.16.3.254 vrrp vrid 3 priority 120 vrrp vrid 3 preempt-mode timer delay 20 vrrp vrid 3 track interface GigabitEthernet0/0/5 reduced 30 dhcp select relay dhcp relay server-ip 172.16.254.5 ip route-static 0.0.0.0 0.0.0.0 172.16.254.5配置解释LSW2在MSTI 2中为主根在VRID 3中也是更高优先级因此承担VLAN 3的主路径。这使VLAN 2与VLAN 3的主流量在两台核心之间自然分摊。一旦LSW2到AR1的三层链路失效它会在VRRP中降权让另一台核心接管。7.5 LSW3 配置sysname LSW3 vlan batch 2 3 stp mode mstp stp region-configuration region-name CAMPUS revision-level 1 instance 1 vlan 2 instance 2 vlan 3 active region-configuration interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/3 port link-type access port default vlan 2 stp edged-port enable interface GigabitEthernet0/0/4 port link-type access port default vlan 3 stp edged-port enable配置解释两条上联都保留trunk支持双核心冗余。PC1 接到VLAN 2PC2 接到VLAN 3。stp edged-port enable可以让终端口更快进入转发状态。7.6 LSW4 配置sysname LSW4 vlan batch 2 3 stp mode mstp stp region-configuration region-name CAMPUS revision-level 1 instance 1 vlan 2 instance 2 vlan 3 active region-configuration interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 3 interface GigabitEthernet0/0/3 port link-type access port default vlan 2 stp edged-port enable interface GigabitEthernet0/0/4 port link-type access port default vlan 3 stp edged-port enable配置解释LSW4与LSW3保持同样的设计思路方便统一维护。PC3 属于VLAN 2PC4 属于VLAN 3。8. eNSP 实施步骤在 eNSP 中建议按下面顺序操作先按题图和端口映射把所有设备连接好。配置LSW3、LSW4的VLAN和接入口。配置LSW1、LSW2的VLAN、Trunk、Eth-Trunk、MSTP。配置双核心的Vlanif、VRRP和DHCP Relay。配置AR1的DHCP、静态路由和NAT。配置AR2的接口 IP 与环回地址。将 PC1 到 PC4 全部改成 DHCP 获取地址。9. 验证方法9.1 交换机验证display vlan display stp brief display stp instance display eth-trunk 1 display vrrp brief display ip interface brief display ip routing-table重点观察Eth-Trunk1是否正常 UpLSW1是否成为VLAN 2的 VRRP MasterLSW2是否成为VLAN 3的 VRRP MasterMSTI 1和MSTI 2的根桥是否按设计生效9.2 路由器验证display ip interface brief display ip routing-table display ip pool display nat session all重点观察AR1的 DHCP 池是否生效到172.16.2.0/24与172.16.3.0/24是否存在主备路由访问 ISP 环回时是否产生 NAT 会话9.3 PC 验证ipconfig ping 172.16.2.254 ping 172.16.3.254 ping 100.100.100.100预期结果PC1、PC3获取172.16.2.0/24地址PC2、PC4获取172.16.3.0/24地址所有 PC 都可以 Ping 通100.100.100.1009.4 冗余验证为了体现“互为备份”建议做两项故障测试手动断开LSW1到AR1的链路观察VLAN 2网关是否切换。手动断开某条核心到接入的上联观察终端是否仍能恢复通信。如果 VRRP 和 MSTP 设计正确业务会短暂收敛后恢复。10. 结论这个实验真正体现的是企业园区网的完整思路而不是孤立协议堆砌VLAN用来做用户隔离Eth-Trunk用来做链路冗余和带宽聚合MSTP用来消除环路并优化二层流向VRRP用来保证默认网关高可用DHCP Relay DHCP Server用来统一地址分配NAT用来让内网在 ISP 只配 IP 的前提下访问外网目标