检测状态指令
1)ping 222.134.53.102 -c5
PING 222.134.53.102 (222.134.53.102) 56(84) bytes of data.
64 bytes from 222.134.53.102: icmp_seq=0 ttl=61 time=2.23 ms
64 bytes from 222.134.53.102: icmp_seq=1 ttl=61 time=2.10 ms
64 bytes from 222.134.53.102: icmp_seq=2 ttl=61 time=2.91 ms
64 bytes from 222.134.53.102: icmp_seq=3 ttl=61 time=2.91 ms
64 bytes from 222.134.53.102: icmp_seq=4 ttl=61 time=2.91 ms
--- 222.134.53.102 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3999ms
#如果time<200 并且 packet loss < 20%那么statusA =1
否则statusA =0
2)ping 219.146.0.130 -c5
ping 219.146.0.130
PING 219.146.0.130 (219.146.0.130) 56(84) bytes of data.
64 bytes from 219.146.0.130: icmp_seq=0 ttl=243 time=6.3 ms
64 bytes from 219.146.0.130: icmp_seq=1 ttl=243 time=6.4 ms
64 bytes from 219.146.0.130: icmp_seq=2 ttl=243 time=6.2 ms
64 bytes from 219.146.0.130: icmp_seq=3 ttl=243 time=6.5 ms
64 bytes from 219.146.0.130: icmp_seq=4 ttl=243 time=6.5 ms
#如果time<200 并且 packet loss < 20%那么statusB =1
否则statusB =0
路由表脚本
default #默认路由表
ip route replace 222.240.0.0/13 via 222.174.245.5
ip route replace 0/0 via 119.185.0.3
chgcnc #因为电信不正常,切换至网通路由
ip route replace 222.240.0.0/13 via 119.185.0.3
chgtel #因为电信正常,切换电信路由
ip route replace 222.240.0.0/13 via 222.174.245.5
chgcncdf #更改默认路由至网通
ip route replace 0/0 via 119.185.0.3
chgteldf #更改默认路由至电信
ip route replace 0/0 via 119.185.0.3
网关文件 gatecnc gate tel
cat gatecnc
119.185.0.3
cat gatetel
222.174.245.5
检测路由状态指令
route -F
121.204.0.0 119.185.0.3 255.252.0.0 UG 0 0 0 eth1
222.240.0.0 119.185.0.3 255.224.0.0 UG 0 0 0 eth1
60.160.0.0 119.185.0.3 255.224.0.0 UG 0 0 0 eth1
default 119.185.0.3 0.0.0.0 UG 0 0 0 eth1