Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4264064
  • 博文数量: 776
  • 博客积分: 13014
  • 博客等级: 上将
  • 技术积分: 10391
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-22 17:00
文章分类

全部博文(776)

文章存档

2015年(55)

2014年(43)

2013年(147)

2012年(20)

2011年(82)

2010年(429)

分类:

2010-03-10 23:42:05

#!/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
]
rcvd [LCP ConfAck id=0x1
]
rcvd [LCP ConfReq id=0x3
]
sent [LCP ConfNak id=0x3 ]
rcvd [LCP ConfReq id=0x5
]
sent [LCP ConfAck id=0x5
]
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
sent [PAP AuthReq id=0x1 user="beeline" password=]
rcvd [PAP AuthAck id=0x1 ""]
PAP authentication succeeded
sent [CCP ConfReq id=0x1 ]
sent [IPCP ConfReq id=0x1 ]
rcvd [LCP ProtRej id=0x6 80 fd 01 01 00 0f 1a 04 78 00 18 04 78]
sent [IPCP ConfReq id=0x1 ]
sent [IPCP ConfReq id=0x1 ]
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 ]
sent [IPCP ConfReq id=0x1 ]
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 ]
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 ]
sent [IPCP ConfReq id=0x1 ]
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 ]
sent [IPCP ConfReq id=0x1 ]
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
阅读(5110) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

eremiter2017-03-24 16:54:14

/etc/autorun我改进了一下,ping 服务器192.168.10.1 即,服务器vpn的ip
在centos7客户端设置如下
/usr/autorun/ppp-service.sh
内容如下
[Shell] 纯文本查看 / 双击代码区域 Ctrl+A快速复制
#!/bin/sh

# /etc/autorun/ppp-service.sh

# 环境centos7.3,检测vpn是否断线,断线而重拔

# 请把dns1,dns2,gw修改成拼得通的DNS,开机自动运行,实时监控,断线自动重拨

#dns1=\"114.114.114.114\"

#dns2=\"114.114.115.115\"

#gw1 = \"192.168.10.1\"



sleep 8

/usr/sbin/pppd call vpn &