公网地址设为12.1.1.0/24 网段环回设为1.1.1.1
使用172.16.1.0/24给交换机划分网段
在sw1中使用172.16.1.1/25和172.1.129/25
在sw2中使用172.16.1.2/25和172.1.130/25
使用172.16.0.0/30给上方左侧路由干道划分网段
使用172.16.0.4/30给上方右侧侧路由干道划分网段
在sw1和sw2下设置Eth-Trunk干道
先在管理员模式下创建干道
然后进入接口设置干道
[sw1]interface Eth-Trunk 0
[sw1]interface g0/0/1
[sw1]-GigabitEthernet0/0/1]eth-trunk 0
[sw1]-GigabitEthernet0/0/1]int g0/0/2
[sw1]-GigabitEthernet0/0/2]eth-trunk 0
[sw2]interface Eth-Trunk 0
[sw2]interface g0/0/1
[sw2]-GigabitEthernet0/0/1]eth-trunk 0
[sw2]-GigabitEthernet0/0/1]int g0/0/2
[sw2]-GigabitEthernet0/0/2]eth-trunk 0
在三层交换机sw1上
[sw1]port-group group-member Ethernet0/0/4 to Ethernet 0/0/5 Eth-Trunk 0
[sw1]-port-group]port link-type trunk
[sw1]-Ethernet0/0/4]port link-type trunk //系统提示
[sw1]-Ethernet0/0/5]port link-type trunk //系统提示
[sw1]-port-group]port trunk allow-pass vlan 2 to 3
[sw1-Ethernet0/0/4]port trunk allow-pass vlan 2 to 3
[sw1-Ethernet0/0/5]port trunk allow-pass vlan 2 to 3//系统提示说明配置成功
在三层交换机sw2上
[sw2]port-group group-member Ethernet0/0/4 to Ethernet 0/0/5 Eth-Trunk 0
[sw2]-port-group]port link-type trunk
[sw2]-Ethernet0/0/4]port link-type trunk //系统提示
[sw2]-Ethernet0/0/5]port link-type trunk //系统提示
[sw2]-port-group]port trunk allow-pass vlan 2 to 3
[sw2-Ethernet0/0/4]port trunk allow-pass vlan 2 to 3
[sw2-Ethernet0/0/5]port trunk allow-pass vlan 2 to 3//系统提示说明配置成功
在二层交换机sw3上
[sw3]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/2
[sw3]-port-group]port link-type trunk
[sw3]-Ethernet0/0/1]port link-type trunk //系统提示
[sw3]-Ethernet0/0/2]port link-type trunk //系统提示说明配置成功
[sw3]-port-group]port trunk allow-pass vlan 2
[sw3-Ethernet0/0/1]port trunk allow-pass vlan 2
[sw3-Ethernet0/0/2]port trunk allow-pass vlan 2//系统提示说明配置成功
在二层交换机sw4上
[sw4]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/2
[sw4]-port-group]port link-type trunk
[sw4]-Ethernet0/0/1]port link-type trunk //系统提示
[sw4]-Ethernet0/0/2]port link-type trunk //系统提示说明配置成功
[sw4]-port-group]port trunk allow-pass vlan 2
[sw4-Ethernet0/0/1]port trunk allow-pass vlan 2
[sw4-Ethernet0/0/2]port trunk allow-pass vlan 2//系统提示说明配置成功
设置完后可以通过display port vlan active
查询设置的Trunk干道
如图,由于还没创建vlan,所以显示都是1
[sw1]vlan 2//因为sw1上默认有vlan1所以只用创建一个vlan2就行
[sw1-vlan2]
[sw2]vlan 2
[sw2-vlan2]
[sw3]vlan 2
[sw3-vlan2]
[sw4]vlan 2
[sw4-vlan2]
因为pc2和pc4在vlan2中所以需要让他们划分到vlan2
[sw3]int Ethernet0/0/4
[sw3-Ethernet0/0/4]port link-type access
[sw3-Ethernet0/0/4]port default vlan 2
[sw4]int Ethernet0/0/4
[sw4-Ethernet0/0/4]port link-type access
[sw4-Ethernet0/0/4]port default vlan 2
以sw1为例
[sw1]stp mode mstp
[sw1]stp enable
[sw1]stp region-configuration
[sw1-mst-region]region-name a
[sw1-mst-region]instance 1 vlan 1
[sw1-mst-region]instance 2 vlan 2
[sw1-mst-region]active region-configuration
设置好后可以通过display stp brief
来查看STP的状态
如图
根据三合一规则来改进
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary
[sw2]stp instance 1 root secondary
[sw2]stp instance 2 root primary
提高pc的连接效率
[sw3]port-group group-member Ethernet 0/0/3 to e0/0/4
[sw3-port-group]stp edged-port enable
[sw4]port-group group-member Ethernet 0/0/3 to e0/0/4
[sw4-port-group]stp edged-port enable
先给vlan配置ip地址
[sw1]interface Vlan 1
[sw1-Vlanif1]ip address 172.16.1.1 25
[sw1]interface Vlanif 2
[sw1-Vlanif2]ip address 172.16.1.129 25
[sw2]interface Vlanif 1
[sw2-Vlanif1]ip address 172.16.1.2 25
[sw2]int Vlanif 2
[sw2-Vlanif2]ip address 172.16.1.130 25
在sw1中vlan1做root,vlan2做备份
在sw2中vlan1做备份,vlan2做root
[sw1]interface Vlan 1
[sw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw1-Vlanif1]vrrp vrid 1 priority 120
[sw1-Vlanif1]vrrp vrid 1 track interface Ethernet 0/0/1 reduced 30
[sw1]interface Vlanif 2
[sw1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[sw2]interface Vlanif 1
[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw2]interface Vlanif 2
[sw2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[sw2-Vlanif2]vrrp vrid 1 priority 120
[sw2-Vlanif2]vrrp vrid 1 track interface Ethernet0/0/1 reduced 30
配置好后我们可以通过display vrrp brief
指令来查看
如图
[sw2]dhcp enable
[sw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw2]ip pool g1
Info:It's successful to create an IP address pool.
[sw2-ip-pool-g1] gateway-list 172.16.1.126
[sw2-ip-pool-g1] network 172.16.1.0 mask 255.255.255.128
[sw2-ip-pool-g1] dns-list 114.114.114.114
[sw2-ip-pool-g1]ip pool v2
Info:It's successful to create an IP address pool.
[sw2-ip-pool-v2] gateway-list 172.16.1.254
[sw2-ip-pool-v2] network 172.16.1.128 mask 255.255.255.128
[sw2-ip-pool-v2] dns-list 114.114.114.114 8.8.8.8
[sw2-ip-pool-v2]int vl1
[sw2-Vlanif1]dhcp select global
[sw2-Vlanif1]int vl2
[sw2-Vlanif2]dhcp select global
获取好后我们可以在PC上通过ipconfig
指令查看IP
如图
因为华为设备中没有实际端口,所以给sw1和sw2配置两个逻辑接口
sw1上
[sw1]vlan 100
[sw1-vlan100]q
[sw1]int e0/0/1
[sw1-Ethernet0/0/1]port link-type access
[sw1-Ethernet0/0/1]p d vlan 100
[sw1]int Vlanif 100
[sw1-Vlanif100]ip address 172.16.0.1 30
[sw1]ospf 1 router-id 1.1.1.2
[sw1-ospf-1]area 0
[sw1-ospf-1-area-0.0.0.0]network 172.16.0.1 0.0.0.0
[sw1-ospf-1]area 1
[sw1-ospf-1-area-0.0.0.1]network 172.16.1.129 0.0.0.0
sw2上
[sw2]vlan 100
[sw2-vlan100]q
[sw2]int e0/0/1
[sw2-Ethernet0/0/1]port link-type access
[sw2-Ethernet0/0/1]p d vlan 100
[sw2]int Vlanif 100
[sw2-Vlanif100]ip address 172.16.0.5 30
[sw2]ospf 1 router-id 2.2.2.2
[sw1-ospf-1]area 0
[sw1-ospf-1-area-0.0.0.0]network 172.16.0.5 0.0.0.0
[sw1-ospf-1]area 1
[sw1-ospf-1-area-0.0.0.1]network 172.16.1.130 0.0.0.0
路由器上
[r1]interface g0/0/1
[r1-GigabitEthernet0/0/1]ip address 172.16.0.2 30
[r1]interface g0/0/2
[r1-GigabitEthernet0/0/2]ip address 172.16.0.6 30
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.0.255
然后通过display ip routing-table protocol ospf
我们可以发现如图所示路由可以汇总
所以在sw1和sw2中的ospf通过abr-summary 172.16.1.0 255.255.255.0
来进行汇总
汇总后
通过display ospf peer brief
我们发现每有一个svi就会建立一个邻居,这会导致hello包发送太多导致更新量太大,所以应该使用沉默接口
由于要沉默的接口太多,所以我们直接将所有的接口沉默,然后再用undo命令来让自己想要的
[sw1-ospf-1]silent-interface all
[sw1-ospf-1]undo silent-interface Ethernet0/0/1
[sw1-ospf-1]undo silent-interface Eth-Trunk 0
[sw1-ospf-1]undo silent-interface Vlanif 1
[sw1-ospf-1]undo silent-interface Vlanif 100
[sw2-ospf-1]silent-interface all
[sw2-ospf-1]undo silent-interface Ethernet0/0/1
[sw1-ospf-1]undo silent-interface Eth-Trunk 0
[sw2-ospf-1]undo silent-interface Vlanif 1
[sw2-ospf-1]undo silent-interface Vlanif 100
[r1]ip route-static 0.0.0.0 0.0.0.0 12.1.1.2
[r1-ospf-1]default-route-advertise
[r1]acl 2000
[r1-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r1-acl-basic-2000]int g0/0/0
[r1-GigabitEthernet0/0/0]nat outbound 2000