HSRP和VRRP實戰
拓撲圖:
HSRP 是熱備份路由協議,思科專有。通過 HSRP,一組路由器可以一起協同工作,來代 表一臺虛擬路由器,備份組像一臺路由器一樣工作,一個虛擬 IP 地址和 MAC 地址,從末端 主機來看,虛擬主路由器是一臺有自己 IP 地址和 MAC 地址的路由器,它不同於實際物理路 由器,那麼該組中一臺路由器失效則另一臺路由器接替工作,路由選擇照常。
VRRP將局域網的一組路由器構成一個備份組,相當於一臺虛擬路由器。局域網內的主機只需要知道這個虛擬路由器的IP地址,並不需知道具體某臺設備的IP地址,將網絡內主機的缺省網關設置爲該虛擬路由器的IP地址,主機就可以利用該虛擬網關與外部網絡進行通信。
VRRP將該虛擬路由器動態關聯到承擔傳輸業務的物理路由器上,當該物理路由器出現故障時,再次選擇新路由器來接替業務傳輸工作,整個過程對用戶完全透明,實現了內部網絡和外部網絡不間斷通信。
實驗要求:
1. C1是VLAN 10成員,C2是VLAN 20的成員;
2. C1流量默認通過R2走,C2流量默認通過R3走;
3. 通過C1使用HSRP實現冗餘,C2通過VRRP實現;
4. 使用動態路由協議配置該圖;
5. 使用R1環回口倒換測試。
配置:
路由器 | 接口 | Ip地址 |
R1 | 0/0 | 12.0.0.1 |
R1 | 0/1 | 13.0.0.1 |
R1 | Loopback 0 | 1.1.1.1 |
R2 | 1/0 | 12.0.0.2 |
R2 | 0/1 | 23.0.0.2 |
R2 | 0/0.10 | 192.168.10.1 |
R2 | 0/0.20 | 192.168.20.1 |
R3 | 0/0 | 13.0.0.3 |
R3 | 0/1 | 23.0.0.3 |
R3 | VLAN 10 | 192.168.10.2 |
R3 | VLAN 20 | 192.168.20.2 |
R1
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int fa0/0
R1(config-if)#ip add 12.0.0.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int loo 0
R1(config-if)#ip add 1.1.1.1 255.255.255.0 環回口
R1(config-if)#no shut
R1(config-if)#int fa0/1
R1(config-if)#ip add 13.0.0.1 255.255.255.0
R1(config-if)#no shut
R1(config)#router rip rip協議
R1(config-router)#version 2
R1(config-router)#no auto-summary
R1(config-router)#net 12.0.0.0
R1(config-router)#net 13.0.0.0
R1(config-router)#net 1.1.1.0
R2
R2(config)#int fa1/0
R2(config-if)#no switchport
R2(config-if)#ip add 12.0.0.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int fa0/1
R2(config-if)#ip add 23.0.0.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int fa0/0
R2(config-if)#int fa0/0.10
R2(config-subif)#encapsulation dot1Q 10
R2(config-subif)#ip add 192.168.10.1 255.255.255.0 VLAN 10 做網關
R2(config-subif)#no shut
R2(config-subif)#int fa0/0.20
R2(config-subif)#encapsulation dot1Q 20
R2(config-subif)#ip add 192.168.20.1 255.255.255.0 VLAN 20 做網關
R2(config-subif)#no shut
R2(config-subif)#exit
R2(config)#router r rip協議
R2(config-router)#version 2
R2(config-router)#no auto-summary
R2(config-router)#net 12.0.0.0
R2(config-router)#net 23.0.0.0
R2(config-router)#net 192.168.10.0
R2(config-router)#net 192.168.20.0
R2(config-router)#
R3
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int fa0/0
R3(config-if)#ip add 13.0.0.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#int fa0/1
R3(config-if)#ip add 23.0.0.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#vlan 10,20 添加vlan
R3(config-vlan)#int vlan 10
R3(config-if)#ip add 192.168.10.2 255.255.255.0
R3(config-if)#int vlan 20
R3(config-if)#ip add 192.168.20.2 255.255.255.0
R3(config-if)#no shut
R3(config-if)#int fa1/15
R3(config-if)#switchport mode trunk 中繼口
R3(config-if)#exit
R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#net 13.0.0.0
R3(config-router)#net 23.0.0.0
R3(config-router)#net 192.168.10.0
R3(config-router)#net 192.168.20.0
R3(config-router)#
SW1
sw1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw1(config)#no ip routing 關閉路由功能
sw1(config)#vlan 10,20 添加vlan
sw1(config-vlan)#int fa1/1
sw1(config-if)#switchport access vlan 10
sw1(config-vlan)#int fa1/2
sw1(config-if)#switchport access vlan 20
sw1(config-if)#int ran fa1/14 -15 上行口
sw1(config-if-range)#switchport mode trunk 中繼口
sw1(config-if-range)#
sw1(config-if-range)#
下面開始做hsrp和vrrp R3用vrrp R2 用hsrp
R2(config)#int fa0/0.10
R2(config-subif)#standby 1 ip 192.168.10.254
R2(config-subif)#standby 1 preempt 搶佔
不用配置優先級,默認是100
R2(config-subif)#standby 1 track fa1/0 上行口配不配置無所謂
R2(config-subif)#
R3(config)#
R3(config)#int vlan 10
R3(config-if)#standby 1 ip 192.168.10.254
R3(config-if)#standby 1 preempt
R3(config-if)#standby 1 priority 95
R3(config-if)#do ping 192.168.10.1
R3(config-if)#exit
R3#show standby brief
R3(config)#track 1 interface fa0/0 line-protocol
R3(config-track)#exit
R3(config)#int vlan 20
R3(config-if)#vrrp 1 ip 192.168.20.254
R3(config-if)#vrrp 1 preempt 搶佔
R3(config-if)#vrrp 1 track 1 跟蹤上型口
R2(config-subif)#vrrp 1 ip 192.168.20.254
R2(config-subif)#vrrp 1 preempt
R2(config-subif)#vrrp 1 priority 95
R2#show vrrp brief
下面開始做倒換測試
C1配置
在r1倒換測試
把R1 fa0/0和R2 fa1/0 shut
在pc1 trace 1.1.1.1
把R1fa 0/0和R2 fa1/0 no shut
在PC1 track 1.1.1.1