拓扑图
PC1电脑配置
指定ip192.168.10.1 网关192.18.10.254
LSW1交换机配置
ge0/0/1 access ,vlan10
ge0/0/2 trunk
ge0/0/3 trunk
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]vlan 10
[Huawei-vlan10]q
[Huawei]interface gigabitethernet 0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 10
[Huawei-GigabitEthernet0/0/1]q
[Huawei]interface gigabitethernet 0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type trunk
[Huawei-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[Huawei-GigabitEthernet0/0/2]q
[Huawei]interface gigabitethernet 0/0/3
[Huawei-GigabitEthernet0/0/3]port link-type trunk
[Huawei-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[Huawei-GigabitEthernet0/0/3]q
[Huawei]
LSW2交换机配置
基础配置
vlan10:192.168.10.252/24
vlan100:192.168.100.1/30
ge 0/0/1 trunk
ge 0/0/3 trunk
ge 0/0/2 access ,vlan100
<Huawei>
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname LSW2
[LSW2]vlan batch 10 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[LSW2]interface vlanif 10
[LSW2-Vlanif10]ip address 192.168.10.252 24
[LSW2-Vlanif10]q
[LSW2]interface vlanif 100
[LSW2-Vlanif100]ip address 192.168.100.1 30
[LSW2-Vlanif100]q
[LSW2]interface gigabitethernet 0/0/1
[LSW2-GigabitEthernet0/0/1]port link-type trunk
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[LSW2-GigabitEthernet0/0/1]q
[LSW2]interface gigabitethernet 0/0/3
[LSW2-GigabitEthernet0/0/3]port link-type trunk
[LSW2-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[LSW2-GigabitEthernet0/0/3]q
[LSW2]interface gigabitethernet 0/0/2
[LSW2-GigabitEthernet0/0/2]port link-type access
[LSW2-GigabitEthernet0/0/2]port default vlan 100
[LSW2-GigabitEthernet0/0/2]q
[LSW2]
配置VRRP
VRRP虚拟ip:192.168.10.254
优先级120
抢占时间20s
[LSW2]
[LSW2]interface vlanif 10
[LSW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
[LSW2-Vlanif10]vrrp vrid 10 priority 120
[LSW2-Vlanif10]vrrp vri 10 preempt-mode timer delay 20
[LSW2-Vlanif10]
配置路由
现在PC1和3台交换机是通的,但是到不了互联网
[LSW2]ip route-static 0.0.0.0 0 192.168.100.2
[LSW2]
LSW3交换机配置
基础配置
vlan10:192.168.10.253/24
vlan200:192.168.200.1/30
ge0/0/1 trunk
ge0/0/3 trunk
ge0/0/2 access,vlan200
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname LSW3
[LSW3]vlan batch 10 200
Info: This operation may take a few seconds. Please wait for a moment...done.
[LSW3]interface vlanif 10
[LSW3-Vlanif10]ip address 192.168.10.253 24
[LSW3-Vlanif10]q
[LSW3]interface vlanif 200
[LSW3-Vlanif200]ip address 192.168.200.1 30
[LSW3-Vlanif200]q
[LSW3]interface gigabitethernet 0/0/1
[LSW3-GigabitEthernet0/0/1]port link-type trunk
[LSW3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[LSW3-GigabitEthernet0/0/1]q
[LSW3]interface gigabitethernet 0/0/3
[LSW3-GigabitEthernet0/0/3]port link-type trunk
[LSW3-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[LSW3-GigabitEthernet0/0/3]q
[LSW3]interface gigabitethernet 0/0/2
[LSW3-GigabitEthernet0/0/2]port link-type access
[LSW3-GigabitEthernet0/0/2]port default vlan 200
[LSW3-GigabitEthernet0/0/2]q
[LSW3]
VRRP配置
VRRP虚拟ip:192.168.10.254
默认优先级100,所有LSW2是主,LSW3是备
[LSW3]
[LSW3]interface vlanif 10
[LSW3-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
[LSW3-Vlanif10]q
[LSW3]
配置默认路由
[LSW3]
[LSW3]ip route-static 0.0.0.0 0 192.168.200.2
[LSW3]
R1路由器配置
基础配置
ge0/0/1:192.168.100.2/30
ge0/0/2:192.168.200.2/30
ge0/0/0:100.1.1.2/30
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR1
[AR1]interface gigabitethernet 0/0/1
[AR1-GigabitEthernet0/0/1]ip address 192.168.100.2 30
[AR1-GigabitEthernet0/0/1]q
[AR1]interface gigabitethernet 0/0/2
[AR1-GigabitEthernet0/0/2]ip address 192.168.200.2 30
[AR1-GigabitEthernet0/0/2]q
[AR1]interface gigabitethernet 0/0/0
[AR1-GigabitEthernet0/0/0]ip address 100.1.1.2 30
[AR1-GigabitEthernet0/0/0]q
[AR1]
路由配置
将10网段指向100.1、200.1
回去有两条路,LSW2路由器出现故障挂掉的还可以走右边。
[AR1]
[AR1]ip route-static 192.168.10.0 24 192.168.100.1
[AR1]ip route-static 192.168.10.0 24 192.168.200.1
[AR1]
R2路由器配置
基础配置
ge0/0/0:100.1.1.1/30
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname AR2
[AR2]interface gigabitethernet 0/0/0
[AR2-GigabitEthernet0/0/0]ip address 100.1.1.1 30
[AR2-GigabitEthernet0/0/0]q
路由配置
将10网段丢给100.1.1.2,不然10网段请求过来,返回不去
[AR2]ip route-static 192.168.10.0 24 100.1.1.2
[AR2]q
<AR2>
至此全部配置完成,这个拓扑主要练习VRRP和路由走向关系。可以用pc1在ping100.1.1.1时候抓包看默认走的左边还是右边。很明显左边是主默认走左边,当我们把LSW2的ge0/0/2端口shutdown掉或者关机还是把线路删掉,会自动走备路线往右边出去。当左边的LSW2交换机恢复正常后,需要等待20秒后才会回复成master。