forked from phamhung140295/ipv6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buyvm_48_noauth.sh
127 lines (109 loc) · 3.48 KB
/
buyvm_48_noauth.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
random() {
tr </dev/urandom -dc A-Za-z0-9 | head -c5
echo
}
array=(1 2 3 4 5 6 7 8 9 0 a b c d e f)
main_interface=$(ip route get 8.8.8.8 | awk -- '{printf $5}')
gen64() {
ip64() {
echo "${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}"
}
echo "$1:$(ip64):$(ip64):$(ip64):$(ip64):$(ip64)"
}
install_3proxy() {
echo "installing 3proxy"
mkdir -p /3proxy
cd /3proxy
URL="https://github.com/z3APA3A/3proxy/archive/0.9.3.tar.gz"
wget -qO- $URL | bsdtar -xvf-
cd 3proxy-0.9.3
make -f Makefile.Linux
mkdir -p /usr/local/etc/3proxy/{bin,logs,stat}
mv /3proxy/3proxy-0.9.3/bin/3proxy /usr/local/etc/3proxy/bin/
wget https://raw.githubusercontent.com/thuongtin/ipv4-ipv6-proxy/master/scripts/3proxy.service-Centos8 --output-document=/3proxy/3proxy-0.9.3/scripts/3proxy.service2
cp /3proxy/3proxy-0.9.3/scripts/3proxy.service2 /usr/lib/systemd/system/3proxy.service
systemctl link /usr/lib/systemd/system/3proxy.service
systemctl daemon-reload
# systemctl enable 3proxy
echo "* hard nofile 999999" >> /etc/security/limits.conf
echo "* soft nofile 999999" >> /etc/security/limits.conf
echo "net.ipv6.conf.$main_interface.proxy_ndp=1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.proxy_ndp=1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.forwarding=1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.forwarding=1" >> /etc/sysctl.conf
echo "net.ipv6.ip_nonlocal_bind = 1" >> /etc/sysctl.conf
sysctl -p
systemctl stop firewalld
systemctl disable firewalld
cd $WORKDIR
}
gen_3proxy() {
cat <<EOF
daemon
maxconn 10000
nserver 1.1.1.1
nserver 8.8.4.4
nserver 2001:4860:4860::8888
nserver 2001:4860:4860::8844
nscache 65536
timeouts 1 5 30 60 180 1800 15 60
setgid 65535
setuid 65535
stacksize 6291456
flush
$(awk -F "/" '{print "proxy -6 -n -p" $4 " -i" $3 " -e"$5"\n" \
"flush\n"}' ${WORKDATA})
EOF
}
gen_proxy_file_for_user() {
cat >proxy.txt <<EOF
$(awk -F "/" '{print $3 ":" $4 ":" $1 ":" $2 }' ${WORKDATA})
EOF
}
gen_data() {
seq $FIRST_PORT $LAST_PORT | while read port; do
echo "$(random)/$(random)/$IP4/$port/$(gen64 $IP6)"
done
}
gen_iptables() {
cat <<EOF
$(awk -F "/" '{print "iptables -I INPUT -p tcp --dport " $4 " -m state --state NEW -j ACCEPT"}' ${WORKDATA})
EOF
}
gen_ifconfig() {
cat <<EOF
$(awk -F "/" '{print "ifconfig '$main_interface' inet6 add " $5 "/64"}' ${WORKDATA})
EOF
}
echo "installing apps"
yum -y install wget
yum -y install gcc net-tools bsdtar zip make >/dev/null
install_3proxy
echo "working folder = /home/proxy-installer"
WORKDIR="/home/proxy-installer"
WORKDATA="${WORKDIR}/data.txt"
mkdir $WORKDIR && cd $_
wget https://raw.githubusercontent.com/phamhung140295/ipv6/master/gen_proxy_48.sh -O $WORKDIR/gen_proxy.sh
IP4=$(curl -4 -s icanhazip.com)
IP6=$(curl -6 -s icanhazip.com | cut -f1-3 -d':')
echo "Internal ip = ${IP4}. Exteranl sub for ip6 = ${IP6}"
FIRST_PORT=10000
LAST_PORT=11000
gen_data >$WORKDIR/data.txt
gen_iptables >$WORKDIR/boot_iptables.sh
gen_ifconfig >$WORKDIR/boot_ifconfig.sh
chmod +x $WORKDIR/boot_*.sh /etc/rc.local
gen_3proxy >/usr/local/etc/3proxy/3proxy.cfg
cat >>/etc/rc.local <<EOF
systemctl start NetworkManager.service
# ifup ${main_interface}
timeout 5 ping google.com
bash ${WORKDIR}/gen_proxy.sh
bash ${WORKDIR}/boot_iptables.sh
bash ${WORKDIR}/boot_ifconfig.sh
ulimit -n 65000
/usr/local/etc/3proxy/bin/3proxy /usr/local/etc/3proxy/3proxy.cfg &
EOF
bash /etc/rc.local
gen_proxy_file_for_user