🚀 运行: ...
IP: ...
ISP: 检测中...

跨运营商零卡顿:使用 Hysteria 2 实现 Enigma2 机顶盒全链路加密串流


在移动与联通的跨网环境下,Enigma2 机顶盒的高码率 TS 流极易卡顿。本文通过 VPS 构建两层 Hysteria 2 隧道,实现全链路加密与暴力转发。


第一阶段:移动软路由(信号源头)

#下载安装hy2
wget https://github.com/apernet/hysteria/releases/latest/download/hysteria-linux-amd64 -O /usr/bin/hysteria
chmod +x /usr/bin/hysteria
mkdir -p /etc/hysteria
#生成自签证书
openssl req -x509 -nodes -newkey rsa:4096 -keyout /etc/hysteria/server.key -out /etc/hysteria/server.crt -days 3650 -subj "/CN=Home"

1. 编写配置文件 /etc/hysteria/server.yaml

nano  /etc/hysteria/server.yaml

listen: :8099

tls:
  cert: /root/server.crt
  key: /root/server.key

auth:
  type: password
  password: "密码1"

masquerade:
  type: proxy
  proxy:
    url: https://www.bing.com
    rewriteHost: true

2. 创建自启动脚本 /etc/init.d/hysteria

nano /etc/init.d/hysteria

#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
start_service() {
    procd_open_instance
    procd_set_param command /usr/bin/hysteria server -c /etc/hysteria/server.yaml
    procd_set_param respawn
    procd_close_instance
}

运行命令:

chmod +x /etc/init.d/hysteria && /etc/init.d/hysteria enable && /etc/init.d/hysteria start

第二阶段:VPS(中转核心)

VPS 需要同时运行一个客户端(连移动)和一个服务端(接联通)。

#下载安装hy2
bash <(curl -fsSL https://get.hy2.sh/)
#生成自签证书
openssl req -x509 -nodes -newkey rsa:4096 -keyout /etc/hysteria/server.key -out /etc/hysteria/server.crt -days 3650 -subj "/CN=Home"

1. 客户端:连回移动家 (/etc/hysteria/client.yaml)

nano /etc/hysteria/client.yaml

server: 移动端域名:8099
auth: "密码1"
tls:
  insecure: true
tcpForwarding:
  - listen: :8088                #vps监听的端口
    remote: 192.168.3.111:8001   #机顶盒的内网ip和串流端口
  - listen: :8080                #vps监听的webif端口
    remote: 192.168.3.111:80     #机顶盒内网webifip和端口

2. 服务端:接待联通 (/etc/hysteria/vps_server.yaml)

listen: :4433
tls:
  cert: /etc/hysteria/server.crt
  key: /etc/hysteria/server.key
auth:
  type: password
  password: "密码2"

3. 设置 Systemd 守护进程

为两个实例创建服务文件:

客户端服务systemctl enable --now hysteria-client@client

systemctl enable --now hysteria-client@client

服务端服务(新建 /etc/systemd/system/hy2-vps-server.service):

nano  /etc/systemd/system/hy2-vps-server.service

粘贴以下内容并保存。

[Unit]
Description=Hysteria 2 Server Service
After=network.target network-online.target nss-lookup.target

[Service]
# 图中原有的内容
ExecStart=/usr/local/bin/hysteria server -c /etc/hysteria/vps_server.yaml
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

执行

systemctl enable --now hy2-vps-server

第三阶段:联通软路由(接收终端)

#下载安装hy2
wget https://github.com/apernet/hysteria/releases/latest/download/hysteria-linux-amd64 -O /usr/bin/hysteria
chmod +x /usr/bin/hysteria
mkdir -p /etc/hysteria

1. 编写配置文件 /etc/hysteria/unicom_client.yaml

nano /etc/hysteria/unicom_client.yaml

粘贴以下内容并保存。

server: vps绑定的域名:4433
auth: "密码2"
tls:
  insecure: true
tcpForwarding:
  - listen: :8088                      #联通路由器串流监听端口
    remote: 127.0.0.1:8088             #vps内网ip和暴露的监听端口
  - listen: :8080                      #联通路由器webif监听端口
    remote: 127.0.0.1:8080             #vps暴露的机顶盒webif监听端口

2. 创建自启动脚本 /etc/init.d/hy2-unicom

nano /etc/init.d/hy2-unicom

#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
start_service() {
    procd_open_instance
    procd_set_param command /usr/bin/hysteria client -c /etc/hysteria/unicom_client.yaml
    procd_set_param respawn
    procd_close_instance
}

运行命令:

chmod +x /etc/init.d/hy2-unicom && /etc/init.d/hy2-unicom enable && /etc/init.d/hy2-unicom start

📺 最终观看说明

完成上述部署后,在联通局域网内:

  1. 管理机顶盒:浏览器访问 http://联通ddns的域名:8080
  2. 播放节目:播放器(PotPlayer/VLC)访问 http://联通ddns的域名:8088

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注