拓扑图
JR
创建vlan及更改设备名
HOSTNAME mamu-CORE-01
vlan 10
name jwc
vlan 20
name xzc
vlan 30
name xsc
vlan 40
name cwc
HJ-01
创建vlan及更改设备名,开启三层交换机路由功能
HOSTNAME mamu-hj-01
ip routing
vlan 10
name jwc
vlan 20
name xzc
vlan 30
name xsc
vlan 40
name cwc
HJ-02
创建vlan及更改设备名,开启三层交换机路由功能
HOSTNAME mamu-hj-02
ip routing
vlan 10
name jwc
vlan 20
name xzc
vlan 30
name xsc
vlan 40
name cwc
JR将端口封装dot1q协议并设置为trunk口
int range e0/0
switchport trunk encapsulation dot1q
switchport mode trunk
no sh
int range e0/1
switchport trunk encapsulation dot1q
switchport mode trunk
no sh
HJ-1
将端口封装dot1q协议并设置为trunk口
将e1/1-2加入聚合组
int range e1/1-2
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 1 mode on
no sh
int port-channel 1
switchport trunk encapsulation dot1q
switchport mode trunk
no sh
HJ-2
将端口封装dot1q协议并设置为trunk口
将e1/1-2加入聚合组
int range e1/1-2
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 1 mode on
no sh
int port-channel 1
switchport trunk encapsulation dot1q
switchport mode trunk
no sh
JR
将e1/0-3分别划分vlan到vlan10-40
并设置该端口为快速端口 把一个port设置了portfast,就是让那个port不再使用STP的算法
启用BPDU防护功能,在此端口不接受BPDU
int e1/0
switchport access vlan 10
description con-to-jwc-1
spanning-tree portfast //设置该端口为快速端口 把一个port设置了portfast,就是让那个port不再使用STP的算法
spanning-tree bpduguard enable //启用BPDU防护功能,在此端口不接受BPDU
no sh
int e1/1
switchport access vlan 20
description con-to-xzc-1
spanning-tree portfast
spanning-tree bpduguard enable
int e1/2
switchport access vlan 30
description con-to-xsc-1
no sh
spanning-tree portfast
spanning-tree bpduguard enable
int e1/3
switchport access vlan 40
description con-to-cwc-1
no sh
spanning-tree portfast
spanning-tree bpduguard enable
HJ-1
配置instance 1(实例1)并关联 vlan 10,30
配置instance 2(实例2)并关联 vlan 20,40
spanning-tree mode mst //启用多生成树协议
spanning-tree mst configuration //进入MST配置模式
name ruijile
revision 1
instance 1 vlan 10,30
instance 2 vlan 20,40
spanning-tree mst 1 priority 4096 //配置三层交换机在instance 1中的优先级为4096
spanning-tree mst 2 priority 8192 //配置三层交换机在instance 2中的优先级为8192
HJ-2
instance1:包括vlan10,30
instance2:包括:vlan 20,40
spanning-tree mode mst //启用多生成树协议
spanning-tree mst configuration //进入MST配置模式
revision 1
instance 1 vlan 10,30
instance 2 vlan 20,40
spanning-tree mst 1 priority 8192
spanning-tree mst 2 priority 4096
H1-1
创建监听端口并配置vlan svi接口IP充当各部门网关
配置VRRPip及优先级等信息
track 1 int e3/0 line-protocol //创建E3/0为监听端口
!
int vlan 10
ip address 192.168.10.252 255.255.255.0
vrrp 10 ip 192.168.10.254
vrrp 10 track 1 decrement 10 //调用跟踪事件1,发现上行链路down后优先级会减10
vrrp 10 priority 105
no sh
!
int vlan 20
ip address 192.168.20.252 255.255.255.0
vrrp 20 ip 192.168.20.254
no sh
!
int vlan 30
ip address 192.168.30.252 255.255.255.0
vrrp 30 ip 192.168.30.254
vrrp 10 track 1 decrement 10 //调用跟踪事件1,发现上行链路down后优先级会减10
vrrp 30 priority 105
no sh
!
int vlan 40
ip address 192.168.40.252 255.255.255.0
vrrp 40 ip 192.168.40.254
no sh
!
优先级调整后
HJ-1作为VLAN 10,VLAN30的主,VLAN20,VLAN40的备,HJ-2作为VLAN20,VLAN40的主,VLAN 10,VLAN30的备,2台设备上联口设置Track跟踪,若主设备故障,主动降级为备设备)
show vrrp brief命令查看VRRP
HJ-2
创建监听端口并配置vlan svi接口IP充当各部门网关
配置VRRPip及优先级等信息
HJ-1作为VLAN 10,VLAN30的主,VLAN20,VLAN40的备,HJ-2作为VLAN20,VLAN40的主,VLAN 10,VLAN30的备,2台设备上联口设置Track跟踪,若主设备故障,主动降级为备设备)
track 1 int e3/0 line-protocol //创建E3/0为监听端口
!
int vlan 10
ip address 192.168.10.253 255.255.255.0
vrrp 10 ip 192.168.10.254
no sh
!
int vlan 20
ip address 192.168.20.253 255.255.255.0
vrrp 20 ip 192.168.20.254
vrrp 20 track 1 decrement 10 //调用跟踪事件1,发现上行链路down后优先级会减10
vrrp 20 priority 105
no sh
!
int vlan 30
ip address 192.168.30.253 255.255.255.0
vrrp 30 ip 192.168.30.254
no sh
!
int vlan 40
ip address 192.168.40.253 255.255.255.0
vrrp 40 ip 192.168.40.254
vrrp 40 track 1 decrement 10 //调用跟踪事件1,发现上行链路down后优先级会减10
vrrp 40 priority 105
no sh
!
HJ-1
配置e0/1端口ip
interface e0/1
no switchport //开启三层功能
ip address 192.168.99.2 255.255.255.252
no sh
如果是三层交换机的话,可以用到此命令。
三层交换机是带有三层路由功能的交换机,也就是这台交换机的端口既有三层路由功能,也具有二层交换功能。三层交换机端口默认为二层口,如果需要启用三层功能就需要在此端口输入no switchport命令。如果是二层交换机就不会用到no switchport命令.
HJ-2
配置e0/1端口ip
interface e0/1
no switchport //开启三层功能
ip address 192.168.99.6 255.255.255.252
no sh
core
ip routing //开启路由功能
!
interface e0/0
no switchport //开启三层功能
ip address 192.168.99.1 255.255.255.252
no sh
interface e0/1
no switchport
ip address 192.168.99.5 255.255.255.252
no sh
!
int loopback 0 //配置环回口
ip add 1.1.1.1 255.255.255.0
no sh
配置充当PC的四台路由器IP及ospf
pc1
interface e0/0
ip address 192.168.10.10 255.255.255.0
no sh
exit
ip default-gateway 192.168.10.252 //设置默认网关
!
router ospf 100 //配置ospf
network 192.168.10.0 0.0.0.255 area 0
-------------------------------------
pc2
interface e0/0
ip address 192.168.20.20 255.255.255.0
no sh
exit
ip default-gateway 192.168.20.252 //设置默认网关
!
router ospf 100 //配置ospf
network 192.168.20.0 0.0.0.255 area 0
---------------------------------------------
pc3
interface e0/0
ip address 192.168.30.30 255.255.255.0
no sh
exit
ip default-gateway 192.168.30.252 //设置默认网关
!
router ospf 100 //配置ospf
network 192.168.30.0 0.0.0.255 area 0
-------------------------------------------
pc4
interface e0/0
ip address 192.168.40.40 255.255.255.0
no sh
exit
ip default-gateway 192.168.40.252 //设置默认网关
!
router ospf 100 //配置ospf
network 192.168.40.0 0.0.0.255 area 0
HJ-1
配置HJ-1的OSPf
router ospf 100
network 192.168.10.0 0.0.0.255 area 0
network 192.168.20.0 0.0.0.255 area 0
network 192.168.30.0 0.0.0.255 area 0
network 192.168.40.0 0.0.0.255 area 0
network 192.168.99.0 0.0.0.3 area 0
HJ-2
配置HJ-2的OSPf
router ospf 100
network 192.168.10.0 0.0.0.255 area 0
network 192.168.20.0 0.0.0.255 area 0
network 192.168.30.0 0.0.0.255 area 0
network 192.168.40.0 0.0.0.255 area 0
network 192.168.99.0 0.0.0.3 area 0
core
配置core的OSPf
router ospf 100
network 1.1.1.0 0.0.0.255 area 0
network 192.168.99.0 0.0.0.3 area 0
show ip route查看路由表
core
HJ-1
HJ-2
core核心连通ping测试
ping各个部门测试
测试主备切换功能
当vlan20 master VRRP2(HJ-2) down机后,网络出现一定延时丢包,但很快恢复
将vlan 20down掉
快速切换查看,发现五个包丢了一个包,不过后面就马上切换正常