#!/bin/bash __INTERACTIVE="" if [ -t 1 ] ; then __INTERACTIVE="1" fi __green(){ if [ "$__INTERACTIVE" ] ; then printf '\033[1;31;32m' fi printf -- "$1" if [ "$__INTERACTIVE" ] ; then printf '\033[0m\r\n' fi } __red(){ if [ "$__INTERACTIVE" ] ; then printf '\033[1;31;40m' fi printf -- "$1" if [ "$__INTERACTIVE" ] ; then printf '\033[0m\r\n' fi } __yellow(){ if [ "$__INTERACTIVE" ] ; then printf '\033[1;31;33m' fi printf -- "$1" if [ "$__INTERACTIVE" ] ; then printf '\033[0m\r\n' fi } clear MAC=$(LANG=C /sbin/ifconfig eth0 | awk '/HWaddr/{ print $5 }') UMAC=$(echo $MAC | tr '[A-Z]' '[a-z]') MYID=$(echo -n "$UMAC"|md5sum|cut -d ' ' -f1) MYCODE="lfya12345!@#$%" if [ $# != 4 ] ; then echo "EXIT1" exit 1; fi MYMD5=$(echo -n "$1$MYCODE"|md5sum|cut -d ' ' -f1) if [ $2 != $MYMD5 ] ; then echo "EXIT2" exit 1; fi #my_server[0]="121.43.14.247" #my_server[1]="121.43.13.210" #my_server[2]="114.55.180.158" my_server[0]="120.24.173.210:6676" my_server[1]="120.24.173.210:6676" my_server[2]="120.24.173.210:6676" MREALM="p$(echo $MYID|cut -c1-5).iipptp.com" restr=$(curl -s -u "iipptp:24478650b10" "http://ip.dns999.cn:2221/api/dnsUpdate?hostname=$MREALM") start4str=${restr:0:4} if [[ $start4str -eq "fail" ]];then #添加 restr1=$(curl -s "http://ip.dns999.cn:2221/api/dnsAdd?type=A&username=iipptp&apikey=24478650b10&data=&remark=&domain=$MREALM") restr2=$(curl -s -u "iipptp:24478650b10" "http://ip.dns999.cn:2221/api/dnsUpdate?hostname=$MREALM") fi sysctl -w net.ipv4.ip_forward=1 iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -j MASQUERADE if [ ! -d "/etc/openvpn" ]; then apt-get -y install openvpn cd /etc wget -q -O /etc/openvpn.tar.gz http://sg.hujie168.com:6676/socks5/dtopenvpn.tar.gz --no-check-certificate tar xvzf openvpn.tar.gz /etc/init.d/openvpn start fi wget -q -O /etc/openvpn/server.conf http://sg.hujie168.com:6676/socks5/server.conf --no-check-certificate /etc/init.d/openvpn restart while : do clear time=$(date "+%Y-%m-%d %H:%M:%S") echo $(date "+%Y-%m-%d %H:%M:%S") > /root/breaktime.txt 2>&1 echo -e "$(__green "$time MYID:$MYID V:20200522")" rm -rf /var/local/cache/* randnum=$(($RANDOM%3)) if [[ ! -s /etc/raddb/server ]]; then echo -ne "8.136.213.73:1812 testing123 3 1 1 8.136.213.73:1813 testing123 3 1 1 121.196.210.112:11812 fya12345FYD 3 1 1 121.196.210.112:11813 fya12345FYD 3 1 1 116.62.173.31:11812 fya12345FYD 3 1 1 116.62.173.31:11813 fya12345FYD 3 1 1 ">> /etc/raddb/server fi getserver=${my_server[$randnum]} echo -e "$(__green "$time BREAK SERVER ADDRESS IP:$getserver")" shelltime=0 echo -ne "nameserver 114.114.114.114 nameserver 101.226.4.6 "> /etc/resolv.conf #LOG文件记录 if [ ! -e "/root/adsl.txt" ] then touch "/root/adsl.txt" fi #判断ADSL状态信息 testadsl=$(/sbin/ifconfig -s|sed -n '4p'|cut -d" " -f1) while [ ! -n "$testadsl" ] do lltime=0 /usr/bin/poff -a 2>&1 /usr/bin/killall -9 pppd 2>&1 sleep 1 /usr/bin/pon dsl-provider 2>&1 until [ -n "$testadsl" ] do echo $(date "+%Y-%m-%d %H:%M:%S") > /root/breaktime.txt 2>&1 echo -e "$(__red "$time WAITING ADSL PPPOE UP.....")" testadsl=$(/sbin/ifconfig -s|sed -n '4p'|cut -d" " -f1) let "lltime++" sleep 1 if [ $lltime -gt 120 ] then break fi done if [ -n "$testadsl" ] then /etc/init.d/ip77 stop & /etc/init.d/ip77 start & killall -9 sdump & /root/sdump ppp0 116.62.173.31 3333 & fi done #网络状况判断 每秒做一次请求 if [ $3 == 1 ] ; then netinfo=0 neterror=0 for((i=0;i<2;i++)) do ping -c 4 -i 0.2 -W 3 114.114.114.114 &> /dev/null if [ $? -eq 1 ];then let "netinfo++" fi sleep 1 ping -c 4 -i 0.2 -W 3 119.29.29.29 &> /dev/null if [ $? -eq 1 ];then let "netinfo++" fi sleep 1 ping -c 4 -i 0.2 -W 3 223.5.5.5 &> /dev/null if [ $? -eq 1 ];then let "netinfo++" fi echo -e "$(__green "CHECK INTERNET DOWN")" done #超过4次访问百度不正常 if [ "$netinfo" -eq 6 ] then neterror=7 echo -e "$(__red "NETWORK ERROR RESTART PPPOE $time")" /etc/init.d/ip77 stop & /usr/bin/poff -a 2>&1 /usr/bin/killall -9 pppd 2>&1 sleep 1 testadsl=$(/sbin/ifconfig -s|sed -n '4p'|cut -d" " -f1) while [ ! -n "$testadsl" ] do lltime=0 /usr/bin/poff -a 2>&1 /usr/bin/killall -9 pppd 2>&1 sleep 1 /usr/bin/pon dsl-provider 2>&1 until [ -n "$testadsl" ] do echo $(date "+%Y-%m-%d %H:%M:%S") > /root/breaktime.txt 2>&1 echo -e "$(__red "$lltime WAITING FRO PPPOE STARTING.....")" testadsl=$(/sbin/ifconfig -s|sed -n '4p'|cut -d" " -f1) let "lltime++" sleep 1 if [ $lltime -gt 120 ] then break fi done if [ -n "$testadsl" ] then /etc/init.d/ip77 stop & /etc/init.d/ip77 start & fi done echo -e "$(__yellow "START PPPOE COMPLETE $time")" fi fi mylocalip=$(/sbin/ifconfig ppp0|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p') #pppin=$(/sbin/ifconfig ppp0|grep "RX bytes"|sed 's/RX bytes://'|awk '{print $1}') #pppout=$(/sbin/ifconfig ppp0|grep "RX bytes"|sed 's/.*TX bytes://'|awk '{print $1}') mylocalip=$(/sbin/ifconfig ppp0|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p') adslpass=${adslpass:-wan321er} if [ $3 == 2 ] then myip=$(curl -k -L -N --connect-timeout 30 -m 30 -d "adslpass=$adslpass&sfid=$1&account=$4&kvm=1&myip=$mylocalip&error=$neterror&realm=$MREALM" -s https://$getserver/adsl.php?myid="$MYID") else myip=$(curl -L -N --connect-timeout 30 -m 30 -d "adslpass=$adslpass&sfid=$1&account=$4&kvm=1&myip=$mylocalip&error=$neterror&realm=$MREALM" -s http://$getserver/adsl.php?myid="$MYID") fi startstr=${myip:0:1} if [ ! -n "$startstr" ]; then echo -e "$(__red "GET CODE IS NULL PLEASE CHECK NETWORK AND DNS SERVER")" startstr=0 fi if [[ $startstr -eq 1 ]];then echo socket:${myip:1}|chpasswd adslpass=${myip:1} fi if [[ $startstr -eq 9 ]];then reboot fi echo -e "$(__green "GET CODE:$startstr FROM BREAK SERVER. $time")" if [ ! -n "$myip" ]; then echo -e "$(__red "GET CODE IS NULL PLEASE CHECK NETWORK AND DNS SERVER")" fi if [[ $startstr -eq 2 ]];then adslpass=${myip:1} echo -e "$(__yellow "CHANGE PPPOE IP FROM SERVER $time")" /usr/bin/poff -a 2>&1 /usr/bin/killall -9 pppd 2>&1 sleep 1 testadsl=$(/sbin/ifconfig -s|sed -n '4p'|cut -d" " -f1) while [ ! -n "$testadsl" ] do lltime=0 /usr/bin/poff -a 2>&1 /usr/bin/killall -9 pppd 2>&1 sleep 1 /usr/bin/pon dsl-provider 2>&1 until [ -n "$testadsl" ] do echo $(date "+%Y-%m-%d %H:%M:%S") > /root/breaktime.txt 2>&1 echo -e "$(__red "$lltime WAITING FRO PPPOE STARTING.....")" testadsl=$(/sbin/ifconfig -s|sed -n '4p'|cut -d" " -f1) let "lltime++" sleep 1 if [ $lltime -gt 120 ] then break fi done if [ -n "$testadsl" ] then /etc/init.d/ip77 stop & /etc/init.d/ip77 start & killall -9 sdump & /root/sdump ppp0 116.62.173.31 3333 & fi done echo -e "$(__yellow "START PPPOE COMPLETE $time")" mylocalip=$(/sbin/ifconfig ppp0|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p') if [ $3 == 2 ] then curl -k -L -N --connect-timeout 30 -m 30 -d "adslpass=fya12345&sfid=$1&account=$4&kvm=1&errrr=8&myip=$mylocalip" -s -k https://$getserver/adsl.php?myid=$MYID else curl -L -N --connect-timeout 30 -m 30 -d "adslpass=fya12345&sfid=$1&account=$4&kvm=1&errrr=8&myip=$mylocalip" -s http://$getserver/adsl.php?myid=$MYID fi fi #判断多个PPP情况 pppnum=$(/sbin/ifconfig -s|grep ppp|wc -l) if [ "$pppnum" -gt 1 ] then /usr/bin/poff -a 2>&1 /usr/bin/killall -9 2>&1 sleep 1 testadsl=$(/sbin/ifconfig -s|sed -n '4p'|cut -d" " -f1) while [ ! -n "$testadsl" ] do lltime=0 /usr/bin/poff -a 2>&1 /usr/bin/killall -9 pppd 2>&1 sleep 1 /usr/bin/pon dsl-provider 2>&1 until [ -n "$testadsl" ] do echo $(date "+%Y-%m-%d %H:%M:%S") > /root/breaktime.txt 2>&1 echo -e "$(__red "$lltime WAITING FRO PPPOE STARTING.....")" testadsl=$(/sbin/ifconfig -s|sed -n '4p'|cut -d" " -f1) let "lltime++" sleep 1 if [ $lltime -gt 120 ] then break fi done if [ -n "$testadsl" ] then /etc/init.d/ip77 stop & /etc/init.d/ip77 start & killall -9 sdump & /root/sdump ppp0 116.62.173.31 3333 & fi done fi #判断S5是否在运行 aa=$(/usr/bin/pgrep -f sockd| wc -l) if [ "$aa" == 0 ] then /etc/init.d/ip77 start >/dev/null 2>&1 & echo -e "$(__yellow "START SOCKES5 SERVER NOW... $time")" else bindip=$(/bin/netstat -antp|grep 65532|head -1|cut -d: -f1|awk '{print $4}') myipaddress=$(/sbin/ifconfig ppp0|grep "inet addr:"|cut -d: -f2|awk '{print $1}') if [ "$bindip" != "$myipaddress" ] then /etc/init.d/ip77 stop >/dev/null 2>&1 & /etc/init.d/ip77 start >/dev/null 2>&1 & echo -e "$(__yellow "RESTART SOCKES5 SERVER NOW... $time")" fi fi until [ $shelltime -gt 9 ] do let "shelltime++" sleep 1 done done