断线重拨脚本
时间:2010-03-10 来源:wangchenxicool
#!/bin/sh
while true; do
ping -w1 news.sina.com.cn >/dev/null 2>&1 || ( killall pppd; date; service pppd restart )
sleep 120
done #!/bin/sh
#自动拨号脚本由本人制作QQ:12956620
#请把dns1,dns2修改成拼得通的DNS,开机自动运行,实时监控,断线自动重拨
dns1="211.95.193.97"
dns2="211.136.20.203"
sleep 8
/bin/pppd call gprs-siem &
sleep 12
while true
do
ping -s 1 -c 1 $dns1 ……去PING第一个DNS
if [ "$?" != "0" ] ……假如PING不通
then
ping -s 1 -c 2 $dns2 ……去PING第二个DNS
if [ "$?" != "0" ] ……假如PING不通
then
killall pppd ……结束PPPD进程
pppd call gprs-siem & ……再去拨号
sleep 12 ……等待12秒
else
sleep 5 ……如果是PING DNS2通的话就直接等待5秒
fi
else
sleep 5 ……如果是PING DNS1通的话就直接等待5秒(一般要设置多长时间去PING请改这里)
fi
done
代码简明!!它相当于在后台时时去PING一个DNS发现真正地掉线,它才会去重新拨号!!此版本经测试通过才发表。
**************************
* *
* The Gemini Project *
* *
**************************
welcome on your dreambox! - Kernel 2.6.9 (08:14:21).
dreambox login: root
Password:
BusyBox v1.01 (2007.10.23-19:23+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
root@dreambox:~> /bin/sh /var/etc/ppp/aa
root@dreambox:~> AT
OK
ATZ
OK
ATH
OK
ATE1
OK
AT+CGDCONT=1,"IP","cmnet"
OK
ATD*99***1#
CONNECT
Serial connection established.
using channel 2
Using interface ppp0
Connect: ppp0 <--> /dev/tts/0
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
sent [LCP ConfReq id=0x1 <asyncmap 0x20a0000> <magic 0x7ec573c> <pcomp> <accomp>
]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x20a0000> <magic 0x7ec573c> <pcomp> <accomp>
]
rcvd [LCP ConfReq id=0x3 <asyncmap 0xa0000> <pcomp> <accomp> <magic 0x2ab30537>
<auth chap MD5>]
sent [LCP ConfNak id=0x3 <auth pap>]
rcvd [LCP ConfReq id=0x5 <asyncmap 0xa0000> <pcomp> <accomp> <magic 0x2ab30537>
<auth pap>]
sent [LCP ConfAck id=0x5 <asyncmap 0xa0000> <pcomp> <accomp> <magic 0x2ab30537>
<auth pap>]
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
sent [PAP AuthReq id=0x1 user="beeline" password=<hidden>]
rcvd [PAP AuthAck id=0x1 ""]
PAP authentication succeeded
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [LCP ProtRej id=0x6 80 fd 01 01 00 0f 1a 04 78 00 18 04 78]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275420253.8 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275420253.8/275420253.8/275420253.8 ms
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275425386.3 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275425386.3/275425386.3/275425386.3 ms
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275430517.7 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275430517.7/275430517.7/275430517.7 ms
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275435653.2 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275435653.2/275435653.2/275435653.2 ms
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275440784.9 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275440784.9/275440784.9/275440784.9 ms
IPCP: timeout sending Config-Requests
sent [LCP TermReq id=0x2 "No network protocols running"]
rcvd [LCP TermAck id=0x2 "No network protocols running"]
Connection terminated.
Sending break to the modem
PDP context detached
Serial link disconnected.
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275445915.2 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275445915.2/275445915.2/275445915.2 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275451048.9 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275451048.9/275451048.9/275451048.9 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275456180.4 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275456180.4/275456180.4/275456180.4 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275461314.4 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275461314.4/275461314.4/275461314.4 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275466446.2 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275466446.2/275466446.2/275466446.2 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275471577.9 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275471577.9/275471577.9/275471577.9 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275476708.1 ms
while true; do
ping -w1 news.sina.com.cn >/dev/null 2>&1 || ( killall pppd; date; service pppd restart )
sleep 120
done #!/bin/sh
#自动拨号脚本由本人制作QQ:12956620
#请把dns1,dns2修改成拼得通的DNS,开机自动运行,实时监控,断线自动重拨
dns1="211.95.193.97"
dns2="211.136.20.203"
sleep 8
/bin/pppd call gprs-siem &
sleep 12
while true
do
ping -s 1 -c 1 $dns1 ……去PING第一个DNS
if [ "$?" != "0" ] ……假如PING不通
then
ping -s 1 -c 2 $dns2 ……去PING第二个DNS
if [ "$?" != "0" ] ……假如PING不通
then
killall pppd ……结束PPPD进程
pppd call gprs-siem & ……再去拨号
sleep 12 ……等待12秒
else
sleep 5 ……如果是PING DNS2通的话就直接等待5秒
fi
else
sleep 5 ……如果是PING DNS1通的话就直接等待5秒(一般要设置多长时间去PING请改这里)
fi
done
代码简明!!它相当于在后台时时去PING一个DNS发现真正地掉线,它才会去重新拨号!!此版本经测试通过才发表。
**************************
* *
* The Gemini Project *
* *
**************************
welcome on your dreambox! - Kernel 2.6.9 (08:14:21).
dreambox login: root
Password:
BusyBox v1.01 (2007.10.23-19:23+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
root@dreambox:~> /bin/sh /var/etc/ppp/aa
root@dreambox:~> AT
OK
ATZ
OK
ATH
OK
ATE1
OK
AT+CGDCONT=1,"IP","cmnet"
OK
ATD*99***1#
CONNECT
Serial connection established.
using channel 2
Using interface ppp0
Connect: ppp0 <--> /dev/tts/0
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
sent [LCP ConfReq id=0x1 <asyncmap 0x20a0000> <magic 0x7ec573c> <pcomp> <accomp>
]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x20a0000> <magic 0x7ec573c> <pcomp> <accomp>
]
rcvd [LCP ConfReq id=0x3 <asyncmap 0xa0000> <pcomp> <accomp> <magic 0x2ab30537>
<auth chap MD5>]
sent [LCP ConfNak id=0x3 <auth pap>]
rcvd [LCP ConfReq id=0x5 <asyncmap 0xa0000> <pcomp> <accomp> <magic 0x2ab30537>
<auth pap>]
sent [LCP ConfAck id=0x5 <asyncmap 0xa0000> <pcomp> <accomp> <magic 0x2ab30537>
<auth pap>]
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
sent [PAP AuthReq id=0x1 user="beeline" password=<hidden>]
rcvd [PAP AuthAck id=0x1 ""]
PAP authentication succeeded
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [LCP ProtRej id=0x6 80 fd 01 01 00 0f 1a 04 78 00 18 04 78]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275420253.8 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275420253.8/275420253.8/275420253.8 ms
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275425386.3 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275425386.3/275425386.3/275425386.3 ms
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275430517.7 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275430517.7/275430517.7/275430517.7 ms
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275435653.2 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275435653.2/275435653.2/275435653.2 ms
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275440784.9 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275440784.9/275440784.9/275440784.9 ms
IPCP: timeout sending Config-Requests
sent [LCP TermReq id=0x2 "No network protocols running"]
rcvd [LCP TermAck id=0x2 "No network protocols running"]
Connection terminated.
Sending break to the modem
PDP context detached
Serial link disconnected.
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275445915.2 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275445915.2/275445915.2/275445915.2 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275451048.9 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275451048.9/275451048.9/275451048.9 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275456180.4 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275456180.4/275456180.4/275456180.4 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275461314.4 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275461314.4/275461314.4/275461314.4 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275466446.2 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275466446.2/275466446.2/275466446.2 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275471577.9 ms
--- 211.95.193.97 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 275471577.9/275471577.9/275471577.9 ms
PING 211.95.193.97 (211.95.193.97): 1 data bytes
9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275476708.1 ms
相关阅读 更多 +