实验拓扑图
实验配置
r1
The device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys r1
[r1]int g0/0/2
[r1-GigabitEthernet0/0/2]ip add 12.1.1.1 24
[r1]int LoopBack 0
[r1-LoopBack0]ip add 1.1.1.1 24
[r1-LoopBack0]q
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 23.1.1.1 24
[r1-GigabitEthernet0/0/0]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 34.1.1.1 24
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]network 34.1.1.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]q
[r1-ospf-1]default-route-advertise
[r1-ospf-1]q
[r1]ip route-static 0.0.0.0 0 12.1.1.2
[r1]acl 2000
[r1-acl-basic-2000]rule permit source any
[r1-acl-basic-2000]q
[r1]int g0/0/2
[r1-GigabitEthernet0/0/2]nat outbound 2000
r2
The device is running!
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys r2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/0]q
[r2]int LoopBack 0
[r2-LoopBack0]ip add 2.2.2.2 24
lsw1
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys lsw1
[lsw1]int Vlanif 1
[lsw1-Vlanif1]ip add 23.1.1.2 24
[lsw1-Vlanif1]q
[lsw1]int Eth-Trunk
[lsw1-Eth-Trunk1]
[lsw1]int g0/0/05
[lsw1-GigabitEthernet0/0/5]eth-trunk 1
[lsw1-GigabitEthernet0/0/6]eth-trunk 1
[lsw1-GigabitEthernet0/0/1]int g0/0/7
[lsw1-GigabitEthernet0/0/7]eth-trunk 1
[lsw1]int Eth-Trunk 1
[lsw1-Eth-Trunk1]port link-type trunk
[lsw1-Eth-Trunk1]port trunk allow-pass vlan all
[lsw1]vlan batch 2 3
[lsw1]int g0/0/2
[lsw1-GigabitEthernet0/0/2]port link-type access
[lsw1-GigabitEthernet0/0/2]port default vlan 2
[lsw1-GigabitEthernet0/0/2]int g0/0/2
[lsw1-GigabitEthernet0/0/2]port link-type access
[lsw1-GigabitEthernet0/0/2]port default vlan 3
[lsw1-GigabitEthernet0/0/2]int g0/0/4
[lsw1-GigabitEthernet0/0/4]port link-type trunk
[lsw1-GigabitEthernet0/0/4]port trunk allow-pass vlan all
[lsw1]stp mode mstp
[lsw1]stp region-configuration
[lsw1-mst-region]instance 1 vlan 2
[lsw1-mst-region]instance 2 vlan 3
[lsw1-mst-region]active region-configuration
[lsw1]stp instance 1 root primary
[lsw1]stp instance 2 root secondary
[lsw1]interface Vlanif 2
[lsw1-Vlanif2]vrrp vrid 1 virtual-ip 192.168.1.1
[lsw1-Vlanif2]vrrp vrid 1 priority 120(改优先级)
[lsw1-Vlanif2]vrrp vrid 1 preempt-mode timer delay 20(改时间)
[lsw1]ospf 1 router-id 2.2.2.2
[lsw1-ospf-1]area 0
[lsw1-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[lsw1-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.255
[lsw1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[lsw1-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[lsw1]int Vlanif 3
[lsw1-Vlanif3]ip add 172.16.1.1 24
[lsw1-Vlanif3]vrrp vrid 2 virtual-ip 172.16.1.2
[lsw1]dhcp enable
[lsw1]ip pool 1
[lsw1-ip-pool-1]network 192.168.1.0 mask 24
[lsw1-ip-pool-1]gateway-list 192.168.1.1
[lsw1]int Vlanif 2[lsw1-Vlanif2]dhcp select global
[lsw1]ip pool 2
[lsw1-ip-pool-2]network 172.16.1.2
[lsw1-ip-pool-2]network 172.16.1.0 mask 24
[lsw1-ip-pool-2]gateway-list 172.16.1.2
[lsw1-ip-pool-2]q
[lsw1]int Vlanif 3
[lsw1-Vlanif3]dhcp select global
lsw2
The device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys lsw2
[lsw2]int Vlanif 1
[lsw2-Vlanif1]ip add 34.1.1.2 24
[lsw2]int Eth-Trunk 1
[lsw2-Eth-Trunk1]q
[lsw2]int g0/0/6
[lsw2-GigabitEthernet0/0/6]eth-trunk 1
[lsw2-GigabitEthernet0/0/6]int g0/0/5
[lsw2-GigabitEthernet0/0/5]eth-trunk 1
[lsw2-GigabitEthernet0/0/5]int g0/0/7
[lsw2-GigabitEthernet0/0/7]eth-trunk 1
[lsw2]int Eth-Trunk 1
[lsw2-Eth-Trunk1]port link-type trunk
[lsw2-Eth-Trunk1]port trunk allow-pass vlan all
[lsw2]vlan batch 2 3
[lsw2]int g0/0/2
[lsw2-GigabitEthernet0/0/2]port link-type access
[lsw2-GigabitEthernet0/0/2]port default vlan 2
[lsw2-GigabitEthernet0/0/2]int g0/0/3
[lsw2-GigabitEthernet0/0/3]port link-type access
[lsw2-GigabitEthernet0/0/3]port default vlan 3
[lsw2-GigabitEthernet0/0/3]int g0/0/4
[lsw2-GigabitEthernet0/0/4]port link-type trunk
[lsw2-GigabitEthernet0/0/4]port trunk allow-pass vlan all
[lsw2]stp mode mstp
[lsw2]stp region-configuration
[lsw2-mst-region]instance 1 vlan 2
[lsw2-mst-region]instance 2 vlan 3
[lsw2-mst-region]active region-configuration
[lsw2]stp instance 1 root secondary
[lsw2]stp instance 2 root primary
[lsw2]ospf 1 router-id 3.3.3.3
[lsw2-ospf-1]area 0
[lsw2-ospf-1-area-0.0.0.0]network 34.1.1.0 0.0.0.255
[lsw2-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.255
[lsw2-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[lsw2-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[lsw2]int Vlanif 2
[lsw2-Vlanif2]ip add 192.168.1.2 24
[lsw2]int Vlanif 3
[lsw2-Vlanif3]ip add 172.16.1.2 24
[lsw2]int Vlanif 2
[lsw2-Vlanif2]vrrp vrid 1 virtual-ip 192.168.1.1
[lsw2]int Vlanif 3
[lsw2-Vlanif3]vrrp vrid 2 virtual-ip 172.16.1.2
[lsw2-Vlanif3]vrrp vrid 2 priority 120
[lsw2-Vlanif3]vrrp vrid 2 preempt-mode timer delay 20
[lsw2]dhcp enable
[lsw2]ip pool 1
[lsw2-ip-pool-1]network 192.168.1.0 mask 24
[lsw2-ip-pool-1]gateway-list 192.168.1.1
[lsw2]int Vlanif 2
[lsw2-Vlanif2]dhcp select global
[lsw2-Vlanif2]q
[lsw2]ip pool 3
[lsw2-ip-pool-3]network 172.16.1.0 mask 24
[lsw2-ip-pool-3]gateway-list 172.16.1.2
[lsw2]int Vlanif 3
[lsw2-Vlanif3]dhcp select global
lsw3
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys lsw3
[lsw3]port-group 1
[lsw3-port-group-1]
[lsw3]vlan 2
[lsw3-vlan2]port-group 1
[lsw3-port-group-1]group-member e0/0/1 to e0/0/4
[lsw3-port-group-1]port link-type access
[lsw3-port-group-1]port default vlan 2
lsw4
The device is running!
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys lsw4[lsw4]port-group 1
[lsw4-port-group-1]group-member e0/0/1 to e0/0/4
[lsw4-port-group-1]port link-type access
[lsw4-port-group-1]port default vlan 3
lsw5
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys lsw5
[lsw5]vlan batch 2 3
[lsw5]port-group 1
[lsw5-port-group-1]group-member e0/0/1 to e0/0/2
[lsw5-port-group-1]port link-type trunk
[lsw5-port-group-1]port trunk allow-pass vlan
[lsw5]int e0/0/3
[lsw5-Ethernet0/0/3]port link-type access
[lsw5-Ethernet0/0/3]port default vlan 2
[lsw5-Ethernet0/0/3]int e0/0/4
[lsw5-Ethernet0/0/4]port link-type access
[lsw5-Ethernet0/0/4]port default vlan 3
实验结果:全网可达