故障分析:公司办公室的adsl爱掉线,一掉的话网关的gateway就没了,下列脚本应此而生,几天过去了,效果不错,全自动的:
route.sh
- #!/bin/bash
- while :
- do
- if route | tail -l | grep "0.0.0.0"
- then
- &>/dev/null
- else
- adsl-stop
- adsl-start
- fi
- sleep 10
- done
执行脚本方法 nuhup sh route.sh &,注意前面要用上nohup,这样避免root用户logout时此脚本也退出生效的问题