一、实验拓扑图
二、实验要求
1.按照图示的VLAN及IP地址需求,完成相关配置;
2.要求SW1为VLAN 2和VLAN 3的主根和主网关,SW2为VLAN 20和VLAN 30的主根和主网关,SW1和SW2互为备份;
3.可以使用super vlan;
4.上层通过静态路由协议完成数据通信过程;
5.AR1为企业出口路由器;
6.要求全网可达。
三.实验步骤
1.给四台交换机配置VLAN
(1)创建VLAN,放通链路。
sw3
<Huawei>sys
[Huawei]sys sw3
[sw3]vlan batch 2 3 20 30
[sw3]interface GigabitEthernet 0/0/1
[sw3-GigabitEthernet0/0/1]p l a
[sw3-GigabitEthernet0/0/1]p d v 2
[sw3-GigabitEthernet0/0/1]int g0/0/2
[sw3-GigabitEthernet0/0/2]p l a
[sw3-GigabitEthernet0/0/2]p d v 3
[sw3-GigabitEthernet0/0/2]int g0/0/3
[sw3-GigabitEthernet0/0/3]p l t
[sw3-GigabitEthernet0/0/3]p t a v 2 3 20 30
[sw3-GigabitEthernet0/0/3]int g0/0/4
[sw3-GigabitEthernet0/0/4]p l t
[sw3-GigabitEthernet0/0/4]p t a v 2 3 20 30
SW4配置:
<Huawei>sys
[Huawei]sys sw4
[sw4]vlan batch 2 3 20 30
[sw4]int g0/0/1
[sw4-GigabitEthernet0/0/1]p l a
[sw4-GigabitEthernet0/0/1]p d v 20
[sw4-GigabitEthernet0/0/1]int g0/0/2
[sw4-GigabitEthernet0/0/2]p l a
[sw4-GigabitEthernet0/0/2]p d v 30
[sw4-GigabitEthernet0/0/2]int g0/0/3
[sw4-GigabitEthernet0/0/3]p l t
[sw4-GigabitEthernet0/0/3]p t a v 2 3 20 30
[sw4-GigabitEthernet0/0/3]int g0/0/4
[sw4-GigabitEthernet0/0/4]p l t
[sw4-GigabitEthernet0/0/4]p t a v 2 3 20 30
2)其中SW1和SW2的0/0/1和0/0/2接口不能单独放通,会导致有一条链路会阻塞,需要进行链路聚合,将这两条链路逻辑上捆绑成一条链路。(配置要求是链路接口不能有任何配置)。
sw1
<Huawei>sys
[Huawei]sys sw1
[sw1]vlan batch 2 3 20 30
[sw1]interface Eth-Trunk 0
[sw1-Eth-Trunk0]trunkport GigabitEthernet 0/0/1 to 0/0/2 (链路聚合)
[sw1-Eth-Trunk0]p l t
[sw1-Eth-Trunk0]p t a v 2 3 20 30
[sw1-Eth-Trunk0]q
[sw1]int g0/0/3
[sw1-GigabitEthernet0/0/3]p l t
[sw1-GigabitEthernet0/0/3]p t a v 2 3 20 30
[sw1-GigabitEthernet0/0/3]int g0/0/4
[sw1-GigabitEthernet0/0/4]p l t
[sw1-GigabitEthernet0/0/4]p t a v 2 3 20 30
SW2配置:
<Huawei>sys
[Huawei]sys sw2
[sw2]vlan batch 2 3 20 30
[sw2]interface Eth-Trunk 0
[sw2-Eth-Trunk0]trunkport GigabitEthernet 0/0/1 to 0/0/2 (链路聚合)
[sw2-Eth-Trunk0]p l t
[sw2-Eth-Trunk0]p t a v 2 3 20 30
[sw2-Eth-Trunk0]int g0/0/3
[sw2-GigabitEthernet0/0/3]p l t
[sw2-GigabitEthernet0/0/3]p t a v 2 3 20 30
[sw2-GigabitEthernet0/0/3]int g0/0/4
[sw2-GigabitEthernet0/0/4]p l t
[sw2-GigabitEthernet0/0/4]p t a v 2 3 20 30
2.生成树协议
(1)让四台交换机认知到mstp内容,两条链路互为备份。
①将VLAN 2和VLAN 3归为实例1,构造一棵生成树,使SW1为主根,SW2为备份根;
②将VLAN 20和VLAN 30归为实例2,构造一棵生成树,使SW2为主根,SW1为备份根。
SW1配置:
[sw1]stp enable
[sw1]stp mode mstp
[sw1]stp region-configuration
[sw1-mst-region] region-name aa
[sw1-mst-region] revision-level 100
[sw1-mst-region] instance 1 vlan 2 to 3
[sw1-mst-region] instance 2 vlan 20 30
[sw1-mst-region] active region-configuration
sw2配置
[sw2]stp enable
[sw2]stp mode mstp
[sw2]stp region-configuration
[sw2-mst-region] region-name aa
[sw2-mst-region] revision-level 100
[sw2-mst-region] instance 1 vlan 2 to 3
[sw2-mst-region] instance 2 vlan 20 30
[sw2-mst-region] active region-configuration
sw3配置:
[sw3]stp enable
[sw3]stp mode mstp
[sw3]stp region-configuration
[sw3-mst-region] region-name aa
[sw3-mst-region] revision-level 100
[sw3-mst-region] instance 1 vlan 2 to 3
[sw3-mst-region] instance 2 vlan 20 30
[sw3-mst-region] active region-configuration
sw4配置:
[sw4]stp enable
[sw4]stp mode mstp
[sw4]stp region-configuration
[sw4-mst-region] region-name aa
[sw4-mst-region] revision-level 100
[sw4-mst-region] instance 1 vlan 2 to 3
[sw4-mst-region] instance 2 vlan 20 30
[sw4-mst-region] active region-configuration
(2)让SW1成为实例1的主根,SW2成为实例2的主根。
①SW1:把实例1的优先级改为0,把实例2的优先级改为4096
②SW2:把实例1的优先级改为4096,把实例2的优先级改为0
SW1配置:
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary
SW2配置:
[sw2]stp instance 1 root secondary
[sw2]stp instance 2 root primary
(3)补充:在SW1的0/0/3接口开启根保护功能(防止新增的交换机抢占根角色)。
[sw1-GigabitEthernet0/0/3]stp root-protection
(4)补充:加快收敛机制,在SW3和SW4的0/0/1和0/0/2开启边端口功能(让接口无需参与stp工作,直接进入转发状态)。
SW3配置
[sw3]int g0/0/1
[sw3-GigabitEthernet0/0/1]stp edged-port enable
[sw3-GigabitEthernet0/0/1]int g0/0/2
[sw3-GigabitEthernet0/0/2]stp edged-port enable
SW4配置:
[sw4]int g0/0/1
[sw4-GigabitEthernet0/0/1]stp edged-port enable
[sw4-GigabitEthernet0/0/1]int g0/0/2
[sw4-GigabitEthernet0/0/2]stp edged-port enable
3.在SW1和SW2中配置VRRP
(1)三层接口用Vlanif,SW1成为VLAN 2和VLAN 3的主网关
①要使SW1成为VLAN 2和VLAN 3的主网关,需要调整优先级(默认100)至120;
②在SW1配置抢占延迟VRRP,让LSW1在稳定的时候把SW2的角色抢占过来;
③配置上行链路监控,需要降低优先级,比SW2低。
SW1配置:
[sw1]int Vlanif 2
[sw1-Vlanif2]ip add 10.0.2.1 24
[sw1-Vlanif2]vrrp vrid 1 virtual-ip 10.0.2.254
[sw1-Vlanif2]vrrp vrid 1 priority 120
[sw1-Vlanif2]vrrp vrid 1 preempt-mode timer delay 20
[sw1-Vlanif2]vrrp vrid 1 track interface GigabitEthernet 0/0/5 reduced 30
[sw1-Vlanif2]q
[sw1]int Vlanif 3
[sw1-Vlanif3]ip add 10.0.3.1 24
[sw1-Vlanif3]vrrp vrid 1 virtual-ip 10.0.3.254
[sw1-Vlanif3]vrrp vrid 1 priority 120
[sw1-Vlanif3]vrrp vrid 1 preempt-mode timer delay 20
[sw1-Vlanif3]vrrp vrid 1 track interface GigabitEthernet 0/0/5 reduced 30
(2)SW1成为VLAN 20和VLAN 30的备份网关,无需调整优先级、抢占延迟和上行链路监控。
SW1配置
[sw1]int Vlanif 20
[sw1-Vlanif20]ip add 10.0.20.1 24
[sw1-Vlanif20]vrrp vrid 1 virtual-ip 10.0.20.254
[sw1-Vlanif20]q
[sw1]int Vlanif 30
[sw1-Vlanif30]ip add 10.0.30.1 24
[sw1-Vlanif30]vrrp vrid 1 virtual-ip 10.0.30.254
(3)查询SW1 Vlanif当前配置:
(4)SW2中的VRRP配置与SW1相反,SW2是VLAN 2和VLAN 3的备份网关,是VLAN 20和VLAN 30的主网关。
SW2配置:
[sw2]int Vlanif 2
[sw2-Vlanif2]ip ad 10.0.2.2 24
[sw2-Vlanif2]vrrp vrid 1 virtual-ip 10.0.2.254
[sw2-Vlanif2]q
[sw2]int Vlanif 3
[sw2-Vlanif3]ip ad 10.0.3.2 24
[sw2-Vlanif3]vrrp vrid 1 virtual-ip 10.0.3.254
[sw2-Vlanif3]q
[sw2]int Vlanif 20
[sw2-Vlanif20]ip ad 10.0.20.2 24
[sw2-Vlanif20]vrrp vrid 1 virtual-ip 10.0.20.254
[sw2-Vlanif20]vrrp vrid 1 priority 120
[sw2-Vlanif20]vrrp vrid 1 preempt-mode timer delay 20
[sw2-Vlanif20]vrrp vrid 1 track in GigabitEthernet 0/0/5 reduced 30
[sw2-Vlanif20]q
[sw2]int Vlanif 30
[sw2-Vlanif30]ip ad 10.0.30.2 24
[sw2-Vlanif30]vrrp vrid 1 virtual-ip 10.0.30.254
[sw2-Vlanif30]vrrp vrid 1 priority 120
[sw2-Vlanif30]vrrp vrid 1 preempt-mode timer delay 20
[sw2-Vlanif30]vrrp vrid 1 track in GigabitEthernet 0/0/5 reduced 30
(5)查询SW2 Vlanif当前配置:
(6)在SW1和SW2中查看VRRP,检验一下。
①在SW1中,Vlanif2和Vlanif3是Master,Vlanif20和Vlanif30是Backup。②在SW2中,Vlanif2和Vlanif3是Backup,Vlanif20和Vlanif30是Master。
4.用静态IP配置PC的IP地址



用PC1分别ping PC2、PC3、PC4,检测连通性,此时四个VLAN互通。
5.OSPF动态路由协议
(1)SW1和SW2分别宣告对应的五个接口,AR1宣告两个接口。
SW1配置:
[sw1]ospf 1
[sw1-ospf-1]area 0
[sw1-ospf-1-area-0.0.0.0]network 10.0.2.1 0.0.0.0
[sw1-ospf-1-area-0.0.0.0]network 10.0.3.1 0.0.0.0
[sw1-ospf-1-area-0.0.0.0]network 10.0.0.2 0.0.0.0
[sw1-ospf-1-area-0.0.0.0]network 10.0.20.1 0.0.0.0
[sw1-ospf-1-area-0.0.0.0]network 10.0.30.1 0.0.0.0
SW2配置
[sw2]ospf 1
[sw2-ospf-1]area 0
[sw2-ospf-1-area-0.0.0.0]network 10.0.2.2 0.0.0.0
[sw2-ospf-1-area-0.0.0.0]network 10.0.3.2 0.0.0.0
[sw2-ospf-1-area-0.0.0.0]network 10.0.0.6 0.0.0.0
[sw2-ospf-1-area-0.0.0.0]network 10.0.20.2 0.0.0.0
[sw2-ospf-1-area-0.0.0.0]network 10.0.30.2 0.0.0.0
r1配置
[AR1]ospf 1
[AR1-ospf-1]area 0
[AR1-ospf-1-area-0.0.0.0]network 10.0.0.1 0.0.0.0
[AR1-ospf-1-area-0.0.0.0]network 10.0.0.5 0.0.0.0
2)让四个Vlanif接口成为静默接口(接口不允许发送和接收OSPF报文)。
SW1配置
[sw1-ospf-1]silent-interface Vlanif 2
[sw1-ospf-1]silent-interface Vlanif 3
[sw1-ospf-1]silent-interface Vlanif 20
[sw1-ospf-1]silent-interface Vlanif 30
SW2配置:
[sw2-ospf-1]silent-interface Vlanif 2
[sw2-ospf-1]silent-interface Vlanif 3
[sw2-ospf-1]silent-interface Vlanif 20
[sw2-ospf-1]silent-interface Vlanif 30
3)在SW1和SW2之间的链路配置VLAN,并放通链路、宣告。
SW1配置
[sw1]vlan 13
[sw1-vlan13]q
[sw1]int Eth-Trunk 0
[sw1-Eth-Trunk0]p t a v 13
[sw1]int Vlanif 13
[sw1-Vlanif13]ip add 10.0.0.9 30
[sw1-Vlanif13]q
[sw1]ospf 1
[sw1-ospf-1]area 0
[sw1-ospf-1-area-0.0.0.0]network 10.0.0.9 0.0.0.0
SW2配置:
[sw2]vlan 13
[sw2-vlan13]q
[sw2]int Eth-Trunk 0
[sw2-Eth-Trunk0]p t a v 13
[sw2-Eth-Trunk0]q
[sw2]interface Vlanif 13
[sw2-Vlanif13]ip address 10.0.0.10 30
[sw2-Vlanif13]q
[sw2]ospf 1
[sw2-ospf-1]area 0
[sw2-ospf-1-area-0.0.0.0]network 10.0.0.10 0.0.0.0
4)查看ospf表,并让SW1 ping SW2的Vlanif接口,检测连通性。
6.三层配置
SW1和SW2与AR1互联,配置VLAN和接口IP地址(互联接口在交换机上称为互联VLAN)。
SW1配置:
[sw1]vlan 11
[sw1-vlan11]int g0/0/5
[sw1-GigabitEthernet0/0/5]port link-type access
[sw1-GigabitEthernet0/0/5]port default vlan 11
[sw1-GigabitEthernet0/0/5]q
[sw1]int Vlanif 11
[sw1-Vlanif11]ip add 10.0.0.2 30
SW2配置:
[sw2]vlan 12
[sw2-vlan12]int g0/0/5
[sw2-GigabitEthernet0/0/5]port link-type access
[sw2-GigabitEthernet0/0/5]port default vlan 12
[sw2-GigabitEthernet0/0/5]q
[sw2]int Vlanif 12
[sw2-Vlanif12]ip ad 10.0.0.6 30
r1配置:
[Huawei]sys r1
[r1]int g 0/0/1
[r1-GigabitEthernet0/0/1]ip address 10.0.0.1 30
[r1-GigabitEthernet0/0/1]int g 0/0/2
[r1-GigabitEthernet0/0/2]ip address 10.0.0.5 30
7.PC连通外网
(1)先给AR1和ISP之间的链路接口和ISP的环回接口配置IP地址。
r1配置:
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip ad 202.1.1.1 30
[r1]ip route-static 0.0.0.0 0 202.1.1.2
[r1-ospf-1]default-route-advertise
[r1]ospf 1
[r1-ospf-1]default-route-advertise
ISP配置:
<Huawei>sys
[Huawei]sys isp
[isp]int g 0/0/0
[isp-GigabitEthernet0/0/0]ip address 202.1.1.2 30
[isp]int LoopBack 0
[isp-LoopBack0]ip address 100.100.100.100 24
(2)AR1既作为核心层,又作为边界设备,需要写一条缺省路由指向运营商,保证成功访问外网,并配置NAT,使企业内网(私网)和运营商(公网)连通。
r1配置
[r1]acl 2000
[r1-acl-basic-2000]rule permit source 10.0.0.0 0.0.255.255
[r1-acl-basic-2000]q
[r1]int g 0/0/0
[r1-GigabitEthernet0/0/0]nat outbound 2000
(3)检测连通性,实现全网可达。