=====================配置==========================
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.255
interface FastEthernet1/0
ip address 10.1.1.1 255.255.255.0
ip route 0.0.0.0 0.0.0.0 10.1.1.254
ISP1.CE:
track 1 ip sla 1 reachability //追踪sla 1 的可达性
interface FastEthernet1/0
ip address 10.1.1.251 255.255.255.0
ip nat inside
ip nat enable
ip virtual-reassembly in
standby delay reload 120
standby 1 ip 10.1.1.254
standby 1 priority 105
standby 1 preempt
standby 1 authentication md5 key-string cisco
standby 1 name HA
duplex auto
speed auto
!
interface FastEthernet1/1
ip address 202.1.1.1 255.255.255.0
ip nat outside
ip virtual-reassembly in
duplex auto
speed auto
!
ip nat source list pat interface FastEthernet1/1 overload
ip route 0.0.0.0 0.0.0.0 202.1.1.2 track 1 //track默认路由
ip route 0.0.0.0 0.0.0.0 202.1.1.2
ip route 1.1.1.1 255.255.255.255 10.1.1.1
!
ip access-list extended pat
permit ip host 1.1.1.1 any
!
ip sla 1 //配置sla
icmp-echo 202.1.1.2 source-ip 202.1.1.1
timeout 2
frequency 10
ip sla schedule 1 life forever start-time now
!
event manager applet isp1 //配置EEM
event syslog occurs 1 pattern "ip sla 1 reachability Up->Down"
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "int f1/0"
action 4 cli command "shutdown"
action 5 mail server "192.168.1.1" to "[email protected]" from "[email protected]" subject "The ISP1 is Unreachable"
event manager applet ISP1-UP
event syslog occurs 1 pattern "ip sla 1 reachability Down->Up"
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "int f1/0"
action 4 cli command "no shutdown"
action 5 mail server "192.168.1.1" to "[email protected]" from "[email protected]" subject "The ISP1 is Up"
ISP2.CE:
track 1 ip sla 1 reachability
interface FastEthernet1/0
ip address 10.1.1.250 255.255.255.0
ip nat inside
ip nat enable
ip virtual-reassembly in
standby delay reload 120
standby 1 ip 10.1.1.254
standby 1 preempt
standby 1 authentication md5 key-string cisco
standby 1 name HA
duplex auto
speed auto
!
interface FastEthernet1/1
ip address 64.1.1.1 255.255.255.0
ip nat outside
ip nat enable
ip virtual-reassembly in
duplex auto
speed auto
ip nat source list pat interface FastEthernet1/1 overload
ip route 0.0.0.0 0.0.0.0 64.1.1.2 track 1
ip route 0.0.0.0 0.0.0.0 64.1.1.2
!
ip access-list extended pat
permit ip host 1.1.1.1 any
!
ip sla 1
icmp-echo 64.1.1.2 source-ip 64.1.1.1
timeout 2
frequency 10
ip sla schedule 1 life forever start-time now
event manager applet ISP2
event syslog occurs 1 pattern "ip sla 1 reachability Up->Down"
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "int f1/0"
action 4 cli command "shutdown"
action 5 mail server "192.168.1.1" to "[email protected]" from "[email protected]" subject "The ISP2 is Unreachable"
event manager applet ISP2-UP
event syslog occurs 1 pattern "ip sla 1 reachability Down->Up"
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "int f1/0"
action 4 cli command "no shutdown"
action 5 mail server "192.168.1.1" to "1@2gmail" from "[email protected]" subject "The ISP2 is Up"
ISP1.PE:
interface FastEthernet1/0
ip address 202.1.1.2 255.255.255.0
duplex auto
speed auto
interface FastEthernet1/1
ip address 10.1.2.2 255.255.255.0
duplex auto
speed auto
ip route 0.0.0.0 0.0.0.0 202.1.1.1
ip route 2.2.2.2 255.255.255.255 10.1.2.10
ISP2.PE:
interface FastEthernet1/0
ip address 64.1.1.2 255.255.255.0
duplex auto
speed auto
interface FastEthernet1/1
ip address 10.1.2.1 255.255.255.0
duplex auto
speed auto
ip route 0.0.0.0 0.0.0.0 64.1.1.1
ip route 2.2.2.2 255.255.255.255 10.1.2.10
R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.255
interface FastEthernet1/0
ip address 10.1.2.10 255.255.255.0
duplex auto
speed auto
ip route 0.0.0.0 0.0.0.0 10.1.2.1
ip route 0.0.0.0 0.0.0.0 10.1.2.2
测试:
R1 PING R2
走的是202.1.1.2(ISP1)
ISP1.PE shutdown接口
ISP1.CE 探测到ISP1.PE接口DOWN并且自动关闭了f1/0接口
ISP2.CE的HSRP切换成为Active
现在流量走的是64.1.1.2(ISP2)
ISP1.PE 重新打开接口
ISP1.CE探测到ISP1.PE接口开启并且开启了f1/0接口,HSRP状态切换为Active
快速切换
现在流量重新走回ISP1