脚本如下:auto_pppd.sh
#!/bin/shwhile true;do ping -w1 news.sina.com.cn >/dev/null 2>&1 || ( killall pppd; date; pppd call ls-gprs &) sleep 20 #每20秒检测一次done
可以放在开机脚本
auto_pppd.sh
#!/bin/sh#扩展#dns1="211.95.193.97"dns2="211.136.20.203"sleep 8/bin/pppd call gprs-siem &sleep 12while truedo 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: rootPassword: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/aaroot@dreambox:~> ATOKATZOKATHOKATE1OKAT+CGDCONT=1,"IP","cmnet"OKATD*99***1#CONNECTSerial connection established.using channel 2Using interface ppp0Connect: ppp0 <--> /dev/tts/0Warning - secret file /etc/ppp/pap-secrets has world and/or group accesssent [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 accesssent [PAP AuthReq id=0x1 user="beeline" password=<hidden>]rcvd [PAP AuthAck id=0x1 ""]PAP authentication succeededsent [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 bytes9 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 lossround-trip min/avg/max = 275420253.8/275420253.8/275420253.8 mssent [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 bytes9 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 lossround-trip min/avg/max = 275425386.3/275425386.3/275425386.3 mssent [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 bytes9 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 lossround-trip min/avg/max = 275430517.7/275430517.7/275430517.7 mssent [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 bytes9 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 lossround-trip min/avg/max = 275435653.2/275435653.2/275435653.2 mssent [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 bytes9 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 lossround-trip min/avg/max = 275440784.9/275440784.9/275440784.9 msIPCP: timeout sending Config-Requestssent [LCP TermReq id=0x2 "No network protocols running"]rcvd [LCP TermAck id=0x2 "No network protocols running"]Connection terminated.Sending break to the modemPDP context detachedSerial link disconnected.PING 211.95.193.97 (211.95.193.97): 1 data bytes9 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 lossround-trip min/avg/max = 275445915.2/275445915.2/275445915.2 msPING 211.95.193.97 (211.95.193.97): 1 data bytes9 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 lossround-trip min/avg/max = 275451048.9/275451048.9/275451048.9 msPING 211.95.193.97 (211.95.193.97): 1 data bytes9 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 lossround-trip min/avg/max = 275456180.4/275456180.4/275456180.4 msPING 211.95.193.97 (211.95.193.97): 1 data bytes9 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 lossround-trip min/avg/max = 275461314.4/275461314.4/275461314.4 msPING 211.95.193.97 (211.95.193.97): 1 data bytes9 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 lossround-trip min/avg/max = 275466446.2/275466446.2/275466446.2 msPING 211.95.193.97 (211.95.193.97): 1 data bytes9 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 lossround-trip min/avg/max = 275471577.9/275471577.9/275471577.9 msPING 211.95.193.97 (211.95.193.97): 1 data bytes9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275476708.1 ms
欢迎关注并加入物联网行业联盟,积累行业人脉和资源。
转载请注明原文地址: https://www.6miu.com/read-74381.html