本人原创文章
原文链接: http://bbs.csc-china.com.cn/forum.php?mod=viewthread&tid=988613
2018-12-28 17:20:30 发表在 思科中文社区
拓扑:
ip sla topo.png
需求:
默认情况内网流量走10.x.x.1路由器,外网流量走10.x.x.2路由器;
如果.1线路Down,内网流量会切换到.2线路;
如果.2线路Down,外网流量会切换到.1线路.
示例及说明:
ip sla 80
icmp-echoA.A.A.A
frequency Z
track 180 ip sla 180 reachability
delay down X up Y
注意:
Z代表的是每隔多长时间IP SLA探测一次;
如果到目标A.A.A.A的ICMP某次探测超时(超时时间是由timeout设置,此处为5秒),从此时起,到TRACK 180 Down需要经过"5秒+X秒";
在这期间,如果某次探测成功,则TRACK 180 不会Down;
如果IP SLA某次探测超时,且在随后的(5+X)秒内的探测都是超时,则在距离第一次探测超时(5+X)秒后,宣布"%TRACK-6-STATE: 180 ip sla 180 reachability Up ->Down";
如果TRACK 180 Down之后,IP SLA在某次探测不超时,则再经历Y秒后,宣布"%TRACK-6-STATE: 180 ip sla 180 reachability Down-> Up";
也就是说如果某条运营商线路确实有问题,路由切换前网络中断的时间范围是: (5+X)~(Z+(5+X))秒,即(5+X)~(5+X+Z)秒.
//运营商线路故障后瞬间,刚好探测(5+X);刚刚探测完,运营商线路故障了,需要多等Z秒才能触发下一次IP SLA的探测,才能进入这个判断
//运营商线路恢复后,到A.A.A.A的连通性恢复后,需要经过(Y)~(Z+Y)秒切回原线路
//细节上对于网络中断的时间可能存在一些小问题,追求极致的同学可以自行补充.
完整命令:
ip sla 180
icmp-echo A.A.A.A
frequency 20
ip sla schedule 80life forever start-time now
ip sla 181
icmp-echo B.B.B.B
frequency 20
ip sla schedule 81life forever start-time now
!
track 180 ip sla 180 reachability
delay down 70 up 30
track 181 ip sla 181 reachability
delay down 70 up 30
!
ip route 10.0.0.0 255.0.0.0 10.x.x.1 100 name lan-out track 180
ip route 0.0.0.0 0.0.0.0 10.x.x.2 100 name wan-out track 181
ip route 0.0.0.0 0.0.0.0 10.x.x.1 200
ip route 10.0.0.0255.0.0.0 10.x.x.2 200
ip route A.A.A.A 255.255.255.255 10.x.x.1
ip route B.B.B.B 255.255.255.255 10.x.x.2
官方文档说明:
Command | Purpose |
---|---|
delay {up seconds [down seconds] | [up seconds] down seconds} | (Optional) Specify a period of time in seconds to delay communicating state changes of a tracked object. The range is from 1 to 180 seconds. |