Last active
May 14, 2022 04:43
-
-
Save rinex20/3c2f0208b0a7416422bbb7c4273d83c7 to your computer and use it in GitHub Desktop.
gost installer for network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://raw.githubusercontent.com/sunpma/doubi/master/iptables-pf.sh 一键转发 | |
# sudo curl -o install.sh http://192.168.90.227/gost/install.sh | sudo bash install.sh | |
set -ex | |
mkdir -p /etc/gost && \ | |
cd /etc/gost | |
# download gost | |
# https://github.com/go-gost/gost/releases/download/v3.0.0-beta.2/gost-linux-amd64-3.0.0-beta.2.gz | |
# download gost | |
download_gost() | |
{ | |
abc=`uname -a` | |
ARCH1="x86_64" | |
ARCH2="aarch64" | |
ARCH3="armv8" | |
ARCH="amd64" | |
if [[ "$abc" == *$ARCH1* ]]; then | |
echo "x86_64" | |
elif [[ "$abc" == *$ARCH2* ]]; then | |
echo "arm8" | |
ARCH="armv8" | |
elif [[ "$abc" == *$ARCH2* ]]; then | |
echo "arm8" | |
ARCH="armv8" | |
else | |
echo "not support" | |
fi | |
VER="3.0.0-beta.2" | |
FILE="gost-linux-${ARCH}-${VER}" | |
URL="https://github.com/go-gost/gost/releases/download/v${VER}/${FILE}.gz" | |
echo "$URL" | |
curl -fsSL -o ${FILE}.gz $URL | |
if [ -e ${FILE}.gz ]; then | |
echo "download completed." | |
fi | |
gunzip -f -d ${FILE}.gz && \ | |
chmod +x ${FILE} && \ | |
mv ${FILE} /usr/local/bin/gost | |
} | |
# wget -O gost-linux.gz https://github.com/go-gost/gost/releases/download/v3.0.0-beta.2/gost-linux-amd64-3.0.0-beta.2.gz | |
download_gost | |
# test gost | |
gost -v | |
#generate gost.yaml | |
cat > /etc/gost/gost.yaml <<EOF | |
- name: service-tun-0 | |
addr: :7519 | |
handler: | |
type: tun | |
chain: chain-relay-mwss | |
metadata: | |
net: 10.168.123.4/24 | |
mtu: "1350" | |
name: "gost_tun0" | |
gw: 10.168.123.1/24 | |
route: 10.168.123.0/24 | |
listener: | |
type: tun | |
metadata: | |
mtu: "1350" | |
name: "gost_tun0" | |
net: 10.168.123.4/24 | |
gw: 10.168.123.1/24 | |
route: 10.168.123.0/24 | |
forwarder: | |
targets: | |
- 127.0.0.1:7519 | |
chains: | |
- name: chain-relay-mwss | |
hops: | |
- name: hop-0 | |
nodes: | |
- name: node-0 | |
addr: xxx.xxx.com:7501 | |
connector: | |
type: relay | |
metadata: | |
path: /img | |
dialer: | |
type: mwss | |
metadata: | |
path: /img | |
EOF | |
# gost.service | |
cat > /etc/systemd/system/gost.service <<EOF | |
[Unit] | |
Description=Gost tun private network | |
After=network.target network-online.target nss-lookup.target | |
[Service] | |
Type=simple | |
StandardError=journal | |
ExecStartPre=/bin/sh -c 'net.core.rmem_max=2500000' | |
ExecStart=/usr/local/bin/gost | |
Restart=on-failure | |
RestartSec=3s | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
systemctl daemon-reload && systemctl start gost && \ | |
systemctl status gost && \ | |
systemctl enable gost | |
echo "finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment