HSRP热备份路由


如图

wKioL1nnCnagiOf3AAHuTo8qVLs369.png

做不同vlan的热备份路由

PC1 vlan1 ; PC2 vlan2

SW1:

enable 

configure terminal

hostname SW1

no ip domain lookup

vlan 2

vlan 3

vlan10

vlan11

exit

interface fastethernet 0/1

switchport mode access 

switchport access vlan 2   

interface fastethernet 0/2

switchport mode access 

switchport access vlan 3

interface fastethernet 0/3

switchport mode trunk

interface fastethernet 0/4

switchport mode trunk

exit


show interfaces trunk

show vlan brief


省略了一些常规操作

SW2:

ip routing

spanning-tree vlan 1 root primary

spanning-tree vlan 2 root primary  #设置优先级成为vlan2的根交换机

spanning-tree vlan 10 root primary

interface vlan 2

ip address 192.168.1.2 255.255.255.0

standby 1 ip 192.168.1.100

standby 1 preempt

standby 1 priority 200 #默认100 越大优先级高 成为vlan 2主路由设备

interface vlan 3

ip address 192.168.2.2 255.255.255.0

standby 2 ip 192.168.2.100

standby 2 preempt 

interface fastethernet 0/1

switchport trunk encapsulation dot1q

switchport mode trunk 


show ip interface brief

show vlan brief

show spanning-tree

show standby 


SW3:

ip routing

spanning-tree vlan 3 root primary #设置优先级成为vlan3的根交换机

spanning-tree vlan 11 root primary

interface vlan 2     #SVI

ip address 192.168.1.3 255.255.255.0

standby 1 ip 192.168.1.100

standby 1 preempt

interface vlan 3

ip address 192.168.2.3 255.255.255.0

standby 2 ip 192.168.2.100

standby 2 preempt 

standby 2 priority 200   #默认100 越大优先级高 成为vlan 3主路由设备

interface fastethernet 0/2

switchport trunk encapsulation dot1q

switchport mode trunk 


在 SW2 与 SW3 上配置 HSRP 链路跟踪(必须要做)

SW2: 

interface vlan 2

standby 2 track fastethernet 0/2 priority 150   #此为实际命令 模拟器不全

SW3:

interface vlan 3

standby 3 track fastethernet 0/2 priority 150


路由

SW2:

interface vlan 10

ip address 192.168.10.1 255.255.255.0

exit

ip route 192.168.100.0 255.255.255.0 192.168.10.2

SW3:

interface vlan 11

ip address 192.168.20.1 255.255.255.0

exit

ip route 192.168.100.0 255.255.255.0 192.168.20.2


show ip interface brief

show ip route


R1

interface gig0/0

ip address 192.168.10.2 255.255.255.0

interface gig0/1

ip address 192.168.20.2 255.255.255.0

interface loopback 0 

ip address 192.168.100.1 255.255.255.0

exit

ip route 192.168.0.0 255.255.0.0 192.168.10.1

ip route 192.168.0.0 255.255.0.0 192.168.20.1


ping 测试