实验拓扑
目标
- pc能够访问1.1.1.1
- 使用vrrp冗余
- 当线路出现故障,切换vrrp主备
配置
vpc
ip 192.168.1.10 255.255.255.0 192.168.1.254
sw
Switch>enable
Switch#conf terminal
Switch(config)#vlan 10
Switch(config)#interface e0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config)#interface range e0/0-1
Switch(config-if-range)#switchport trunk encapsulation dot1q
Switch(config-if-range)#switchport mode trunk
Switch(config-if-range)#switchport trunk allowed vlan 10
R1
Router>enable
Router#conf terminal
Router(config)#interface ethernet 0/0
Router(config-if)#ip address 12.1.1.1 255.255.255.252
Router(config-if)# no shutdown
Router(config)#interface ethernet 0/1
Router(config-if)# no shutdown
Router(config)# interface ethernet 0/1.10
Router(config-if)# encapsulation dot1Q 10
Router(config-if)# ip address 192.168.1.252 255.255.255.0
Router(config-if)# vrrp 10 ip 192.168.1.254
Router(config-if)# vrrp 10 priority 120
Router(config-if)# vrrp 10 track 10 decrement 20
Router(config)#ip sla 10
Router(config)#icmp-echo 1.1.1.1 source-interface Ethernet0/0
Router(config)#frequency 5
Router(config)#ip sla schedule 10 life forever start-time now
Router(config)#track 10 ip sla 10
Router(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.2
R2
Router>enable
Router#conf terminal
Router(config)#interface ethernet 0/0
Router(config-if)#ip address 12.1.1.6 255.255.255.252
Router(config-if)# no shutdown
Router(config)#interface ethernet 0/1
Router(config-if)# no shutdown
Router(config)# interface ethernet 0/1.10
Router(config-if)# encapsulation dot1Q 10
Router(config-if)# ip address 192.168.1.253 255.255.255.0
Router(config-if)# vrrp 10 ip 192.168.1.254
Router(config-if)# vrrp 10 priority 110
Router(config-if)# vrrp 10 track 10 decrement 20
Router(config)#ip sla 10
Router(config)#icmp-echo 1.1.1.1 source-interface Ethernet0/0
Router(config)#frequency 5
Router(config)#ip sla schedule 10 life forever start-time now
Router(config)#track 10 ip sla 10
Router(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.5
R3
Router>enable
Router#conf terminal
Router(config)#interface ethernet 0/0
Router(config-if)#ip address 12.1.1.2 255.255.255.252
Router(config-if)# no shutdown
Router(config)#interface ethernet 0/1
Router(config-if)#ip address 12.1.1.5 255.255.255.252
Router(config-if)# no shutdown
Router(config)# interface Loopback0
Router(config-if)# ip address 1.1.1.1 255.255.255.255
Router(config)#ip route 192.168.1.0 255.255.255.0 12.1.1.1
Router(config)#ip route 192.168.1.0 255.255.255.0 12.1.1.6
测试
链路正常时
手动关闭 R1 的e0/0接口