浙江理工大学斐讯K2自动锐捷闪讯拨号,断线重连脚本以及固件,通过mentohust实现锐捷闪讯认证断线重连脚本
斐讯K2自动锐捷闪讯拨号,断线重连脚本以及固件,通过MentoHUST实现锐捷闪讯认证,通过l2tp实现拨号 计划任务里写如
Sep 5 14:31:50 root charon: 13[ENC] generating QUICK_MODE request 3930082374 [ HASH ] Sep 5 14:31:50 root charon: 13[NET] sending packet: from 10.18.99.33[4500] to 128.88.33.11[4500] (60 bytes) Sep 5 14:31:50 root NetworkManager[932]: nm-l2tp[26025] <info> strongSwan IPsec tunnel is up. Sep 5 14:31:50 root NetworkManager[932]: ** Message: xl2tpd started with pid 26104 Sep 5 14:31:50 root NetworkManager[932]: xl2tpd[26104]: Not looking for kernel SAref support. Sep 5 14:31:50 root NetworkManager[932]: xl2tpd[26104]: Using l2tp kernel support. Sep 5 14:31:50 root NetworkManager[932]: xl2tpd[26104]: xl2tpd version xl2tpd-1.3.6 started on root PID:26104 Sep 5 14:31:50 root NetworkManager[932]: xl2tpd[26104]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc. Sep 5 14:31:50 root NetworkManager[932]: xl2tpd[26104]: Forked by Scott Balmos and David Stipp, (C) 2001 Sep 5 14:31:50 root NetworkManager[932]: xl2tpd[26104]: Inherited by Jeff McAdams, (C) 2002 Sep 5 14:31:50 root NetworkManager[932]: xl2tpd[26104]: Forked again by Xelerance (www.xelerance.com) (C) 2006 Sep 5 14:31:50 root NetworkManager[932]: xl2tpd[26104]: Listening on IP address 0.0.0.0, port 1701 Sep 5 14:31:50 root NetworkManager[932]: xl2tpd[26104]: Connecting to host 128.88.33.11, port 1701 Sep 5 14:31:50 root NetworkManager[932]: <info> [1536129110.8589] vpn-connection[0x2207460,c700dc45-2bc6-4e83-a50a-7fdacfd4ac19,"VPN connection 1",0]: VPN plugin: state changed: starting (3) Sep 5 14:31:55 root NetworkManager[932]: xl2tpd[26104]: Maximum retries exceeded for tunnel 33925. Closing. Sep 5 14:31:55 root NetworkManager[932]: xl2tpd[26104]: Connection 0 closed to 128.88.33.11, port 1701 (Timeout) Sep 5 14:32:00 root NetworkManager[932]: xl2tpd[26104]: Unable to deliver closing message for tunnel 33925. Destroying anyway. Sep 5 14:32:04 root NetworkManager[932]: nm-l2tp[26025] <warn> Looks like pppd didn't initialize our dbus module Sep 5 14:32:04 root NetworkManager[932]: nm-l2tp[26025] <info> Terminated xl2tpd daemon with PID 26104. Sep 5 14:32:04 root NetworkManager[932]: xl2tpd[26104]: death_handler: Fatal signal 15 received
问题分析
xl2tpd连接×××服务器时,调用pppd来进行拨号,建立连接后,每隔几秒会向服务器发送echo-request请求,如果服务器因为某些原因(只能想到网络原因)未及时做出相应,pppd发送几次请求后就会自动中断链接。
1、编写脚本reconnect.sh
#!/bin/sh echo "开始检测" logger -t "【网络检测】" "开始检测" ping -c 4 -W 10 114.114.114.114 if [ "$?" != "0" ];then echo "网络异常" logger -t "【网络检测】" "网络异常" logger -t "【网络检测】" "尝试重新连接" ps w | grep l2tpd | grep -v grep | awk '{print $1}' | xargs kill -9 restart_wan logger -t "【网络检测】" "重新连接" echo "已重连 " echo "ok">>/tmp/vpncon.log if [ ! -f "/tmp/1.log" ] #五次重连不上则重启 then touch "/tmp/1.log" a=0 else a=`cat /tmp/1.log` fi if [ $a -le 5 ] then echo $(($a+1))> /tmp/1.log else logger -t "【网络检测】" "尝试重启" reboot logger -t "【网络检测】" "重启完成" fi else logger -t "【网络检测】" "网络正常" fi logger -t "【网络检测】" "结束检测" exit 0
2、使用WinSCP工具上传到路由器
把刚才新建的reconnect.sh 脚本上传到/tmp/目录
3、添加定时任务到老毛子(Padavan)->高级设置->系统管理->服务->其他服务->Cron守护程序 (计划任务)
*/1 * * * * sh /tmp/reconnect.sh
可实现每分钟自动检测断网重连
4、日志
项目地址:https://github.com/fjh1997/phicomm-K2-openwrt-padavan-reconnect-vpn?tdsourcetag=s_pcqq_aiomsg
点击链接加入群聊三群:751529538
点击链接加入群聊二群:376877156
点击链接加入群聊【路由器交流群:622891808已满】
本站附件分享,如果附件失效,可以去找找看
饿了么红包
于2020-06-19发布