1、实验目的
掌握HSRP的操作
2、拓扑与需求
拓扑:
需求:
- SW14之间的线路均配置为Trunk,封装协议为802.1Q,SW12上创建VLAN 10、20,并按拓扑图配置SVI接口的IP地址,SW3将接口E0/0划分至VLAN 10,SW4将接口E0/0划分至VLAN 20;
- SW1和SW2的SVI 10共同虚拟HSRP组10,虚拟IP为192.168.10.254,SW1的优先级设置为最大,SW2采用默认优先级,均开启抢占功能;
- SW1和SW2的SVI 20共同虚拟HSRP组20,虚拟IP为192.168.20.254,SW1采用默认优先级,SW2的优先级设置为最大,均开启抢占功能;
3、配置与实现
- SW14之间的线路均配置为Trunk,封装协议为802.1Q,SW12上创建VLAN 10、20,并按拓扑图配置SVI接口的IP地址,SW3将接口E0/0划分至VLAN 10,SW4将接口E0/0划分至VLAN 20;
SW1
SW1(config)#interface range ethernet 0/0-2
SW1(config-if-range)#switchport trunk encapsulation dot1q
SW1(config-if-range)#switchport mode trunk
SW1(config-if-range)#vlan 10,20
SW1(config-vlan)#interface vlan 10
SW1(config-if)#ip address 192.168.10.252 255.255.255.0
SW1(config-if)#no shutdown
SW1(config-if)#interface vlan 20
SW1(config-if)#ip address 192.168.20.252 255.255.255.0
SW1(config-if)#no shutdown
SW2
SW2(config)#interface range ethernet 0/0-2
SW2(config-if-range)#switchport trunk encapsulation dot1q
SW2(config-if-range)#switchport mode trunk
SW2(config-if-range)#vlan 10,20
SW2(config-vlan)#interface vlan 10
SW2(config-if)#ip address 192.168.10.253 255.255.255.0
SW2(config-if)#no shutdown
SW2(config-if)#interface vlan 20
SW2(config-if)#ip address 192.168.20.253 255.255.255.0
SW2(config-if)#no shutdown
SW3
SW3(config)#interface range ethernet 0/1-2
SW3(config-if-range)#switchport trunk encapsulation dot1q
SW3(config-if-range)#switchport mode trunk
SW3(config)#interface ethernet 0/0
SW3(config-if)#switchport mode access
SW3(config-if)#switchport access vlan 10
% Access VLAN does not exist. Creating vlan 10
SW4
SW4(config)#interface range ethernet 0/1-2
SW4(config-if-range)#switchport trunk encapsulation dot1q
SW4(config-if-range)#switchport mode trunk
SW4(config)#interface ethernet 0/0
SW4(config-if)#switchport mode access
SW4(config-if)#switchport access vlan 20
% Access VLAN does not exist. Creating vlan 20
- SW1和SW2的SVI 10共同虚拟HSRP组10,虚拟IP为192.168.10.254,SW1的优先级设置为最大,SW2采用默认优先级,均开启抢占功能;
SW1
SW1(config-if)#interface vlan 10
SW1(config-if)#standby 10 ip 192.168.10.254
SW1(config-if)#standby 10 priority 255
SW1(config-if)#standby 10 preempt
SW2
SW2(config-if)#interface vlan 10
SW2(config-if)#standby 10 ip 192.168.10.254
SW2(config-if)#standby 10 preempt
3. SW1和SW2的SVI 20共同虚拟HSRP组20,虚拟IP为192.168.20.254,SW1采用默认优先级,SW2的优先级设置为最大,均开启抢占功能;
SW1
SW1(config-if)#interface vlan 20
SW1(config-if)#standby 20 ip 192.168.20.254
SW1(config-if)#standby 20 preempt
SW2
SW2(config-if)#interface vlan 20
SW2(config-if)#standby 20 ip 192.168.20.254
SW2(config-if)#standby 20 priority 255
SW2(config-if)#standby 20 preempt