老E的博客

  • 首页
  • 关于
  • 技术应用
    • VPS相关
    • AI相关
    • 盒子相关
    • 其他
  • 订阅Youtube频道
  • 网络加速
    • expressvpnNo.1 ExpressVPN
    • 最佳免费VPN-PrivadoVPN
    • NordVPN
    • 廉价王者-Surfshark
    • PrivateInternetAccess
    • 解锁一切-PrivateVPN
  • 公益资源
    • AI导航
    • 工具下载
    • Docker镜像加速
  • 友情链接
    • tickcloudTickcloud
老E的博客
专注记录并分享跨境技术应用及随想
  1. 首页
  2. 技术应用
  3. VPS相关
  4. 正文

一款简单到爆的Websocket VPN隧道工具

2023年10月20日 4768次阅读 0条评论
clawcloud
expressvpn best vpn
privado vpn
surfshark vpn
private vpn
pia vpn
nord vpn

wstunnel是一款简单到爆、让人不禁说“卧槽”的隧道/代理工具,简单到一时不知道如何写这篇博文,其github项目主页如下。

https://github.com/erebe/wstunnel

github项目主页中,作者提供了包括Windows、Linux以及MacOS平台amd64和aarch64架构的『二进制预编译文件』,直接下载对应版本运行即可。老E也将最新的6.0版本放在『博客空间』中,需要的可以自取。

1.下载与运行

在Linux服务端,直接下载、解压、赋权。压缩包需要解压,未安装unzip的需要在解压前安装一下,同时检查端口占用情况。

wget https://github.com/erebe/wstunnel/releases/download/v6.0/wstunnel-linux-x64.zip
#apt install unzip -y  
#CentOS仅包管理器不同,可使用yum install unzip
unzip wstunnel-linux-x64.zip && chmod 755 wstunnel && rm -f wstunnel-linux-x64.zip

完成上述操作后,使用如下命令运行wstunnel,示例为采用wss协议(Secure Websocket、Websocket over TLS),监听本机所有接口的6789端口。当然,wstunnel是可以使用ws协议的,即不使用TLS加密。

./wstunnel --server wss://0.0.0.0:6789

在客户端,下载对应平台的release压缩包,解压、赋权后直接运行以下命令,其含义为通过wss连接服务端的6789端口,在本地所有接口监听并在指定的socks5_port端口暴露socks5服务。

./wstunnel -D 0.0.0.0:<socks5_port> wss://<a.b.c.d>:6789

此时,在浏览器中,可以通过SwithyOmega或其他任何同类插件,修改代理服务器即可。代理协议为socks5、代理IP为安装wstunnel客户端的主机IP、代理端口为暴露的socks5_port端口。

wstunnel的命令行参数不多,主要是针对客户端的定义,可以通过wstunnel -h查阅。

root@ip-172-31-24-212:~# ./wstunnel
Use the websockets protocol to tunnel {TCP,UDP} traffic
wsTunnelClient <---> wsTunnelServer <---> RemoteHost
Use secure connection (wss://) to bypass proxies
Version: 6.0

wstunnel [OPTIONS] ws[s]://wstunnelServer[:port]

Client options:
  -L --localToRemote=[BIND:]PORT:HOST:PORT      Listen on local and forwards
                                                traffic from remote. Can be
                                                used multiple time
  -D --dynamicToRemote=[BIND:]PORT              Listen on local and
                                                dynamically (with socks5 proxy)
                                                forwards traffic from remote
  -u --udp                                      forward UDP traffic instead
 ... ...

2.Systemd描述文件样例

wstunnel简单到爆,但前台运行的方式很不优雅,所以还是通过systemd来进行管理。Systemd描述文件一般创建、放置于/etc/systemd/system/下,可使用如下命令。

nano /etc/systemd/system/wstunnel.service

描述文件样例中,尖括号包裹的内容是需要结合自身情况加以替换的。

[Unit]
Description = wstunnel is a tunnel tool that's so simple that you say WOCAO
After = network.target

[Service]
Type=simple
ExecStart = /<path-to-wstunnel>/wstunnel --server wss://0.0.0.0:<port>
Restart = on-failure

[Install]
WantedBy = multi-user.target

描述文件创建、编辑之后,使用如下命令加载服务文件、启动服务及设置开机自启动。

systemctl daemon-reload
systemctl start wstunnel
systemctl enable wstunnel
本作品采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 进行许可
标签: proxy vpn websocket 代理 翻墙 虚拟专用网络 隧道
最后更新:2024年5月27日

老E

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

站内搜索
归档
  • 2025 年 5 月
  • 2025 年 4 月
  • 2025 年 3 月
  • 2025 年 2 月
  • 2025 年 1 月
  • 2024 年 12 月
  • 2024 年 11 月
  • 2024 年 10 月
  • 2024 年 9 月
  • 2024 年 8 月
  • 2024 年 7 月
  • 2024 年 6 月
  • 2024 年 5 月
  • 2024 年 4 月
  • 2024 年 3 月
  • 2024 年 2 月
  • 2024 年 1 月
  • 2023 年 12 月
  • 2023 年 11 月
  • 2023 年 10 月
  • 2023 年 9 月
  • 2023 年 8 月
  • 2023 年 7 月
  • 2023 年 6 月

Copyright ©2023-2025 Appscross. All Rights Reserved.