通过Gost搭建隧道中转

By | 2022-11-12

通过Gost搭建隧道中转

项目地址:

https://github.com/go-gost/gost

官方文档:

https://gost.run

下载Gost


wget https://github.com/go-gost/gost/releases/download/v3.0.0-rc.0/gost-linux-amd64-3.0.0-rc.0.gz
gzip -d gost-linux-amd64-3.0.0-rc.0.gz
chmod +x gost-linux-amd64-3.0.0-rc.0
mv gost-linux-amd64-3.0.0-rc.0 gost

端口转发

gost启用端口转发:./gost -L tcp://:9527/落地机ip:80

隧道中转

方式1(推荐):

中转机, 9527为中转端口,1.1.1.1为落地机IP,8443为落地机微端口:

./gost -L tcp://:9527 -F relay+tls://1.1.1.1:8443

落地机:

./gost -L relay+tls://:8443/:80

方式2:

中转机:

./gost -L tcp://:9527/1.1.1.1:80 -F relay+tls://1.1.1.1:8443

落地机:

./gost -L relay+tls://:8443

后台运行:

nohup gost运行指令 > gost.log 2>&1 &

设置开机自启

本地win可以创建一个快捷方式,复制到开机自启目录下
服务器为Debian

apt install supervisor

编写自启程序 把这个文件复制到目录下 /etc/supervisor/conf.d/

vim /etc/supervisor/conf.d/gost.conf

写入以下内容

[program:gost]
command=gost命令
directory=/root
autostart=true
autorestart=true

startretries=10