|
@@ -4,12 +4,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
+help_info()
|
|
|
|
+{
|
|
|
|
+cat <<EOF
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+wget -qO- git.io/fptwc | bash
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+wget -qO- git.io/fpcnL | bash
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+yum install -y wget && \
|
|
|
|
+wget https://raw.githubusercontent.com/atrandys/wireguard/master/wireguard_install.sh \
|
|
|
|
+&& chmod +x wireguard_install.sh && ./wireguard_install.sh
|
|
|
|
+
|
|
|
|
+EOF
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+Green="\033[32m" && Red="\033[31m" && GreenBG="\033[42;37m" && RedBG="\033[41;37m" && Font="\033[0m"
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+Info="${Green}[信息]${Font}" && OK="${Green}[OK]${Font}" && Error="${Red}[错误]${Font}"
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
+if [ ! -f '/usr/bin/wg' ]; then
|
|
|
|
+ clear
|
|
|
|
+ echo -e "${RedBG} 一键安装 WireGuard 脚本 For Debian_9 Ubuntu Centos_7 ${Font}"
|
|
|
|
+ echo -e "${GreenBG} 开源项目:https://github.com/hongwenjun/vps_setup ${Font}"
|
|
|
|
+ help_info
|
|
|
|
+ echo -e "${RedBG} 检测到你的vps没有正确选择脚本,请使用对应系统的脚本安装 ${Font}"
|
|
|
|
+ exit 1
|
|
|
|
+fi
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -17,7 +48,7 @@ rand(){
|
|
min=$1
|
|
min=$1
|
|
max=$(($2-$min+1))
|
|
max=$(($2-$min+1))
|
|
num=$(cat /dev/urandom | head -n 10 | cksum | awk -F ' ' '{print $1}')
|
|
num=$(cat /dev/urandom | head -n 10 | cksum | awk -F ' ' '{print $1}')
|
|
- echo $(($num%$max+$min))
|
|
+ echo $(($num%$max+$min))
|
|
}
|
|
}
|
|
|
|
|
|
port=$(rand 1000 60000)
|
|
port=$(rand 1000 60000)
|
|
@@ -25,11 +56,11 @@ port=$(rand 1000 60000)
|
|
mtu=1420
|
|
mtu=1420
|
|
host=$(hostname -s)
|
|
host=$(hostname -s)
|
|
|
|
|
|
-ip_list=(2 8 18 88 188 118 158 198 168 186)
|
|
+ip_list=(2 5 8 18 88 188 118 158 198 168 186 )
|
|
|
|
|
|
|
|
|
|
if [ ! -f '/usr/bin/curl' ]; then
|
|
if [ ! -f '/usr/bin/curl' ]; then
|
|
- apt update && apt install -y curl
|
|
+ apt update && apt install -y curl
|
|
fi
|
|
fi
|
|
serverip=$(curl -4 icanhazip.com)
|
|
serverip=$(curl -4 icanhazip.com)
|
|
|
|
|
|
@@ -40,6 +71,7 @@ fi
|
|
|
|
|
|
|
|
|
|
wget -O ~/wgmtu https://raw.githubusercontent.com/hongwenjun/vps_setup/master/Wireguard/wgmtu.sh
|
|
wget -O ~/wgmtu https://raw.githubusercontent.com/hongwenjun/vps_setup/master/Wireguard/wgmtu.sh
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -53,7 +85,7 @@ wg genkey | tee cprivatekey | wg pubkey > cpublickey
|
|
cat <<EOF >wg0.conf
|
|
cat <<EOF >wg0.conf
|
|
[Interface]
|
|
[Interface]
|
|
PrivateKey = $(cat sprivatekey)
|
|
PrivateKey = $(cat sprivatekey)
|
|
-Address = 10.0.0.1/24
|
|
+Address = 10.0.0.1/24
|
|
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
|
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
|
ListenPort = $port
|
|
ListenPort = $port
|
|
@@ -84,12 +116,12 @@ PersistentKeepalive = 25
|
|
|
|
|
|
EOF
|
|
EOF
|
|
|
|
|
|
-
|
|
+
|
|
-for i in {1..9}
|
|
+for i in {2..9}
|
|
do
|
|
do
|
|
ip=10.0.0.${ip_list[$i]}
|
|
ip=10.0.0.${ip_list[$i]}
|
|
wg genkey | tee cprivatekey | wg pubkey > cpublickey
|
|
wg genkey | tee cprivatekey | wg pubkey > cpublickey
|
|
-
|
|
+
|
|
cat <<EOF >>wg0.conf
|
|
cat <<EOF >>wg0.conf
|
|
[Peer]
|
|
[Peer]
|
|
PublicKey = $(cat cpublickey)
|
|
PublicKey = $(cat cpublickey)
|
|
@@ -124,12 +156,6 @@ wg-quick down wg0
|
|
wg-quick up wg0
|
|
wg-quick up wg0
|
|
wg
|
|
wg
|
|
|
|
|
|
-
|
|
|
|
-Green="\033[32m" && Red="\033[31m" && GreenBG="\033[42;37m" && RedBG="\033[41;37m" && Font="\033[0m"
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-Info="${Green}[信息]${Font}" && OK="${Green}[OK]${Font}" && Error="${Red}[错误]${Font}"
|
|
|
|
-
|
|
|
|
conf_url=http://${serverip}:8000
|
|
conf_url=http://${serverip}:8000
|
|
|
|
|
|
cat <<EOF > ~/wg5
|
|
cat <<EOF > ~/wg5
|
|
@@ -142,17 +168,16 @@ host=$(hostname -s)
|
|
|
|
|
|
cd /etc/wireguard/
|
|
cd /etc/wireguard/
|
|
tar cvf wg5clients.tar client* wg*
|
|
tar cvf wg5clients.tar client* wg*
|
|
-cat /etc/wireguard/wg_${host}_1.conf | qrencode -o - -t UTF8
|
|
+cat /etc/wireguard/wg_${host}_2.conf | qrencode -o - -t UTF8
|
|
-echo "# 手机扫描二维码2号配置,PC使用配置复制下面文本"
|
|
+echo -e "${GreenBG}# 手机扫描二维码2号配置,Windows 用配置请复制合适文本 ${Font}"
|
|
|
|
|
|
cat /etc/wireguard/client.conf && next
|
|
cat /etc/wireguard/client.conf && next
|
|
-cat /etc/wireguard/wg_${host}_1.conf && next
|
|
|
|
cat /etc/wireguard/wg_${host}_2.conf && next
|
|
cat /etc/wireguard/wg_${host}_2.conf && next
|
|
cat /etc/wireguard/wg_${host}_3.conf && next
|
|
cat /etc/wireguard/wg_${host}_3.conf && next
|
|
cat /etc/wireguard/wg_${host}_4.conf && next
|
|
cat /etc/wireguard/wg_${host}_4.conf && next
|
|
|
|
|
|
echo -e "${RedBG} 一键安装 WireGuard 脚本 For Debian_9 Ubuntu Centos_7 ${Font}"
|
|
echo -e "${RedBG} 一键安装 WireGuard 脚本 For Debian_9 Ubuntu Centos_7 ${Font}"
|
|
-echo -e "${GreenBG} 开源项目:https://github.com/hongwenjun/vps_setup ${Font}"
|
|
+echo -e "${GreenBG} 开源项目:https://github.com/hongwenjun/vps_setup ${Font}"
|
|
echo
|
|
echo
|
|
echo -e "# ${Info} 使用${GreenBG} bash wg5 ${Font} 命令,可以临时网页下载配置和二维码"
|
|
echo -e "# ${Info} 使用${GreenBG} bash wg5 ${Font} 命令,可以临时网页下载配置和二维码"
|
|
echo -e "# ${Info} 使用${GreenBG} bash wgmtu ${Font} 命令,重置客户端数量,设置服务器端MTU数值或服务端口号 "
|
|
echo -e "# ${Info} 使用${GreenBG} bash wgmtu ${Font} 命令,重置客户端数量,设置服务器端MTU数值或服务端口号 "
|