Compare commits
7 Commits
0b3fdf45c2
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 51f9a1bfbc | |||
| 5c66bc599a | |||
| 1b604b502f | |||
| fee7043601 | |||
| 7440b00575 | |||
| f2cdde7c55 | |||
| fdeb904741 |
@@ -0,0 +1,904 @@
|
||||
# VPS 流量转发配置
|
||||
|
||||
基于 **Xray + Nginx SNI 分流 + Mihomo TUN 透明代理 + WireGuard**,实现:
|
||||
内网服务反向代理、多 VPS 链路中转、BT 透明代理、Minecraft UDP 转发。
|
||||
|
||||
---
|
||||
|
||||
## 设备
|
||||
|
||||
| 设备 | IP / 域名 | 角色 |
|
||||
|---|---|---|
|
||||
| **北京 VPS** | `salmonstill.cn` / `49.232.242.90` | 公网入口,Nginx + Xray + socat + WireGuard |
|
||||
| **搬瓦工 VPS** | `173.242.118.60` | 代理出口,Xray Reality 入站(客户端直连) |
|
||||
| **旁路由** | `192.168.1.199` / WG `10.0.0.2` | 内网核心,Xray bridge + Mihomo 代理 |
|
||||
| **NAS** | `192.168.1.188` | 绿联云 UGOS,思源笔记等服务 |
|
||||
| **qBittorrent** | `192.168.1.200` (macvlan) | PT 下载,独立 IP |
|
||||
| **Windows** | `192.168.1.177` | 内网办公,SSH |
|
||||
| **Spark** | `192.168.1.166` | Ubuntu 主机,本地 TUN 代理 |
|
||||
|
||||
---
|
||||
|
||||
## Nginx SNI 分流 (`beijing-vps-stream.conf`)
|
||||
|
||||
监听 `:443`,按 SNI 将流量分发到不同后端:
|
||||
|
||||
| SNI | 后端 | 端口 | 用途 |
|
||||
|---|---|---|---|
|
||||
| `www.apple.com` | Xray interconn | :9443 | 反向代理隧道 |
|
||||
| `www.microsoft.com` | Xray mihomo_in | :9444 | Mihomo 客户端 → 搬瓦工出口 |
|
||||
| `news.apple.com` | Xray proxy_from_lan | :9445 | 北京直连代理 |
|
||||
| `drive.salmonstill.cn` | NAS | :38653 | 绿联云直接转发 |
|
||||
| 默认 | NPM | :8443 | Nginx Proxy Manager |
|
||||
|
||||
搬瓦工 VPS(部署 `东京-vps-stream.conf` + `tokyo-vps-config.json`):`www.microsoft.com` → Xray :9443,默认 → NPM。
|
||||
|
||||
---
|
||||
|
||||
## Xray 核心
|
||||
|
||||
### 北京 VPS (`xray-北京vps-config.json`)
|
||||
|
||||
**Reality 入站** — 共享 privateKey `GGT9LfN_...`,由 Nginx SNI 转发:
|
||||
|
||||
| Tag | 端口 | SNI | Reality target |
|
||||
|---|---|---|---|
|
||||
| `interconn` | :9443 | `www.apple.com` | `www.apple.com:443` |
|
||||
| `mihomo_in` | :9444 | `www.microsoft.com` | `www.microsoft.com:443` |
|
||||
| `proxy_from_lan` | :9445 | `news.apple.com` | `www.apple.com:443` |
|
||||
|
||||
**dokodemo-door 入站** — 端口转发到旁路由反向隧道,共 11 个:
|
||||
|
||||
| Tag | 公网端口 | 路由目标 |
|
||||
|---|---|---|
|
||||
| `external` | 38653 | → portal → NAS :9443 |
|
||||
| `external_siyuan` | 38654 | → portal → NAS :5005 |
|
||||
| `external_minecraft` | 39132 | → portal → 旁路由 :39132 |
|
||||
| `external_wsl` | 38655 | → portal → Windows :22 |
|
||||
| `external_nas_ssh` | 38656 | → portal → NAS :22 |
|
||||
| `external_router_ssh` | 38657 | → portal → 旁路由 :22 |
|
||||
| `external_spark_ssh` | 38659 | → portal → Spark (166) :22 |
|
||||
| `external_spark_rdp` | 38660 | → portal → Spark (166) :3389 |
|
||||
| `external_spark_38662` | 38662 | → portal → Spark (166) :38662 |
|
||||
| `external_router_web` | 39766 | → portal → 旁路由 :80 |
|
||||
| `external_tmp` | 8501 | → portal → Windows :8501 |
|
||||
| `external_gitea` | 38661 | → portal → NAS :3000 |
|
||||
| `external_222` | 222 | → portal → NAS :222 |
|
||||
| `external_qbit` | 51413 | → portal → qBittorrent :51413 |
|
||||
|
||||
**其他入站**:
|
||||
|
||||
| Tag | 端口 | 类型 | 用途 |
|
||||
|---|---|---|---|
|
||||
| `proxy_in` | 10809 | mixed | SOCKS5/HTTP 代理 → 搬瓦工出口 |
|
||||
| `socks-dynamic` | 38658 | SOCKS5 (password) | 动态 LAN 端口访问 |
|
||||
|
||||
**出站**:`direct`(freedom 直连)、`to_tokyo`(VLESS+Reality → `173.242.118.60:443`)
|
||||
|
||||
**路由**:所有 `external_*` + `interconn` + `socks-dynamic` → `portal`(反向隧道);`mihomo_in` + `proxy_in` → `to_tokyo`;`proxy_from_lan` → `direct`
|
||||
|
||||
### 旁路由 (`xray-旁路由-config.json`)
|
||||
|
||||
**Bridge 入站**:与北京 VPS 的 Portal 建立永久反向隧道。
|
||||
|
||||
**出站**(14 个):
|
||||
|
||||
| Tag | 目标 | 用途 |
|
||||
|---|---|---|
|
||||
| `to_nas` | `192.168.1.188:9443` | NAS 管理 |
|
||||
| `to_siyuan` | `192.168.1.188:5005` | 思源笔记 |
|
||||
| `to_wsl` | `192.168.1.177:22` | WSL SSH |
|
||||
| `to_nas_ssh` | `192.168.1.188:22` | NAS SSH |
|
||||
| `to_router_ssh` | `192.168.1.199:22` | 旁路由 SSH |
|
||||
| `to_router_web` | `192.168.1.199:80` | 旁路由 Web |
|
||||
| `to_minecraft` | `127.0.0.1:39132` | Minecraft 服务 |
|
||||
| `to_tmp` | `192.168.1.177:8501` | 临时服务 |
|
||||
| `to_3000` | `192.168.1.188:3000` | Web 服务 |
|
||||
| `to_222` | `192.168.1.188:222` | 备用服务 |
|
||||
| `to_qbit` | `192.168.1.200:51413` | qBittorrent 入站 |
|
||||
| `to_spark_ssh` | `192.168.1.166:22` | Spark SSH 远程 |
|
||||
| `to_spark_rdp` | `192.168.1.166:3389` | Spark xRDP 桌面远程 |
|
||||
| `to_spark_38662` | `192.168.1.166:38662` | Spark 自定义服务 |
|
||||
| `interconn` | VLESS+Reality → `salmonstill.cn:443` (SNI=www.apple.com) | 隧道链接 |
|
||||
| `to_beijing_direct` | VLESS+Reality → `salmonstill.cn:443` (SNI=news.apple.com) | 北京直连 |
|
||||
| `direct` | freedom | 直连 |
|
||||
|
||||
**路由规则**(bridge 入站按端口匹配):
|
||||
- 38653 → `to_nas`(NAS 管理)
|
||||
- 38654 → `to_siyuan`
|
||||
- 38655 → `to_wsl`
|
||||
- 38656 → `to_nas_ssh`
|
||||
- 38657 → `to_router_ssh`
|
||||
- 8501 → `to_tmp`
|
||||
- 39766 → `to_router_web`
|
||||
- 38661 → `to_3000`
|
||||
- 222 → `to_222`
|
||||
- 39132 → `to_minecraft`
|
||||
- 51413 → `to_qbit`
|
||||
- 38658 → `direct`(SOCKS5 动态回家,直接连接目标地址)
|
||||
- 38659 → `to_spark_ssh`(Spark SSH 远程)
|
||||
- 38660 → `to_spark_rdp`(Spark xRDP 桌面远程)
|
||||
- 38662 → `to_spark_38662`
|
||||
- 默认(catch-all)→ **`direct`**(不匹配端口规则的动态请求直连目标)
|
||||
- `socks-lan` 入站 → `to_beijing_direct`
|
||||
|
||||
> 所有显式端口规则优先于 catch-all,现有端口转发不受影响。
|
||||
|
||||
### 搬瓦工 VPS / 洛杉矶 (`tokyo-vps-config.json`)
|
||||
|
||||
极简:VLESS+Reality 入站 `:9443`(SNI=www.microsoft.com),freedom 出站。
|
||||
所有客户端(Spark、旁路由、macOS)直连此服务器,不再经北京 VPS 中转。
|
||||
|
||||
---
|
||||
|
||||
## Mihomo
|
||||
|
||||
### 旁路由 (`旁路由的mihomo config.yaml`)
|
||||
|
||||
**纯代理模式** — 无内核级劫持,提供多端口代理服务供客户端手动指定:
|
||||
|
||||
| 端口 | 类型 | 路由 | 用途 |
|
||||
|---|---|---|---|
|
||||
| `7890` | mixed | 按规则分流 | 本地服务默认代理 |
|
||||
| `7891` | mixed | 全部走 US-Direct | 全局国外代理 |
|
||||
| `7892` | mixed | 全部直连 | 全局国内直连 |
|
||||
|
||||
配合 **fake-ip DNS**(`enhanced-mode: fake-ip`),DNS 请求返回 `198.18.x.x` 假 IP,强制流量进入代理路由。
|
||||
|
||||
**代理节点**:
|
||||
- `US-Direct` — VLESS+Reality → `173.242.118.60:443`(默认国外出口,客户端直连搬瓦工)
|
||||
|
||||
**关键策略组**:
|
||||
- 国外 → `[US-Direct, 直连]`
|
||||
|
||||
**防死循环 IP**:`49.232.242.90`(北京 VPS)、`173.242.118.60`(搬瓦工 VPS)强制直连。
|
||||
|
||||
**额外监听器**:`:7891`(全局→US-Direct)、`:7892`(强制直连)
|
||||
|
||||
### macOS (`非tun模式的主机mihomo config.yaml`)
|
||||
|
||||
结构与旁路由一致,无 TUN,监听器 `:7890` + `:7891` + `:7892`。
|
||||
|
||||
**重启**(launchctl 管理):
|
||||
```bash
|
||||
launchctl unload ~/Library/LaunchAgents/com.mihomo.proxy.plist
|
||||
launchctl load ~/Library/LaunchAgents/com.mihomo.proxy.plist
|
||||
```
|
||||
|
||||
### Ubuntu / Spark (`tun模式的主机mihomo config.yaml`)
|
||||
|
||||
本地 TUN 模式(`stack: system`),不依赖旁路由网关。设备重启后 `auto-route` 自建路由表,稳定可靠。监听器 `:7890` + `:7891` + `:7892`,节点直连 US-Direct。
|
||||
|
||||
|
||||
|
||||
## qBittorrent 透明代理
|
||||
|
||||
### 架构总览
|
||||
|
||||
```
|
||||
出站(SOCKS5 代理)
|
||||
qBittorrent(192.168.1.200) 互联网
|
||||
↓ SOCKS5 旁路由:1080 (socks-lan) ↑
|
||||
↓ Xray routing → to_beijing_direct │
|
||||
↓ Reality(VLESS, SNI=news.apple.com) │
|
||||
↓ 北京VPS:443 → Nginx分流 │
|
||||
↓ proxy_from_lan:9445 → direct(freedom) ─────────────────┘
|
||||
|
||||
入站(端口转发)
|
||||
Peer → 北京VPS:51413 → external_qbit → portal
|
||||
→ bridge隧道 → 旁路由 → to_qbit → 192.168.1.200:51413
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 设备清单
|
||||
|
||||
| 设备 | IP | 角色 |
|
||||
|---|---|---|
|
||||
| 北京VPS | `salmonstill.cn` / `49.232.242.90` | 公网出口 + 入站入口 |
|
||||
| 旁路由 | `192.168.1.199` | Xray 桥接 + SOCKS5 代理 |
|
||||
| NAS | `192.168.1.188` | Docker 宿主机 |
|
||||
| qBittorrent 容器 | `192.168.1.200` | macvlan 独立 IP,PT 专用 |
|
||||
|
||||
---
|
||||
|
||||
### 第一部分:北京 VPS 配置
|
||||
|
||||
#### 1.1 Nginx Stream SNI 分流 `beijing-vps-stream.conf`
|
||||
|
||||
新增 `news.apple.com` SNI 映射(用于旁路由 Mihomo 直连代理):
|
||||
|
||||
```nginx
|
||||
stream {
|
||||
map $ssl_preread_server_name $backend {
|
||||
www.apple.com xray; # 旁路由反向代理隧道
|
||||
www.microsoft.com mihomo; # 外部客户端代理 → 东京出口
|
||||
news.apple.com xray_lan; # 旁路由 Mihomo 北京直连代理
|
||||
drive.salmonstill.cn nas; # 绿联云服务
|
||||
default npm; # Nginx Proxy Manager
|
||||
}
|
||||
upstream xray { server 127.0.0.1:9443; }
|
||||
upstream mihomo { server 127.0.0.1:9444; }
|
||||
upstream xray_lan { server 127.0.0.1:9445; } # 新增
|
||||
upstream nas { server 127.0.0.1:38653; }
|
||||
upstream npm { server 127.0.0.1:8443; }
|
||||
|
||||
server {
|
||||
listen 443 reuseport;
|
||||
listen [::]:443 reuseport;
|
||||
ssl_preread on;
|
||||
proxy_pass $backend;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 1.2 Xray 配置 `xray-北京vps-config.json`
|
||||
|
||||
##### 新增入站 `proxy_from_lan`(北京直连出口)
|
||||
|
||||
```json
|
||||
{
|
||||
"tag": "proxy_from_lan",
|
||||
"listen": "127.0.0.1",
|
||||
"port": 9445,
|
||||
"protocol": "vless",
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "113e167a-a2be-4b46-9010-60020108626c",
|
||||
"flow": "xtls-rprx-vision"
|
||||
}
|
||||
],
|
||||
"decryption": "none"
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "raw",
|
||||
"security": "reality",
|
||||
"realitySettings": {
|
||||
"show": false,
|
||||
"target": "www.apple.com:443",
|
||||
"serverNames": ["news.apple.com"],
|
||||
"privateKey": "GGT9LfN_2JdQG68cwrULgUK-adfT6wIokLzWjaB0fXs",
|
||||
"shortIds": ["7c947a71b94f369e"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> Reality 公私钥复用已有的 `interconn` 入站 keypair,`serverNames` 用新的 `news.apple.com` 与 Nginx 对应。
|
||||
> `target` 设为 `www.apple.com:443`,Reality 从此地址偷取真实 TLS 证书用于伪装。
|
||||
|
||||
##### 新增入站 `external_qbit`(BT 入站端口)
|
||||
|
||||
```json
|
||||
{
|
||||
"tag": "external_qbit",
|
||||
"listen": "0.0.0.0",
|
||||
"port": 51413,
|
||||
"protocol": "dokodemo-door",
|
||||
"settings": {
|
||||
"address": "127.0.0.1",
|
||||
"port": 51413,
|
||||
"network": "tcp"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> 仅 TCP——Xray portal 反向代理对 UDP 支持不完善,BT 的 μTP(UDP) 走不了,需要在 qBittorrent 里关闭。
|
||||
|
||||
##### 新增路由规则
|
||||
|
||||
```json
|
||||
{ "type": "field", "inboundTag": ["proxy_from_lan"], "outboundTag": "direct" },
|
||||
{ "type": "field", "inboundTag": ["external_qbit"], "outboundTag": "portal" }
|
||||
```
|
||||
|
||||
#### 1.3 腾讯云防火墙
|
||||
|
||||
新开端口:
|
||||
|
||||
| 端口 | 协议 | 用途 |
|
||||
|---|---|---|
|
||||
| 51413 | TCP | BT 入站 |
|
||||
|
||||
---
|
||||
|
||||
### 第二部分:旁路由 Xray SOCKS5 出站代理
|
||||
|
||||
#### 2.1 配置 `xray-旁路由-config.json`
|
||||
|
||||
qBittorrent 出站不走 Mihomo 透明代理,而是通过旁路由上 Xray 的 `socks-lan` 入站(`:1080`),直接转发到北京 VPS 直连出口。
|
||||
|
||||
##### SOCKS5 入站
|
||||
|
||||
```json
|
||||
{
|
||||
"tag": "socks-lan",
|
||||
"port": 1080,
|
||||
"listen": "0.0.0.0",
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
"auth": "noauth",
|
||||
"udp": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### 出站 `to_beijing_direct`
|
||||
|
||||
```json
|
||||
{
|
||||
"tag": "to_beijing_direct",
|
||||
"protocol": "vless",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "salmonstill.cn",
|
||||
"port": 443,
|
||||
"users": [
|
||||
{
|
||||
"id": "113e167a-a2be-4b46-9010-60020108626c",
|
||||
"flow": "xtls-rprx-vision",
|
||||
"encryption": "none"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "raw",
|
||||
"security": "reality",
|
||||
"realitySettings": {
|
||||
"fingerprint": "chrome",
|
||||
"serverName": "news.apple.com",
|
||||
"publicKey": "62y5gDjPrdeuePGl-D2IW4Cw9Kb8_bSBBTmArvL7Nhs",
|
||||
"shortId": "7c947a71b94f369e"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### 路由规则
|
||||
|
||||
```json
|
||||
{ "type": "field", "inboundTag": ["socks-lan"], "outboundTag": "to_beijing_direct" }
|
||||
```
|
||||
|
||||
> 路径:`qBittorrent → SOCKS5 旁路由:1080 → to_beijing_direct → 北京VPS:443(SNI=news.apple.com) → proxy_from_lan:9445 → direct → 互联网`
|
||||
|
||||
---
|
||||
|
||||
### 第三部分:旁路由 Xray 51413 转发
|
||||
|
||||
#### 3.1 配置 `xray-旁路由-config.json`
|
||||
|
||||
##### 新增加出站 `to_qbit`
|
||||
|
||||
```json
|
||||
{
|
||||
"tag": "to_qbit",
|
||||
"protocol": "freedom",
|
||||
"settings": {
|
||||
"redirect": "192.168.1.200:51413"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### 新增路由规则
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": ["bridge"],
|
||||
"port": "51413",
|
||||
"outboundTag": "to_qbit"
|
||||
}
|
||||
```
|
||||
|
||||
> 放在 bridge 下——从北京 VPS 的 portal 通过反向隧道过来的 BT 入站流量,由 bridge 接收后按端口 51413 匹配到此规则,转发到 qBittorrent 容器。
|
||||
|
||||
---
|
||||
|
||||
### 第四部分:NAS qBittorrent Docker
|
||||
|
||||
#### 4.1 创建 macvlan 网络
|
||||
|
||||
```bash
|
||||
docker network create -d macvlan \
|
||||
--subnet=192.168.1.0/24 \
|
||||
--gateway=192.168.1.199 \
|
||||
--ip-range=192.168.1.200/32 \
|
||||
-o parent=eth0 \
|
||||
qbit_macvlan
|
||||
```
|
||||
|
||||
> `--gateway=192.168.1.199`:qBittorrent 的默认网关设为旁路由,确保出站流量经过旁路由。
|
||||
> `--ip-range=192.168.1.200/32`:固定 IP。
|
||||
|
||||
#### 4.2 启动容器
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name qbittorrent \
|
||||
--network qbit_macvlan \
|
||||
--ip 192.168.1.200 \
|
||||
-e WEBUI_PORT=8090 \
|
||||
-p 8090:8090 \
|
||||
-v /path/to/downloads:/downloads \
|
||||
lscr.io/linuxserver/qbittorrent:latest
|
||||
```
|
||||
|
||||
#### 4.3 qBittorrent 设置
|
||||
|
||||
| 设置项 | 值 |
|
||||
|---|---|
|
||||
| 监听端口 | `51413` |
|
||||
| UPnP/NAT-PMP | **禁用** |
|
||||
| SOCKS5 代理 | `192.168.1.199` / 端口 `1080` |
|
||||
| 连接协议 | **仅 TCP**(关闭 μTP) |
|
||||
| DHT | 可选(建议开) |
|
||||
| PEX | 可选(建议开) |
|
||||
|
||||
> 关闭 μTP(UDP):Xray portal 反向代理不支持 UDP,BT 的 μTP 走 UDP 会导致入站失败。
|
||||
|
||||
#### 4.4 定时做种调度(crontab)
|
||||
|
||||
让 qBittorrent 只在夜间(01:00-07:00)做种,白天暂停以节省带宽:
|
||||
|
||||
```bash
|
||||
crontab -e
|
||||
```
|
||||
|
||||
添加以下两行(在 NAS 或任意可访问 192.168.1.200 的设备上):
|
||||
|
||||
```
|
||||
0 1 * * * curl -s -X POST "http://192.168.1.200:8888/api/v2/torrents/start" --data "hashes=all"
|
||||
0 7 * * * curl -s -X POST "http://192.168.1.200:8888/api/v2/torrents/stop" --data "hashes=all"
|
||||
```
|
||||
|
||||
| 时间 | 操作 | 含义 |
|
||||
|---|---|---|
|
||||
| 凌晨 01:00 | `/torrents/start` `hashes=all` | 启动全部种子开始做种 |
|
||||
| 早上 07:00 | `/torrents/stop` `hashes=all` | 停止全部种子 |
|
||||
|
||||
---
|
||||
|
||||
### 第五部分:部署顺序
|
||||
|
||||
```
|
||||
1. 腾讯云防火墙 → 开放 51413/tcp
|
||||
2. scp beijing-vps-stream.conf → 北京VPS /etc/nginx/stream.conf.d/
|
||||
3. scp xray-北京vps-config.json → 北京VPS /usr/local/etc/xray/config.json
|
||||
4. 北京VPS: nginx -t && systemctl reload nginx
|
||||
5. 北京VPS: systemctl restart xray
|
||||
6. scp 旁路由的mihomo config.yaml → 旁路由 /opt/mihomo/config.yaml
|
||||
7. scp xray-旁路由-config.json → 旁路由 /etc/xray/config.json
|
||||
8. 旁路由: /etc/init.d/mihomo restart
|
||||
9. 旁路由: /etc/init.d/xray restart
|
||||
10. NAS: 创建 macvlan 网络 + 启动 qBittorrent 容器
|
||||
11. NAS: 配置 qBittorrent 监听端口 51413,关闭 μTP
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 第六部分:验证
|
||||
|
||||
#### 6.1 SOCKS5 代理出站验证
|
||||
|
||||
```bash
|
||||
# 在 NAS 上执行,应返回北京 VPS 的公网 IP
|
||||
docker exec qbittorrent curl --socks5 192.168.1.199:1080 https://ip.sb
|
||||
```
|
||||
|
||||
#### 6.2 Xray 日志确认
|
||||
|
||||
```bash
|
||||
# 旁路由上查看 Xray 日志,确认 socks-lan 流量转发正常
|
||||
tail -f /var/log/xray.log | grep socks-lan
|
||||
```
|
||||
|
||||
#### 6.3 BT 入站验证
|
||||
|
||||
```bash
|
||||
# 北京 VPS 上确认端口监听
|
||||
ss -tlnp | grep 51413
|
||||
|
||||
# 从外部测试端口可达
|
||||
nc -zv salmonstill.cn 51413
|
||||
```
|
||||
|
||||
#### 6.4 端到端 BT 测试
|
||||
|
||||
下载一个热门 Ubuntu torrent 种子,观察:
|
||||
- qBittorrent WebUI → 连接 → 应显示 DHT 节点数增长
|
||||
- 跟踪器页面 → 应显示 "Working"
|
||||
- 下载速度应有上传来确认入站工作
|
||||
|
||||
---
|
||||
|
||||
### 第七部分:故障排查
|
||||
|
||||
| 现象 | 排查 |
|
||||
|---|---|
|
||||
| qBittorrent curl ip.sb 返回真实 IP | SOCKS5 代理未生效,检查 qBittorrent 设置中代理配置 |
|
||||
| 代理连不上 | 确认 旁路由 Xray 正在运行且 `socks-lan` 入站监听 :1080 |
|
||||
| 入站无上传 | 检查北京 VPS ufw/腾讯云安全组已放行 51413/tcp |
|
||||
| xray 报错 `reverse-proxy.xray.internal` | portal/bridge 域名不匹配,两边必须一致 |
|
||||
| 下载有速度、无上传 | μTP 没关或 portal UDP 不支持,qBittorrent 设置仅 TCP |
|
||||
|
||||
---
|
||||
|
||||
### 第八部分:文件清单
|
||||
|
||||
| 文件 | 位置 | 作用 |
|
||||
|---|---|---|
|
||||
| `beijing-vps-stream.conf` | 北京VPS `/etc/nginx/stream.conf.d/` | Nginx SNI分流(含 news.apple.com → 9445) |
|
||||
| `xray-北京vps-config.json` | 北京VPS `/usr/local/etc/xray/config.json` | Xray 入站+路由(含 proxy_from_lan + external_qbit) |
|
||||
| `xray-旁路由-config.json` | 旁路由 `/etc/xray/config.json` | Xray bridge + to_qbit(51413) + socks-lan(1080) → to_beijing_direct |
|
||||
|
||||
## Minecraft UDP 转发
|
||||
|
||||
### 架构
|
||||
|
||||
```
|
||||
公网玩家 (UDP 19132)
|
||||
↓
|
||||
北京VPS (salmonstill.cn)
|
||||
socat 监听 19132 → 转发到 10.0.0.2:19132
|
||||
↓ WireGuard 隧道
|
||||
旁路由 ImmortalWrt (192.168.1.199 / 10.0.0.2)
|
||||
nftables 端口转发 + SNAT
|
||||
↓
|
||||
NAS (192.168.1.188:19132)
|
||||
↓
|
||||
Minecraft 基岩版 Docker 容器
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 设备信息
|
||||
|
||||
| 设备 | IP | 系统 |
|
||||
|---|---|---|
|
||||
| 北京VPS | `salmonstill.cn` / `49.232.242.90` | Ubuntu 22.04 |
|
||||
| 旁路由 | `192.168.1.199` / WG隧道: `10.0.0.2` | ImmortalWrt 24.10 (GL-MT2500) |
|
||||
| NAS | `192.168.1.188` | 绿联云 UGOS |
|
||||
|
||||
---
|
||||
|
||||
### 第一部分:北京VPS 配置
|
||||
|
||||
#### WireGuard 配置 `/etc/wireguard/wg0.conf`
|
||||
|
||||
```ini
|
||||
[Interface]
|
||||
Address = 10.0.0.1/24
|
||||
ListenPort = 51820
|
||||
PrivateKey = <北京VPS私钥>
|
||||
MTU = 1420
|
||||
|
||||
# 回包源地址转换(必须,否则公网玩家收不到回包)
|
||||
PostUp = iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
|
||||
PostDown = iptables -t nat -D POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
|
||||
|
||||
[Peer]
|
||||
# 旁路由
|
||||
PublicKey = 9jPlaUhx2Dc+C5ZqJx6Iu8GtNMig3cFIoqfHg8PZbCA=
|
||||
AllowedIPs = 10.0.0.2/32
|
||||
PersistentKeepalive = 25
|
||||
```
|
||||
|
||||
> ⚠️ 不使用 iptables DNAT 转发,改用 socat 处理 UDP 转发,避免 conntrack 连接跟踪问题导致回包丢失。
|
||||
|
||||
#### 开启内核转发
|
||||
|
||||
```bash
|
||||
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
|
||||
sysctl -p
|
||||
```
|
||||
|
||||
#### 开放防火墙端口
|
||||
|
||||
```bash
|
||||
ufw allow 51820/udp # WireGuard
|
||||
ufw allow 19132/udp # Minecraft 基岩版
|
||||
```
|
||||
|
||||
#### 启动 WireGuard
|
||||
|
||||
```bash
|
||||
systemctl enable wg-quick@wg0
|
||||
systemctl start wg-quick@wg0
|
||||
```
|
||||
|
||||
#### socat UDP 转发
|
||||
|
||||
socat 监听公网 19132 端口,收到包后转发给旁路由隧道 IP,并维护连接状态确保回包正确返回。
|
||||
|
||||
创建 systemd service:
|
||||
|
||||
```bash
|
||||
nano /etc/systemd/system/mc-forward.service
|
||||
```
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Minecraft UDP Forward
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/socat UDP4-LISTEN:19132,fork,reuseaddr UDP4:10.0.0.2:19132
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
启动并设置开机自启:
|
||||
|
||||
```bash
|
||||
systemctl daemon-reload
|
||||
systemctl enable mc-forward
|
||||
systemctl start mc-forward
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 第二部分:旁路由 ImmortalWrt 配置
|
||||
|
||||
#### WireGuard 接口配置
|
||||
|
||||
路径:**网络 → 接口 → 添加新接口**
|
||||
|
||||
**常规设置:**
|
||||
|
||||
| 字段 | 值 |
|
||||
|---|---|
|
||||
| 接口名称 | `WireGuard` |
|
||||
| 协议 | `WireGuard VPN` |
|
||||
| 私钥 | `<旁路由私钥>` |
|
||||
| IP 地址 | `10.0.0.2/24` |
|
||||
| 监听端口 | 不填 |
|
||||
|
||||
**防火墙设置:** 加入 `wan` 区域
|
||||
|
||||
**Peers → 添加对端:**
|
||||
|
||||
| 字段 | 值 |
|
||||
|---|---|
|
||||
| 公钥 | `n159R7bNB+tW3Br0cok2zA27Pzg2WSPTI9uQ9odOFyU=` |
|
||||
| 端点主机 | `salmonstill.cn` |
|
||||
| 端点端口 | `51820` |
|
||||
| 允许的 IP | `0.0.0.0/0` |
|
||||
| 路由允许的 IP | ✅ 勾选 |
|
||||
| 持续 Keep-Alive | `25` |
|
||||
|
||||
> ⚠️ 允许的 IP 必须设为 `0.0.0.0/0`,否则 WireGuard 会丢弃来自公网玩家 IP 的包。
|
||||
|
||||
#### 端口转发配置
|
||||
|
||||
路径:**网络 → 防火墙 → 端口转发 → 添加**
|
||||
|
||||
| 字段 | 值 |
|
||||
|---|---|
|
||||
| 名称 | `Minecraft-udp` |
|
||||
| 协议 | `UDP` |
|
||||
| 源区域 | `wan` |
|
||||
| 外部端口 | `19132` |
|
||||
| 目标区域 | `lan` |
|
||||
| 内部 IP 地址 | `192.168.1.188` |
|
||||
| 内部端口 | `19132` |
|
||||
|
||||
#### SNAT 配置
|
||||
|
||||
路径:**网络 → 防火墙 → NAT 规则 → 添加**
|
||||
|
||||
| 字段 | 值 |
|
||||
|---|---|
|
||||
| 名称 | `minecraft-snat` |
|
||||
| 地址族限制 | `仅 IPv4` |
|
||||
| 协议 | `UDP` |
|
||||
| 出站区域 | `lan` |
|
||||
| 目标地址 | `192.168.1.188` |
|
||||
| 目标端口 | `19132` |
|
||||
| 操作 | `SNAT - 重写为特定的源 IP 或端口` |
|
||||
| 重写 IP 地址 | `192.168.1.199` |
|
||||
|
||||
> SNAT 的作用:将转发给 NAS 的包源 IP 改为旁路由 IP,确保 NAS 的回包发回给旁路由而不是直接走主路由,避免回包路径不对称。
|
||||
|
||||
---
|
||||
|
||||
### 第三部分:NAS Docker 配置
|
||||
|
||||
使用 `network_mode: host` 避免 Docker NAT 导致的 IP 映射问题。
|
||||
|
||||
```yaml
|
||||
services:
|
||||
bedrock:
|
||||
image: itzg/minecraft-bedrock-server:2026.2.1
|
||||
container_name: mc-bedrock
|
||||
network_mode: host
|
||||
stdin_open: true
|
||||
tty: true
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
VERSION: "1.26.14.1"
|
||||
TZ: "Asia/Shanghai"
|
||||
OPS: "2535472561115036"
|
||||
volumes:
|
||||
- /volume2/ProgramsV2/minecraft:/data
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 第四部分:验证
|
||||
|
||||
#### 检查 WireGuard 隧道
|
||||
|
||||
```bash
|
||||
# 旁路由
|
||||
wg show
|
||||
# 正常应有 latest handshake 和双向 transfer
|
||||
```
|
||||
|
||||
#### 检查 socat 运行状态
|
||||
|
||||
```bash
|
||||
systemctl status mc-forward
|
||||
```
|
||||
|
||||
#### 抓包验证完整链路
|
||||
|
||||
```bash
|
||||
# VPS 上抓 wg0,确认双向流量
|
||||
tcpdump -i wg0 udp port 19132 -n
|
||||
|
||||
# 旁路由抓 br-lan,确认转发到 NAS
|
||||
tcpdump -i br-lan udp port 19132 -n
|
||||
|
||||
# NAS 上抓包,确认收到并回包
|
||||
sudo tcpdump -i bridge0 udp port 19132 -n
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 故障排查
|
||||
|
||||
| 现象 | 排查方法 |
|
||||
|---|---|
|
||||
| WireGuard 无握手 | 检查 VPS 防火墙 51820/udp 是否开放 |
|
||||
| socat 收不到包 | 检查 ufw 19132/udp 是否开放 |
|
||||
| 旁路由收不到包 | 检查 WireGuard AllowedIPs 是否为 `0.0.0.0/0` |
|
||||
| NAS 收不到包 | 检查端口转发内部端口是否填写正确 |
|
||||
| NAS 有回包但玩家连不上 | 检查 SNAT 规则是否生效,确认 NAS 用 host 网络模式 |
|
||||
| 游戏内延迟不显示 | 检查 socat 是否正常运行,DNAT 规则是否已删除 |
|
||||
|
||||
---
|
||||
|
||||
### 扩展:新增其他 UDP 服务
|
||||
|
||||
1. VPS 新建一个 socat service,修改端口号
|
||||
2. 旁路由 LuCI 端口转发新增一条规则
|
||||
3. `ufw allow <新端口>/udp`
|
||||
---
|
||||
|
||||
## SOCKS5 动态 LAN 端口访问
|
||||
|
||||
通过新增的 `socks-dynamic` 入站(`:38658`,密码认证),可从外部访问任意内网 IP:PORT,无需事先配置端口规则。
|
||||
|
||||
```
|
||||
浏览器 SOCKS5 → salmonstill.cn:38658
|
||||
→ 北京VPS socks-dynamic → portal → 反向隧道
|
||||
→ 旁路由 bridge → catch-all direct → 任意 LAN IP:PORT
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Reality 密钥
|
||||
|
||||
| 位置 | Private Key | Public Key (客户端用) |
|
||||
|---|---|---|
|
||||
| **北京 VPS**(3 个入站共用) | `GGT9LfN_2JdQG68cwrULgUK-adfT6wIokLzWjaB0fXs` | `62y5gDjPrdeuePGl-D2IW4Cw9Kb8_bSBBTmArvL7Nhs` |
|
||||
| **搬瓦工 VPS**(客户端直连) | `iBlu3eH1VLf1S5Qw87m_1w0TGYUktDwHAzgpQ2aKuGI` | `jr_zQjC4mvlQITuG5Ap5Mxqe5EBbGyyvwbVLDEi8OCA` |
|
||||
|
||||
`Beijing-Direct` 节点必须 `skip-cert-verify: true`,因 Reality 返回 target(`www.apple.com`)的证书,而 SNI 是 `news.apple.com`,TLS SAN 校验会失败。
|
||||
|
||||
---
|
||||
|
||||
## 流量路径
|
||||
|
||||
### 路径 1:内网服务反向代理
|
||||
```
|
||||
用户 → salmonstill.cn:端口 → dokodemo-door → portal → 隧道 → bridge
|
||||
→ 端口匹配出站 → 内网目标 → 原路返回
|
||||
```
|
||||
|
||||
### 路径 2:代理翻墙(直连搬瓦工)
|
||||
```
|
||||
Mihomo 客户端 → 173.242.118.60:443 (SNI=www.microsoft.com)
|
||||
→ Nginx 分流 → Xray :9443 → freedom → 互联网
|
||||
```
|
||||
|
||||
### 路径 3:qBittorrent 代理出站
|
||||
```
|
||||
qBittorrent → SOCKS5 旁路由:1080 → Xray to_beijing_direct
|
||||
→ salmonstill.cn:443 (SNI=news.apple.com) → proxy_from_lan → direct → 互联网
|
||||
```
|
||||
|
||||
### 路径 4:BT 入站
|
||||
```
|
||||
BT Peer → salmonstill.cn:51413 → portal → 隧道 → bridge → to_qbit → 1.200:51413
|
||||
```
|
||||
|
||||
### 路径 5:Minecraft UDP
|
||||
```
|
||||
公网玩家 → salmonstill.cn:19132 → socat → WireGuard → 旁路由 → NAS :19132
|
||||
```
|
||||
|
||||
### 路径 6:SOCKS5 动态回家
|
||||
```
|
||||
浏览器 SOCKS5 → salmonstill.cn:38658 → socks-dynamic → portal → 隧道
|
||||
→ bridge → catch-all direct → 任意 LAN IP:PORT
|
||||
```
|
||||
|
||||
|
||||
|
||||
| 文件 | 目标设备 | 部署路径 |
|
||||
|---|---|---|
|
||||
| `beijing-vps-stream.conf` | 北京 VPS | `/etc/nginx/stream.conf.d/` |
|
||||
| `xray-北京vps-config.json` | 北京 VPS | `/usr/local/etc/xray/config.json` |
|
||||
| `东京-vps-stream.conf` | 搬瓦工 VPS | `/etc/nginx/stream.conf.d/` |
|
||||
| `tokyo-vps-config.json` | 搬瓦工 VPS | `/usr/local/etc/xray/config.json` |
|
||||
| `xray-旁路由-config.json` | 旁路由 | `/etc/xray/config.json` |
|
||||
| `旁路由的mihomo config.yaml` | 旁路由 | `/opt/mihomo/config.yaml` |
|
||||
| `非tun模式的主机mihomo config.yaml` | macOS | `~/Library/LaunchAgents/` (launchctl 管理) |
|
||||
| `tun模式的主机mihomo config.yaml` | Spark (Ubuntu) | `/opt/mihomo/config.yaml` (systemd) |
|
||||
| `subscribe-7891-only.yaml` | 通用 | 精简版模板(单独 7891 端口) |
|
||||
| `qbittorrent流量转发.md` | — | 方案文档(已合并到 README,可删除) |
|
||||
| `我的世界udp转发.md` | — | 方案文档(已合并到 README,可删除) |
|
||||
|
||||
---
|
||||
|
||||
## 部署流程
|
||||
|
||||
```
|
||||
1. 腾讯云防火墙开放端口(443, 51413/tcp, 51820/udp, 19132/udp)
|
||||
2. 北京 VPS: 部署 Nginx stream → nginx -t && systemctl reload nginx
|
||||
3. 北京 VPS: 部署 Xray → systemctl restart xray
|
||||
4. 北京 VPS: 部署 WireGuard → wg-quick@wg0
|
||||
5. 北京 VPS: 部署 socat → systemctl start mc-forward
|
||||
6. 搬瓦工 VPS: 部署 Nginx + Xray
|
||||
7. 旁路由: 部署 Xray → /etc/init.d/xray restart
|
||||
8. 旁路由: 部署 Mihomo → /etc/init.d/mihomo restart
|
||||
9. 旁路由: 配置 WireGuard + 端口转发 + SNAT(LuCI)
|
||||
10. NAS: 创建 macvlan 网络 → 启动 qBittorrent 容器
|
||||
11. NAS: 启动 Minecraft 容器
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 验证命令
|
||||
|
||||
```bash
|
||||
# 北京 VPS
|
||||
ss -tlnp | grep -E '944[345]|3865[3-8]|51413|10809'
|
||||
systemctl status nginx xray wg-quick@wg0 mc-forward
|
||||
|
||||
# 搬瓦工 VPS
|
||||
ss -tlnp | grep -E '443|9443'
|
||||
systemctl status nginx xray
|
||||
|
||||
# 旁路由
|
||||
ss -tlnp | grep -E '789[0-2]|1080' # Mihomo 端口 + Xray socks-lan
|
||||
mihomo -d /opt/mihomo -t # 配置文件校验
|
||||
tail /opt/mihomo/logs/mihomo.log | grep INFO # 确认代理无报错
|
||||
wg show
|
||||
|
||||
# qBittorrent 连通性
|
||||
docker exec qbittorrent curl -s https://ip.sb # 应返回北京 VPS IP
|
||||
|
||||
# Minecraft
|
||||
systemctl status mc-forward
|
||||
tcpdump -i wg0 udp port 19132 -n
|
||||
```
|
||||
-508
@@ -1,508 +0,0 @@
|
||||
# VPS流量转发架构说明
|
||||
|
||||
---
|
||||
|
||||
## 总览
|
||||
|
||||
这套架构基于 **Xray + Nginx SNI 分流 + Mihomo 透明代理 + WireGuard**,实现:
|
||||
|
||||
1. **反向代理内网服务到公网**(无需公网 IPv6/端口映射)
|
||||
2. **异地多 VPS 链路中转代理**(Mihomo 客户端接入 → 东京出口)
|
||||
3. **统一公网入口流量管理**(所有流量走 443 端口,无额外端口暴露)
|
||||
4. **qBittorrent 透明代理 + 入站端口转发**(NAS PT 下载走北京 VPS 出口,支持 BT 入站连接)
|
||||
5. **Minecraft 基岩版 UDP 转发**(独立 WireGuard 隧道 + socat 方案)
|
||||
|
||||
---
|
||||
|
||||
## 设备清单
|
||||
|
||||
| 设备 | IP / 域名 | 系统 / 型号 | 角色 |
|
||||
|---|---|---|---|
|
||||
| **北京 VPS** | `salmonstill.cn` / `49.232.242.90` | Ubuntu 22.04 | 公网入口节点,Nginx + Xray + socat + WireGuard |
|
||||
| **东京 VPS** | `tokyo.salmonstill.cn` / `43.165.178.10` | - | 代理出口节点,Xray Reality 出站 |
|
||||
| **旁路由** | `192.168.1.199` / WG: `10.0.0.2` | ImmortalWrt 24.10 (GL-MT2500) | 内网反向代理 + 透明代理核心 |
|
||||
| **NAS** | `192.168.1.188` | 绿联云 UGOS | 内网存储服务(思源笔记、绿联云管理) |
|
||||
| **qBittorrent** | `192.168.1.200` (macvlan) | Docker (linuxserver/qbittorrent) | PT 下载专用,独立 IP |
|
||||
| **Windows 台式机** | `192.168.1.177` | Windows + WSL | 内网办公设备,SSH 服务 |
|
||||
|
||||
---
|
||||
|
||||
## 核心组件说明
|
||||
|
||||
### 1. 北京 VPS(公网入口节点)
|
||||
|
||||
#### 1.1 Nginx Stream SNI 分流层
|
||||
|
||||
**配置文件**: `beijing-vps-stream.conf`
|
||||
|
||||
Nginx stream 模块监听 `443/tcp`(IPv4 + IPv6),通过 `ssl_preread` 在 SSL 握手阶段提取 ClientHello 中的 SNI 字段,按域名分流到不同后端:
|
||||
|
||||
| SNI 域名 | 后端 | 端口 | 用途 |
|
||||
|---|---|---|---|
|
||||
| `www.apple.com` | upstream `xray` | :9443 | 旁路由反向代理隧道 |
|
||||
| `www.microsoft.com` | upstream `mihomo` | :9444 | Mihomo 客户端代理入口 → 东京出口 |
|
||||
| `news.apple.com` | upstream `xray_lan` | :9445 | 旁路由 Mihomo 北京直连代理 |
|
||||
| `drive.salmonstill.cn` | upstream `nas` | :38653 | 绿联云 NAS 服务直接转发 |
|
||||
| 其他域名 | upstream `npm` | :8443 | Nginx Proxy Manager 常规 Web 管理 |
|
||||
|
||||
#### 1.2 Xray 服务层
|
||||
|
||||
**配置文件**: `xray-北京vps-config.json`
|
||||
|
||||
**入站(共 15 个)**:
|
||||
|
||||
**Reality 入站(3 个)** — 均监听 `127.0.0.1`,由 Nginx 转发过来:
|
||||
|
||||
| Tag | 端口 | SNI | Reality target | 用途 |
|
||||
|---|---|---|---|---|
|
||||
| `interconn` | 9443 | `www.apple.com` | `www.apple.com:443` | 接收旁路由反向代理桥接 |
|
||||
| `mihomo_in` | 9444 | `www.microsoft.com` | `www.microsoft.com:443` | 接收外部 Mihomo 代理流量 |
|
||||
| `proxy_from_lan` | 9445 | `news.apple.com` | `www.apple.com:443` | 接收旁路由直连代理流量 |
|
||||
|
||||
**dokodemo-door 入站(11 个)** — 监听 `0.0.0.0`,反向代理内网服务:
|
||||
|
||||
| Tag | 端口 | 路由 |
|
||||
|---|---|---|
|
||||
| `external` | 38653 | → portal → NAS `1.188:9443` |
|
||||
| `external_siyuan` | 38654 | → portal → NAS `1.188:5005` |
|
||||
| `external_minecraft` | 39132 | → portal → 旁路由 `127.0.0.1:39132` |
|
||||
| `external_wsl` | 38655 | → portal → Windows `1.177:22` |
|
||||
| `external_nas_ssh` | 38656 | → portal → NAS `1.188:22` |
|
||||
| `external_router_ssh` | 38657 | → portal → 旁路由 `1.199:22` |
|
||||
| `external_qbit` | 51413 | → portal → qBittorrent `1.200:51413` |
|
||||
| `external_router_web` | 39766 | → portal → 旁路由 `1.199:80` |
|
||||
| `external_tmp` | 8501 | → portal → Windows `1.177:8501` |
|
||||
| `external_3000` | 3000 | → portal → NAS `1.188:3000` |
|
||||
| `external_222` | 222 | → portal → NAS `1.188:222` |
|
||||
|
||||
**Mixed 入站(1 个)**:
|
||||
|
||||
| Tag | 端口 | 用途 |
|
||||
|---|---|---|
|
||||
| `proxy_in` | 10809 | SOCKS5/HTTP 混合代理(→ 东京出口) |
|
||||
|
||||
**组件 - Portal**:
|
||||
```json
|
||||
"reverse": {
|
||||
"portals": [
|
||||
{ "tag": "portal", "domain": "reverse-proxy.xray.internal" }
|
||||
]
|
||||
}
|
||||
```
|
||||
与旁路由 Bridge 建立永久反向隧道,所有 `external_*` 入站的流量通过 portal 送入隧道。
|
||||
|
||||
**出站(2 个)**:
|
||||
|
||||
| Tag | 协议 | 用途 |
|
||||
|---|---|---|
|
||||
| `direct` | freedom | 北京 VPS 直连出网 |
|
||||
| `to_tokyo` | VLESS+Reality → `us.salmonstill.cn:443` | 转发到东京 VPS 出口 |
|
||||
|
||||
**路由规则**:
|
||||
- 所有 `external_*` 入站 → `portal`(送入反向隧道)
|
||||
- `interconn` → `portal`(隧道本身维持)
|
||||
- `mihomo_in` + `proxy_in` → `to_tokyo`(到东京出口)
|
||||
- `proxy_from_lan` → `direct`(北京直连)
|
||||
|
||||
---
|
||||
|
||||
### 2. 东京 VPS(代理出口节点)
|
||||
|
||||
**配置文件**: `tokyo-vps-config.json`
|
||||
|
||||
极简配置:
|
||||
|
||||
```json
|
||||
inbounds: [{
|
||||
port: 9443,
|
||||
protocol: "vless",
|
||||
streamSettings: { security: "reality", serverNames: ["www.microsoft.com"] }
|
||||
}]
|
||||
outbounds: [{ protocol: "freedom", tag: "direct" }]
|
||||
```
|
||||
|
||||
**Nginx Stream 层** (`东京-vps-stream.conf`):
|
||||
```
|
||||
www.microsoft.com → Xray :9443
|
||||
default → NPM :8443
|
||||
```
|
||||
|
||||
- 入站:VLESS+Reality,监听 `127.0.0.1:9443`,SNI=`www.microsoft.com`
|
||||
- 出站:freedom 自由网络出口
|
||||
- **仅做流量出口转发,无其他逻辑**
|
||||
|
||||
---
|
||||
|
||||
### 3. 旁路由(内网核心枢纽)
|
||||
|
||||
#### 3.1 Xray 反向代理桥接
|
||||
|
||||
**配置文件**: `xray-旁路由-config.json`
|
||||
|
||||
**组件 — Bridge**:
|
||||
```json
|
||||
"reverse": {
|
||||
"bridges": [{ "tag": "bridge", "domain": "reverse-proxy.xray.internal" }]
|
||||
}
|
||||
```
|
||||
与北京 VPS 的 Portal 建立永久 TCP 隧道。来自公网的请求通过该隧道进入内网。
|
||||
|
||||
**入站(1 个)**:
|
||||
|
||||
| Tag | 端口 | 协议 |
|
||||
|---|---|---|
|
||||
| `socks-lan` | 1080 | SOCKS5(备用) |
|
||||
|
||||
**出站(12 个)** — 按端口/服务映射内网目标:
|
||||
|
||||
| Tag | 目标 | 用途 |
|
||||
|---|---|---|
|
||||
| `to_nas` | `192.168.1.188:9443` | NAS 管理界面 |
|
||||
| `to_siyuan` | `192.168.1.188:5005` | 思源笔记 |
|
||||
| `to_wsl` | `192.168.1.177:22` | WSL SSH |
|
||||
| `to_nas_ssh` | `192.168.1.188:22` | NAS SSH |
|
||||
| `to_router_ssh` | `192.168.1.199:22` | 旁路由 SSH |
|
||||
| `to_router_web` | `192.168.1.199:80` | 旁路由 Web 管理 |
|
||||
| `to_minecraft` | `127.0.0.1:39132` | Minecraft 服务 |
|
||||
| `to_tmp` | `192.168.1.177:8501` | 临时服务 |
|
||||
| `to_3000` | `192.168.1.188:3000` | Web 服务 |
|
||||
| `to_222` | `192.168.1.188:222` | 备用服务 |
|
||||
| `to_qbit` | `192.168.1.200:51413` | qBittorrent 入站 |
|
||||
| `interconn` | VLESS+Reality → `salmonstill.cn:443` (SNI=`www.apple.com`) | 与北京 VPS 的隧道连接 |
|
||||
| `to_beijing_direct` | VLESS+Reality → `salmonstill.cn:443` (SNI=`news.apple.com`) | 北京直连代理 |
|
||||
| `direct` | freedom | 直连 |
|
||||
|
||||
**路由规则**(从 bridge 入站的流量按端口匹配):
|
||||
- 38653 → `to_nas`
|
||||
- 38654 → `to_siyuan`
|
||||
- 38655 → `to_wsl`
|
||||
- 38656 → `to_nas_ssh`
|
||||
- 38657 → `to_router_ssh`
|
||||
- 8501 → `to_tmp`
|
||||
- 39766 → `to_router_web`
|
||||
- 3000 → `to_3000`
|
||||
- 222 → `to_222`
|
||||
- 39132 → `to_minecraft`
|
||||
- 51413 → `to_qbit`
|
||||
- 默认 → `to_nas`
|
||||
- socks-lan 入站 → `to_beijing_direct`
|
||||
|
||||
#### 3.2 Mihomo TPROXY 透明代理
|
||||
|
||||
**配置文件**: `旁路由的mihomo config.yaml`
|
||||
|
||||
专为 qBittorrent PT 流量设计的透明代理方案。
|
||||
|
||||
**TPROXY 端口**: `7893`
|
||||
|
||||
**代理节点(2 个)**:
|
||||
- `Xray-Real` — VLESS+Reality,SNI=`www.microsoft.com`,经北京到东京出口
|
||||
- `Beijing-Direct` — VLESS+Reality,SNI=`news.apple.com`,北京直连(`skip-cert-verify: true` — 因 Reality 返回的是 target `www.apple.com` 的证书)
|
||||
|
||||
**策略组(11 个)**:
|
||||
- 国内 → 直连
|
||||
- 国外 → `[Xray-Real, 直连]`
|
||||
- Steam / Microsoft / AI / Stream Media / GitHub / Crypto → 按规则选
|
||||
- **PT-BT → `[Beijing-Direct, 直连]`**(核心策略)
|
||||
|
||||
**关键路由规则**:
|
||||
```
|
||||
SRC-IP-CIDR,192.168.1.200/32,PT-BT,no-resolve ← qBittorrent 全部走 PT-BT
|
||||
DOMAIN-SUFFIX,salmonstill.cn,直连
|
||||
DOMAIN-SUFFIX,volces.com,直连
|
||||
DOMAIN-KEYWORD,raylink,直连
|
||||
IP-CIDR,49.232.242.90/32,直连 ← 北京 VPS 防死循环
|
||||
IP-CIDR,43.165.178.10/32,直连 ← 东京 VPS 防死循环
|
||||
```
|
||||
|
||||
**nftables TPROXY 劫持** (`/etc/nftables.d/50-mihomo-tproxy.nft`):
|
||||
```
|
||||
ip saddr 192.168.1.200 meta mark set 1 tproxy to :7893 accept
|
||||
```
|
||||
- 仅劫持来源 `192.168.1.200` 的流量
|
||||
- 排除本地/私有地址和 VPS IP(防死循环)
|
||||
|
||||
**策略路由** (`/etc/rc.local`):
|
||||
```
|
||||
ip rule add fwmark 1 table 100
|
||||
ip route add local 0.0.0.0/0 dev lo table 100
|
||||
```
|
||||
|
||||
**额外监听器**:
|
||||
- `:7891` — 全局代理(强制走 Xray-Real → 东京出口)
|
||||
- `:7892` — 强制直连
|
||||
|
||||
---
|
||||
|
||||
### 4. qBittorrent PT 下载节点
|
||||
|
||||
#### 4.1 网络架构
|
||||
|
||||
```
|
||||
qBittorrent (192.168.1.200, macvlan)
|
||||
└── 网关: 192.168.1.199 (旁路由)
|
||||
```
|
||||
|
||||
Docker macvlan 网络创建命令:
|
||||
```bash
|
||||
docker network create -d macvlan \
|
||||
--subnet=192.168.1.0/24 \
|
||||
--gateway=192.168.1.199 \
|
||||
--ip-range=192.168.1.200/32 \
|
||||
-o parent=eth0 \
|
||||
qbit_macvlan
|
||||
```
|
||||
|
||||
#### 4.2 流量路径
|
||||
|
||||
**出站(透明代理)**:
|
||||
```
|
||||
qBittorrent → nftables TPROXY劫持 → Mihomo :7893
|
||||
→ SRC-IP-CIDR 匹配 → PT-BT 策略组 → Beijing-Direct
|
||||
→ VLESS+Reality (SNI=news.apple.com) → 北京VPS :443
|
||||
→ Nginx 分流 → proxy_from_lan :9445 → direct → 互联网
|
||||
```
|
||||
|
||||
**入站(端口转发)**:
|
||||
```
|
||||
BT Peer → 北京VPS :51413 → external_qbit → portal
|
||||
→ 反向隧道 → bridge → to_qbit → 192.168.1.200:51413
|
||||
```
|
||||
|
||||
#### 4.3 qBittorrent 设置
|
||||
|
||||
| 设置 | 值 |
|
||||
|---|---|
|
||||
| 监听端口 | 51413 |
|
||||
| UPnP/NAT-PMP | 禁用 |
|
||||
| SOCKS5 代理 | 清空(不使用) |
|
||||
| 连接协议 | **仅 TCP(关闭 μTP)** |
|
||||
| DHT | 可选(建议开) |
|
||||
| PEX | 可选(建议开) |
|
||||
|
||||
> μTP(UDP) 必须关闭 — Xray portal 反向代理不支持 UDP。
|
||||
|
||||
#### 4.4 定时做种调度(crontab)
|
||||
|
||||
```cron
|
||||
0 1 * * * curl -s -X POST "http://192.168.1.200:8888/api/v2/torrents/start" --data "hashes=all"
|
||||
0 7 * * * curl -s -X POST "http://192.168.1.200:8888/api/v2/torrents/stop" --data "hashes=all"
|
||||
```
|
||||
|
||||
夜间 01:00-07:00 做种,白天暂停节省带宽。
|
||||
|
||||
---
|
||||
|
||||
### 5. Minecraft 基岩版 UDP 转发
|
||||
|
||||
**独立于 Xray 体系的另一套方案**,使用 WireGuard + socat 实现 UDP 转发。
|
||||
|
||||
#### 5.1 架构
|
||||
|
||||
```
|
||||
公网玩家 UDP :19132 → 北京VPS socat → WireGuard 隧道
|
||||
→ 旁路由 10.0.0.2 → 端口转发 + SNAT → NAS 192.168.1.188:19132
|
||||
→ Docker 容器 (itzg/minecraft-bedrock-server, host 网络)
|
||||
```
|
||||
|
||||
#### 5.2 北京 VPS 配置
|
||||
|
||||
**WireGuard** (`/etc/wireguard/wg0.conf`):
|
||||
```
|
||||
[Interface]
|
||||
Address = 10.0.0.1/24
|
||||
ListenPort = 51820
|
||||
PostUp = iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
|
||||
|
||||
[Peer]
|
||||
PublicKey = 9jPlaUhx2Dc+C5ZqJx6Iu8GtNMig3cFIoqfHg8PZbCA=
|
||||
AllowedIPs = 10.0.0.2/32
|
||||
PersistentKeepalive = 25
|
||||
```
|
||||
|
||||
**socat systemd service** (`/etc/systemd/system/mc-forward.service`):
|
||||
```
|
||||
ExecStart=/usr/bin/socat UDP4-LISTEN:19132,fork,reuseaddr UDP4:10.0.0.2:19132
|
||||
```
|
||||
|
||||
**防火墙**:
|
||||
```
|
||||
ufw allow 51820/udp # WireGuard
|
||||
ufw allow 19132/udp # Minecraft
|
||||
```
|
||||
|
||||
#### 5.3 旁路由配置
|
||||
|
||||
**WireGuard 接口**:
|
||||
- IP: `10.0.0.2/24`
|
||||
- Peer 端点: `salmonstill.cn:51820`
|
||||
- AllowedIPs: `0.0.0.0/0`(**必须**,否则丢弃公网来源包)
|
||||
- 防火墙区域: `wan`
|
||||
|
||||
**端口转发**:UDP `wan:19132` → `lan:192.168.1.188:19132`
|
||||
|
||||
**SNAT 规则**:目标 `1.188:19132` UDP → 源 IP 重写为 `192.168.1.199`
|
||||
> 确保 NAS 回包发给旁路由而非主路由,避免非对称路由问题。
|
||||
|
||||
#### 5.4 NAS Docker 配置
|
||||
|
||||
```yaml
|
||||
services:
|
||||
bedrock:
|
||||
image: itzg/minecraft-bedrock-server:2026.2.1
|
||||
container_name: mc-bedrock
|
||||
network_mode: host
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
VERSION: "1.26.14.1"
|
||||
OPS: "2535472561115036"
|
||||
volumes:
|
||||
- /volume2/ProgramsV2/minecraft:/data
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 6. macOS 客户端配置
|
||||
|
||||
**配置文件**: `mac 的mihomo config.yaml`
|
||||
|
||||
备用客户端配置,与旁路由的 Mihomo 共享相同架构理念:
|
||||
|
||||
- 混合端口: 7890
|
||||
- 监听器: 7891(全局代理→东京出口)、7892(强制直连)
|
||||
- 单节点: `Xray-Real` (VLESS+Reality, SNI=`www.microsoft.com`)
|
||||
- 完整 rule-providers 规则集(广告、国内、GFW、流媒体、AI、GitHub、Steam 等)
|
||||
- `subscribe.yaml` — 与 Mac 配置结构相同,作为通用订阅配置模板
|
||||
- `subscribe-7891-only.yaml` — 精简版,全局走 7891 代理代理,适合快速切换
|
||||
|
||||
---
|
||||
|
||||
## 流量路径总览
|
||||
|
||||
### 路径 1:内网服务反向代理访问
|
||||
```
|
||||
用户 → salmonstill.cn:443 → Nginx SNI 匹配 → dokodemo-door 入站
|
||||
→ Xray portal → 反向隧道 → 旁路由 bridge
|
||||
→ 按端口匹配出站 → 内网目标 → 原路返回
|
||||
```
|
||||
|
||||
### 路径 2:代理翻墙(东京出口)
|
||||
```
|
||||
Mihomo 客户端 → salmonstill.cn:443 → Nginx SNI `www.microsoft.com`
|
||||
→ mihomo_in :9444 → to_tokyo → 东京 VPS → freedom → 互联网
|
||||
```
|
||||
|
||||
### 路径 3:北京直连代理(qBittorrent)
|
||||
```
|
||||
qBittorrent → nftables TPROXY → Mihomo :7893
|
||||
→ PT-BT → Beijing-Direct → salmonstill.cn:443
|
||||
→ Nginx SNI `news.apple.com` → proxy_from_lan :9445 → direct → 互联网
|
||||
```
|
||||
|
||||
### 路径 4:BT 入站
|
||||
```
|
||||
BT Peer → salmonstill.cn:51413 → external_qbit → portal
|
||||
→ 反向隧道 → bridge → to_qbit → 192.168.1.200:51413
|
||||
```
|
||||
|
||||
### 路径 5:Minecraft UDP
|
||||
```
|
||||
公网玩家 → salmonstill.cn:19132 → socat → WireGuard 隧道
|
||||
→ 旁路由 10.0.0.2 → 端口转发 + SNAT → NAS :19132 → Docker 容器
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 关键配置要点
|
||||
|
||||
### Reality 密钥体系
|
||||
|
||||
| 位置 | 用途 | Public Key | Private Key |
|
||||
|---|---|---|---|
|
||||
| **北京 VPS**(3个入站共用) | interconn / mihomo_in / proxy_from_lan | `62y5gDjPrdeuePGl-D2IW4Cw9Kb8_bSBBTmArvL7Nhs`(客户端用)| `GGT9LfN_2JdQG68cwrULgUK-adfT6wIokLzWjaB0fXs` |
|
||||
| **东京 VPS** | to_tokyo 出口 | 客户端 `to_tokyo` 配置中的 `password` | `iBlu3eH1VLf1S5Qw87m_1w0TGYUktDwHAzgpQ2aKuGI` |
|
||||
|
||||
> Reality 客户端必须使用 `public-key`,服务端使用 `privateKey`,且 `serverNames` 必须与 Nginx 分流 SNI 严格一致。
|
||||
|
||||
### 防死循环 IP
|
||||
以下 IP 在旁路由的 Mihomo 规则中必须直连:
|
||||
- `49.232.242.90` — 北京 VPS
|
||||
- `43.165.178.10` — 东京 VPS
|
||||
|
||||
### skip-cert-verify
|
||||
`Beijing-Direct` 节点必须设置 `skip-cert-verify: true`,因为 Reality 返回的是 target(`www.apple.com`)的证书,但 SNI 是 `news.apple.com`,TLS 的 SAN 校验会失败。
|
||||
|
||||
---
|
||||
|
||||
## 文件清单
|
||||
|
||||
| 文件 | 目标设备 | 部署路径 |
|
||||
|---|---|---|
|
||||
| `beijing-vps-stream.conf` | 北京 VPS | `/etc/nginx/stream.conf.d/` |
|
||||
| `xray-北京vps-config.json` | 北京 VPS | `/usr/local/etc/xray/config.json` |
|
||||
| `东京-vps-stream.conf` | 东京 VPS | `/etc/nginx/stream.conf.d/` |
|
||||
| `tokyo-vps-config.json` | 东京 VPS | `/usr/local/etc/xray/config.json` |
|
||||
| `旁路由的mihomo config.yaml` | 旁路由 | `/opt/mihomo/config.yaml` |
|
||||
| `xray-旁路由-config.json` | 旁路由 | `/etc/xray/config.json` |
|
||||
| `mac 的mihomo config.yaml` | macOS | 本地运行 |
|
||||
| `subscribe.yaml` | 通用 | 订阅模板 |
|
||||
| `subscribe-7891-only.yaml` | 通用 | 精简版模板 |
|
||||
| 旁路由备份 `backup-*.tar.gz` | 旁路由 | ImmortalWrt 系统备份 |
|
||||
|
||||
---
|
||||
|
||||
## 架构优势
|
||||
|
||||
1. **极致伪装**:所有流量走 443 端口 HTTPS,通过 SNI 区分,无特征被封
|
||||
2. **零额外端口暴露**:除 443 外无公网端口(Minecraft 19132 和 WireGuard 51820 除外)
|
||||
3. **内网零暴露**:NAS/Windows/qBittorrent 无需公网 IP 和端口映射
|
||||
4. **高可用隧道**:Xray portal/bridge 反向代理永久在线
|
||||
5. **低延迟**:Xray Reality 协议性能优异,中转延迟增加 < 10ms
|
||||
6. **易扩展**:新增内网服务只需在旁路由添加路由规则,无需改公网配置
|
||||
|
||||
---
|
||||
|
||||
## 部署顺序(标准流程)
|
||||
|
||||
```
|
||||
1. 腾讯云防火墙开放所需端口(443, 51413/tcp, 51820/udp, 19132/udp)
|
||||
2. 北京 VPS: 部署 Nginx stream 配置 → nginx -t && systemctl reload nginx
|
||||
3. 北京 VPS: 部署 Xray 配置 → systemctl restart xray
|
||||
4. 北京 VPS: 部署 WireGuard → wg-quick@wg0
|
||||
5. 北京 VPS: 部署 socat → systemctl start mc-forward
|
||||
6. 东京 VPS: 部署 Nginx + Xray 配置
|
||||
7. 旁路由: 部署 Xray 配置 → /etc/init.d/xray restart
|
||||
8. 旁路由: 部署 Mihomo 配置 → /etc/init.d/mihomo restart
|
||||
9. 旁路由: 部署 nftables 规则 → fw4 reload
|
||||
10. 旁路由: 配置 WireGuard 接口 + 端口转发 + SNAT(LuCI)
|
||||
11. NAS: 创建 macvlan 网络 → 启动 qBittorrent 容器
|
||||
12. NAS: 启动 Minecraft 容器
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 验证命令速查
|
||||
|
||||
```bash
|
||||
# 北京 VPS 健康检查
|
||||
ss -tlnp | grep -E '944[345]|3865[3-7]|51413|10809'
|
||||
systemctl status nginx xray wg-quick@wg0 mc-forward
|
||||
|
||||
# 东京 VPS 健康检查
|
||||
ss -tlnp | grep 9443
|
||||
systemctl status nginx xray
|
||||
|
||||
# 旁路由
|
||||
nft list chain inet mihomo_tproxy prerouting | grep 192.168
|
||||
ip rule show | grep "fwmark 1"
|
||||
ss -tlnp | grep -E '789[0-3]|1080'
|
||||
wg show
|
||||
|
||||
# qBittorrent 连通性验证
|
||||
docker exec qbittorrent curl -s https://ip.sb # 应返回北京 VPS IP
|
||||
|
||||
# Minecraft 连通性
|
||||
systemctl status mc-forward
|
||||
tcpdump -i wg0 udp port 19132 -n
|
||||
```
|
||||
+84
-146
@@ -1,13 +1,12 @@
|
||||
# qBittorrent 透明代理 + BT 入站转发配置文档
|
||||
# qBittorrent SOCKS5 代理 + BT 入站转发配置文档
|
||||
|
||||
## 架构总览
|
||||
|
||||
```
|
||||
出站(透明代理)
|
||||
出站(SOCKS5 代理)
|
||||
qBittorrent(192.168.1.200) 互联网
|
||||
↓ nftables TPROXY 劫持 ↑
|
||||
↓ mihomo:7893 │
|
||||
↓ SRC-IP-CIDR → PT-BT → Beijing-Direct │
|
||||
↓ SOCKS5 旁路由:1080 (socks-lan) ↑
|
||||
↓ Xray routing → to_beijing_direct │
|
||||
↓ Reality(VLESS, SNI=news.apple.com) │
|
||||
↓ 北京VPS:443 → Nginx分流 │
|
||||
↓ proxy_from_lan:9445 → direct(freedom) ─────────────────┘
|
||||
@@ -24,7 +23,7 @@ Peer → 北京VPS:51413 → external_qbit → portal
|
||||
| 设备 | IP | 角色 |
|
||||
|---|---|---|
|
||||
| 北京VPS | `salmonstill.cn` / `49.232.242.90` | 公网出口 + 入站入口 |
|
||||
| 旁路由 | `192.168.1.199` | TPROXY 透明代理 + Xray 桥接 |
|
||||
| 旁路由 | `192.168.1.199` | Xray 桥接 + SOCKS5 代理 |
|
||||
| NAS | `192.168.1.188` | Docker 宿主机 |
|
||||
| qBittorrent 容器 | `192.168.1.200` | macvlan 独立 IP,PT 专用 |
|
||||
|
||||
@@ -131,129 +130,74 @@ stream {
|
||||
|
||||
---
|
||||
|
||||
## 第二部分:旁路由 Mihomo 透明代理
|
||||
## 第二部分:旁路由 Xray SOCKS5 出站代理
|
||||
|
||||
### 2.1 配置 `旁路由的mihomo config.yaml`
|
||||
### 2.1 配置 `xray-旁路由-config.json`
|
||||
|
||||
#### 关键设置
|
||||
qBittorrent 出站不走 Mihomo 透明代理,而是通过旁路由上 Xray 的 `socks-lan` 入站(`:1080`),直接转发到北京 VPS 直连出口。
|
||||
|
||||
```yaml
|
||||
# TPROXY 透明代理入口(替代 TUN 模式)
|
||||
tproxy-port: 7893
|
||||
```
|
||||
#### SOCKS5 入站
|
||||
|
||||
#### 北京直连代理节点
|
||||
|
||||
```yaml
|
||||
proxies:
|
||||
- name: Beijing-Direct
|
||||
type: vless
|
||||
server: salmonstill.cn
|
||||
port: 443
|
||||
uuid: "113e167a-a2be-4b46-9010-60020108626c"
|
||||
udp: true
|
||||
flow: xtls-rprx-vision
|
||||
packet-encoding: xudp
|
||||
tls: true
|
||||
servername: news.apple.com
|
||||
skip-cert-verify: true # Reality 下必须跳过证书 SAN 校验
|
||||
client-fingerprint: chrome
|
||||
reality-opts:
|
||||
public-key: "62y5gDjPrdeuePGl-D2IW4C9wKb8_bSBBTmArvL7Nhs"
|
||||
short-id: "7c947a71b94f369e"
|
||||
network: tcp
|
||||
```
|
||||
|
||||
> `skip-cert-verify: true` 必须加——Reality 返回的是 `www.apple.com` 的证书(来自 target),但 SNI 是 `news.apple.com`,Mihomo 的 TLS 验证会因为 SAN 不匹配而拒绝。
|
||||
|
||||
#### PT-BT 策略组
|
||||
|
||||
```yaml
|
||||
proxy-groups:
|
||||
- name: PT-BT
|
||||
type: select
|
||||
proxies: [Beijing-Direct, 直连]
|
||||
```
|
||||
|
||||
#### qBittorrent 透明代理规则
|
||||
|
||||
```yaml
|
||||
rules:
|
||||
# 防死循环:北京 VPS 和东京 VPS 的 IP 必须直连
|
||||
- IP-CIDR,49.232.242.90/32,直连
|
||||
- IP-CIDR,43.165.178.10/32,直连
|
||||
# ... 其他防死循环规则 ...
|
||||
- SRC-IP-CIDR,192.168.1.200/32,PT-BT,no-resolve # qBittorrent 全部流量走代理
|
||||
```
|
||||
|
||||
> `SRC-IP-CIDR` 匹配**来源 IP**,不是目的 IP。所有从 192.168.1.200 发出的流量都会被 PT-BT 策略组接管。
|
||||
> `no-resolve` 防止 DNS 解析阶段误触发。
|
||||
|
||||
---
|
||||
|
||||
## 第三部分:旁路由 nftables TPROXY 规则
|
||||
|
||||
### 3.1 规则文件 `/etc/nftables.d/50-mihomo-tproxy.nft`
|
||||
|
||||
```nft
|
||||
#!/usr/sbin/nft -f
|
||||
|
||||
table inet mihomo_tproxy {
|
||||
chain prerouting {
|
||||
type filter hook prerouting priority mangle; policy accept;
|
||||
|
||||
# 不劫持本地/私有地址
|
||||
ip daddr 127.0.0.0/8 return
|
||||
ip daddr 10.0.0.0/8 return
|
||||
ip daddr 172.16.0.0/12 return
|
||||
ip daddr 192.168.0.0/16 return
|
||||
ip daddr 224.0.0.0/4 return
|
||||
|
||||
# 不劫持到北京/东京 VPS 的流量(防死循环)
|
||||
ip daddr 49.232.242.90 return
|
||||
ip daddr 43.165.178.10 return
|
||||
|
||||
# 劫持 192.168.1.200 的全部流量到 TPROXY
|
||||
ip saddr 192.168.1.200 meta mark set 1 tproxy to :7893 accept
|
||||
```json
|
||||
{
|
||||
"tag": "socks-lan",
|
||||
"port": 1080,
|
||||
"listen": "0.0.0.0",
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
"auth": "noauth",
|
||||
"udp": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> ImmortalWrt 使用 fw4(nftables),放在 `/etc/nftables.d/` 下会被自动加载。
|
||||
#### 出站 `to_beijing_direct`
|
||||
|
||||
### 3.2 策略路由 `/etc/rc.local`
|
||||
|
||||
```bash
|
||||
# 让被 fwmark=1 标记的包走本地回环(TPROXY 要求)
|
||||
ip rule add fwmark 1 table 100 2>/dev/null
|
||||
ip route add local 0.0.0.0/0 dev lo table 100 2>/dev/null
|
||||
|
||||
# 加载 nftables 规则(如果 fw4 reload 没自动加载)
|
||||
sleep 5
|
||||
nft add table inet mihomo_tproxy 2>/dev/null
|
||||
nft -f /etc/nftables.d/50-mihomo-tproxy.nft
|
||||
|
||||
exit 0
|
||||
```json
|
||||
{
|
||||
"tag": "to_beijing_direct",
|
||||
"protocol": "vless",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "salmonstill.cn",
|
||||
"port": 443,
|
||||
"users": [
|
||||
{
|
||||
"id": "113e167a-a2be-4b46-9010-60020108626c",
|
||||
"flow": "xtls-rprx-vision",
|
||||
"encryption": "none"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "raw",
|
||||
"security": "reality",
|
||||
"realitySettings": {
|
||||
"fingerprint": "chrome",
|
||||
"serverName": "news.apple.com",
|
||||
"publicKey": "62y5gDjPrdeuePGl-D2IW4Cw9Kb8_bSBBTmArvL7Nhs",
|
||||
"shortId": "7c947a71b94f369e"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3.3 验证 TPROXY
|
||||
#### 路由规则
|
||||
|
||||
```bash
|
||||
# 确认 nftables 规则
|
||||
nft list chain inet mihomo_tproxy prerouting | grep 192.168
|
||||
|
||||
# 确认策略路由
|
||||
ip rule show | grep "fwmark 1"
|
||||
|
||||
# 确认端口监听
|
||||
ss -tlnp | grep 7893
|
||||
```json
|
||||
{ "type": "field", "inboundTag": ["socks-lan"], "outboundTag": "to_beijing_direct" }
|
||||
```
|
||||
|
||||
> 路径:`qBittorrent → SOCKS5 旁路由:1080 → to_beijing_direct → 北京VPS:443(SNI=news.apple.com) → proxy_from_lan:9445 → direct → 互联网`
|
||||
|
||||
---
|
||||
|
||||
## 第四部分:旁路由 Xray 51413 转发
|
||||
## 第三部分:旁路由 Xray 51413 转发
|
||||
|
||||
### 4.1 配置 `xray-旁路由-config.json`
|
||||
### 3.1 配置 `xray-旁路由-config.json`
|
||||
|
||||
#### 新增加出站 `to_qbit`
|
||||
|
||||
@@ -282,9 +226,9 @@ ss -tlnp | grep 7893
|
||||
|
||||
---
|
||||
|
||||
## 第五部分:NAS qBittorrent Docker
|
||||
## 第四部分:NAS qBittorrent Docker
|
||||
|
||||
### 5.1 创建 macvlan 网络
|
||||
### 4.1 创建 macvlan 网络
|
||||
|
||||
```bash
|
||||
docker network create -d macvlan \
|
||||
@@ -295,10 +239,10 @@ docker network create -d macvlan \
|
||||
qbit_macvlan
|
||||
```
|
||||
|
||||
> `--gateway=192.168.1.199`:qBittorrent 的默认网关设为旁路由,确保流量经过 TPROXY。
|
||||
> `--ip-range=192.168.1.200/32`:固定 IP,对应 nftables 劫持规则。
|
||||
> `--gateway=192.168.1.199`:qBittorrent 的默认网关设为旁路由,确保出站流量经过旁路由。
|
||||
> `--ip-range=192.168.1.200/32`:固定 IP。
|
||||
|
||||
### 5.2 启动容器
|
||||
### 4.2 启动容器
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
@@ -311,20 +255,20 @@ docker run -d \
|
||||
lscr.io/linuxserver/qbittorrent:latest
|
||||
```
|
||||
|
||||
### 5.3 qBittorrent 设置
|
||||
### 4.3 qBittorrent 设置
|
||||
|
||||
| 设置项 | 值 |
|
||||
|---|---|
|
||||
| 监听端口 | `51413` |
|
||||
| UPnP/NAT-PMP | **禁用** |
|
||||
| SOCKS5 代理 | **清空(不使用)** |
|
||||
| SOCKS5 代理 | `192.168.1.199` / 端口 `1080` |
|
||||
| 连接协议 | **仅 TCP**(关闭 μTP) |
|
||||
| DHT | 可选(建议开) |
|
||||
| PEX | 可选(建议开) |
|
||||
|
||||
> 关闭 μTP(UDP):Xray portal 反向代理不支持 UDP,BT 的 μTP 走 UDP 会导致入站失败。
|
||||
|
||||
### 5.4 定时做种调度(crontab)
|
||||
### 4.4 定时做种调度(crontab)
|
||||
|
||||
让 qBittorrent 只在夜间(01:00-07:00)做种,白天暂停以节省带宽:
|
||||
|
||||
@@ -346,7 +290,7 @@ crontab -e
|
||||
|
||||
---
|
||||
|
||||
## 第六部分:部署顺序
|
||||
## 第五部分:部署顺序
|
||||
|
||||
```
|
||||
1. 腾讯云防火墙 → 开放 51413/tcp
|
||||
@@ -356,33 +300,31 @@ crontab -e
|
||||
5. 北京VPS: systemctl restart xray
|
||||
6. scp 旁路由的mihomo config.yaml → 旁路由 /opt/mihomo/config.yaml
|
||||
7. scp xray-旁路由-config.json → 旁路由 /etc/xray/config.json
|
||||
8. 旁路由: 创建 nftables 规则文件 + rc.local 策略路由
|
||||
9. 旁路由: /etc/init.d/mihomo restart
|
||||
10. 旁路由: /etc/init.d/xray restart
|
||||
11. 旁路由: fw4 reload 或 nft -f /etc/nftables.d/50-mihomo-tproxy.nft
|
||||
12. NAS: 创建 macvlan 网络 + 启动 qBittorrent 容器
|
||||
13. NAS: 配置 qBittorrent 监听端口 51413,关闭 μTP
|
||||
8. 旁路由: /etc/init.d/mihomo restart
|
||||
9. 旁路由: /etc/init.d/xray restart
|
||||
10. NAS: 创建 macvlan 网络 + 启动 qBittorrent 容器
|
||||
11. NAS: 配置 qBittorrent 监听端口 51413,关闭 μTP
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 第七部分:验证
|
||||
## 第六部分:验证
|
||||
|
||||
### 7.1 TPROXY 透明代理出站
|
||||
### 6.1 SOCKS5 代理出站验证
|
||||
|
||||
```bash
|
||||
# 在 NAS 上执行,应返回北京 VPS 的公网 IP
|
||||
docker exec qbittorrent curl https://ip.sb
|
||||
|
||||
# 确认不是东京 VPS 的 IP
|
||||
docker exec qbittorrent curl https://ifconfig.io
|
||||
docker exec qbittorrent curl --socks5 192.168.1.199:1080 https://ip.sb
|
||||
```
|
||||
|
||||
### 7.2 Mihomo 面板查看
|
||||
### 6.2 Xray 日志确认
|
||||
|
||||
浏览器打开 `http://192.168.1.199:9090` → 连接 → 应能看到大量通过 `Beijing-Direct` 的连接。
|
||||
```bash
|
||||
# 旁路由上查看 Xray 日志,确认 socks-lan 流量转发正常
|
||||
tail -f /var/log/xray.log | grep socks-lan
|
||||
```
|
||||
|
||||
### 7.3 BT 入站验证
|
||||
### 6.3 BT 入站验证
|
||||
|
||||
```bash
|
||||
# 北京 VPS 上确认端口监听
|
||||
@@ -392,7 +334,7 @@ ss -tlnp | grep 51413
|
||||
nc -zv salmonstill.cn 51413
|
||||
```
|
||||
|
||||
### 7.4 端到端 BT 测试
|
||||
### 6.4 端到端 BT 测试
|
||||
|
||||
下载一个热门 Ubuntu torrent 种子,观察:
|
||||
- qBittorrent WebUI → 连接 → 应显示 DHT 节点数增长
|
||||
@@ -401,26 +343,22 @@ nc -zv salmonstill.cn 51413
|
||||
|
||||
---
|
||||
|
||||
## 第八部分:故障排查
|
||||
## 第七部分:故障排查
|
||||
|
||||
| 现象 | 排查 |
|
||||
|---|---|
|
||||
| qBittorrent curl ip.sb 返回真实 IP | nftables 规则未生效,检查 `nft list chain inet mihomo_tproxy prerouting` |
|
||||
| Beijing-Direct 连不上 | 确认 `servername: news.apple.com` + `skip-cert-verify: true` |
|
||||
| qBittorrent curl ip.sb 返回真实 IP | SOCKS5 代理未生效,检查 qBittorrent 设置中代理配置 |
|
||||
| 代理连不上 | 确认 旁路由 Xray 正在运行且 `socks-lan` 入站监听 :1080 |
|
||||
| 入站无上传 | 检查北京 VPS ufw/腾讯云安全组已放行 51413/tcp |
|
||||
| xray 报错 `reverse-proxy.xray.internal` | portal/bridge 域名不匹配,两边必须一致 |
|
||||
| 旁路由自身网络异常 | nftables 规则漏了 `ip daddr 192.168.0.0/16 return`,检查私有地址排除 |
|
||||
| 下载有速度、无上传 | μTP 没关或 portal UDP 不支持,qBittorrent 设置仅 TCP |
|
||||
|
||||
---
|
||||
|
||||
## 第九部分:文件清单
|
||||
## 第八部分:文件清单
|
||||
|
||||
| 文件 | 位置 | 作用 |
|
||||
|---|---|---|
|
||||
| `beijing-vps-stream.conf` | 北京VPS `/etc/nginx/stream.conf.d/` | Nginx SNI分流(含 news.apple.com → 9445) |
|
||||
| `xray-北京vps-config.json` | 北京VPS `/usr/local/etc/xray/config.json` | Xray 入站+路由(含 proxy_from_lan + external_qbit) |
|
||||
| `旁路由的mihomo config.yaml` | 旁路由 `/opt/mihomo/config.yaml` | Mihomo TPROXY + Beijing-Direct + PT-BT 规则 |
|
||||
| `xray-旁路由-config.json` | 旁路由 `/etc/xray/config.json` | Xray bridge + to_qbit(51413) + socks-lan(1080) |
|
||||
| `/etc/nftables.d/50-mihomo-tproxy.nft` | 旁路由 | nftables TPROXY 劫持规则 |
|
||||
| `/etc/rc.local` | 旁路由 | 策略路由 + nft 加载(持久化) |
|
||||
| `xray-旁路由-config.json` | 旁路由 `/etc/xray/config.json` | Xray bridge + to_qbit(51413) + socks-lan(1080) → to_beijing_direct |
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
mixed-port: 7890
|
||||
allow-lan: true
|
||||
bind-address: '*'
|
||||
mode: rule
|
||||
log-level: info
|
||||
external-controller: '127.0.0.1:9090'
|
||||
|
||||
find-process-mode: off
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
default-nameserver:
|
||||
- tls://223.5.5.5
|
||||
- tls://223.6.6.6
|
||||
nameserver:
|
||||
- https://dns.alidns.com/dns-query
|
||||
- https://doh.pub/dns-query
|
||||
respect-rules: false
|
||||
|
||||
proxies:
|
||||
- name: Xray-Real
|
||||
type: vless
|
||||
server: salmonstill.cn
|
||||
port: 443
|
||||
uuid: "113e167a-a2be-4b46-9010-60020108626c"
|
||||
udp: true
|
||||
flow: xtls-rprx-vision
|
||||
packet-encoding: xudp
|
||||
tls: true
|
||||
servername: www.microsoft.com
|
||||
client-fingerprint: chrome
|
||||
reality-opts:
|
||||
public-key: "62y5gDjPrdeuePGl-D2IW4Cw9Kb8_bSBBTmArvL7Nhs"
|
||||
short-id: "7c947a71b94f369e"
|
||||
network: tcp
|
||||
|
||||
listeners:
|
||||
- name: global-mixed
|
||||
type: mixed
|
||||
port: 7891
|
||||
listen: 0.0.0.0
|
||||
udp: true
|
||||
proxy: Xray-Real
|
||||
|
||||
rules:
|
||||
- MATCH,DIRECT
|
||||
@@ -1,16 +1,26 @@
|
||||
# ========================
|
||||
# Clash-ALL 思路(单上游 Xray Reality 精简版) + 额外端口:7891 全局代理 + 7892 强制直连
|
||||
# Spark (Ubuntu) Mihomo 配置
|
||||
# 本地 TUN 模式,国外走 US-Direct 直连
|
||||
# ========================
|
||||
|
||||
mixed-port: 7890
|
||||
allow-lan: true
|
||||
bind-address: '*'
|
||||
allow-lan: false
|
||||
bind-address: '0.0.0.0'
|
||||
mode: rule
|
||||
log-level: info
|
||||
external-controller: '127.0.0.1:9090'
|
||||
|
||||
find-process-mode: off
|
||||
|
||||
# TUN 模式 — 本机所有流量自动劫持
|
||||
tun:
|
||||
enable: true
|
||||
stack: system
|
||||
dns-hijack:
|
||||
- any:53
|
||||
auto-route: true
|
||||
auto-detect-interface: true
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
@@ -28,14 +38,13 @@ dns:
|
||||
- geosite:microsoft
|
||||
- '+.lan'
|
||||
- '+.local'
|
||||
- '+.hf-mirror.com'
|
||||
default-nameserver:
|
||||
- 223.5.5.5
|
||||
- 223.6.6.6
|
||||
nameserver:
|
||||
- https://9.9.9.9/dns-query
|
||||
- https://149.112.112.112/dns-query
|
||||
- https://94.140.14.14/dns-query
|
||||
- https://94.140.15.15/dns-query
|
||||
- https://dns.alidns.com/dns-query
|
||||
- https://doh.pub/dns-query
|
||||
proxy-server-nameserver:
|
||||
- https://dns.alidns.com/dns-query
|
||||
- https://doh.pub/dns-query
|
||||
@@ -53,11 +62,11 @@ proxies:
|
||||
- name: 拒绝
|
||||
type: reject
|
||||
|
||||
- name: Xray-Real
|
||||
- name: US-Direct
|
||||
type: vless
|
||||
server: salmonstill.cn
|
||||
server: 173.242.118.60
|
||||
port: 443
|
||||
uuid: "113e167a-a2be-4b46-9010-60020108626c"
|
||||
uuid: "4d222c16-53bb-4402-814e-c8188cebcea6"
|
||||
udp: true
|
||||
flow: xtls-rprx-vision
|
||||
packet-encoding: xudp
|
||||
@@ -65,8 +74,8 @@ proxies:
|
||||
servername: www.microsoft.com
|
||||
client-fingerprint: chrome
|
||||
reality-opts:
|
||||
public-key: "62y5gDjPrdeuePGl-D2IW4Cw9Kb8_bSBBTmArvL7Nhs"
|
||||
short-id: "7c947a71b94f369e"
|
||||
public-key: "jr_zQjC4mvlQITuG5Ap5Mxqe5EBbGyyvwbVLDEi8OCA"
|
||||
short-id: "a1b2c3d4"
|
||||
network: tcp
|
||||
|
||||
# ========================
|
||||
@@ -79,7 +88,7 @@ proxy-groups:
|
||||
|
||||
- name: 国外
|
||||
type: select
|
||||
proxies: [Xray-Real, 直连]
|
||||
proxies: [US-Direct, 直连]
|
||||
|
||||
- name: Steam-rule
|
||||
type: select
|
||||
@@ -262,7 +271,7 @@ rule-providers:
|
||||
proxy: 国外
|
||||
|
||||
# ========================
|
||||
# 多监听器部分
|
||||
# 多监听器
|
||||
# ========================
|
||||
listeners:
|
||||
- name: global-mixed
|
||||
@@ -270,7 +279,7 @@ listeners:
|
||||
port: 7891
|
||||
listen: 127.0.0.1
|
||||
udp: true
|
||||
proxy: Xray-Real
|
||||
proxy: US-Direct
|
||||
|
||||
- name: direct-mixed
|
||||
type: mixed
|
||||
@@ -285,9 +294,14 @@ listeners:
|
||||
rules:
|
||||
- DOMAIN,vs18.bj2cu.u3.ucweb.com,拒绝
|
||||
- DOMAIN-SUFFIX,salmonstill.cn,直连
|
||||
- DOMAIN-SUFFIX,hf-mirror.com,国内
|
||||
- DOMAIN-KEYWORD,raylink,直连
|
||||
- IP-CIDR,49.232.242.90/32,直连
|
||||
- IP-CIDR,43.165.178.10/32,直连
|
||||
- IP-CIDR,173.242.118.60/32,直连
|
||||
- DOMAIN-SUFFIX,ubuntu.com,国外
|
||||
- DOMAIN-SUFFIX,canonical.com,国外
|
||||
- DOMAIN-SUFFIX,okx.com,国外
|
||||
- DOMAIN-SUFFIX,okxc.com,国外
|
||||
- RULE-SET,Ads,Block
|
||||
- RULE-SET,Private_Domain,国内
|
||||
- RULE-SET,Private_IP,国内,no-resolve
|
||||
+76
-5
@@ -109,13 +109,24 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "external_3000",
|
||||
"tag": "external_gitea",
|
||||
"listen": "0.0.0.0",
|
||||
"port": 3000,
|
||||
"port": 38661,
|
||||
"protocol": "dokodemo-door",
|
||||
"settings": {
|
||||
"address": "127.0.0.1",
|
||||
"port": 3000,
|
||||
"port": 38661,
|
||||
"network": "tcp"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "external_spark_38662",
|
||||
"listen": "0.0.0.0",
|
||||
"port": 38662,
|
||||
"protocol": "dokodemo-door",
|
||||
"settings": {
|
||||
"address": "127.0.0.1",
|
||||
"port": 38662,
|
||||
"network": "tcp"
|
||||
}
|
||||
},
|
||||
@@ -230,6 +241,44 @@
|
||||
"port": 51413,
|
||||
"network": "tcp"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "socks-dynamic",
|
||||
"listen": "0.0.0.0",
|
||||
"port": 38658,
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
"auth": "password",
|
||||
"accounts": [
|
||||
{
|
||||
"user": "dynamic",
|
||||
"pass": "ab981c1d2b6d031631ee75986ea4e7c7"
|
||||
}
|
||||
],
|
||||
"udp": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "external_spark_ssh",
|
||||
"listen": "0.0.0.0",
|
||||
"port": 38659,
|
||||
"protocol": "dokodemo-door",
|
||||
"settings": {
|
||||
"address": "127.0.0.1",
|
||||
"port": 38659,
|
||||
"network": "tcp"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "external_spark_rdp",
|
||||
"listen": "0.0.0.0",
|
||||
"port": 38660,
|
||||
"protocol": "dokodemo-door",
|
||||
"settings": {
|
||||
"address": "127.0.0.1",
|
||||
"port": 38660,
|
||||
"network": "tcp"
|
||||
}
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
@@ -243,7 +292,7 @@
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "us.salmonstill.cn",
|
||||
"address": "173.242.118.60",
|
||||
"port": 443,
|
||||
"users": [
|
||||
{
|
||||
@@ -323,7 +372,14 @@
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
"external_3000"
|
||||
"external_gitea"
|
||||
],
|
||||
"outboundTag": "portal"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
"external_spark_38662"
|
||||
],
|
||||
"outboundTag": "portal"
|
||||
},
|
||||
@@ -348,6 +404,21 @@
|
||||
],
|
||||
"outboundTag": "portal"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
"socks-dynamic"
|
||||
],
|
||||
"outboundTag": "portal"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
"external_spark_ssh",
|
||||
"external_spark_rdp"
|
||||
],
|
||||
"outboundTag": "portal"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
|
||||
+62
-1
@@ -100,6 +100,27 @@
|
||||
"redirect": "192.168.1.200:51413"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "to_spark_ssh",
|
||||
"protocol": "freedom",
|
||||
"settings": {
|
||||
"redirect": "192.168.1.166:22"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "to_spark_rdp",
|
||||
"protocol": "freedom",
|
||||
"settings": {
|
||||
"redirect": "192.168.1.166:3389"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "to_spark_38662",
|
||||
"protocol": "freedom",
|
||||
"settings": {
|
||||
"redirect": "192.168.1.166:38662"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "interconn",
|
||||
"protocol": "vless",
|
||||
@@ -239,7 +260,7 @@
|
||||
"inboundTag": [
|
||||
"bridge"
|
||||
],
|
||||
"port": "3000",
|
||||
"port": "38661",
|
||||
"outboundTag": "to_3000"
|
||||
},
|
||||
{
|
||||
@@ -271,7 +292,47 @@
|
||||
"inboundTag": [
|
||||
"bridge"
|
||||
],
|
||||
"port": "38658",
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
"bridge"
|
||||
],
|
||||
"port": "38659",
|
||||
"outboundTag": "to_spark_ssh"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
"bridge"
|
||||
],
|
||||
"port": "38660",
|
||||
"outboundTag": "to_spark_rdp"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
"bridge"
|
||||
],
|
||||
"port": "38662",
|
||||
"outboundTag": "to_spark_38662"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
"bridge"
|
||||
],
|
||||
"port": "38653",
|
||||
"outboundTag": "to_nas"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"inboundTag": [
|
||||
"bridge"
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+16
-22
@@ -11,8 +11,6 @@ external-controller: '127.0.0.1:9090'
|
||||
|
||||
find-process-mode: off
|
||||
|
||||
tproxy-port: 7893
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
@@ -34,13 +32,11 @@ dns:
|
||||
- '+.salmonstill.cn'
|
||||
- '+.raylink' # keyword 的话用这个兜底
|
||||
default-nameserver:
|
||||
- 127.0.0.1
|
||||
- 223.5.5.5
|
||||
- 114.114.114.114
|
||||
nameserver:
|
||||
- https://9.9.9.9/dns-query
|
||||
- https://149.112.112.112/dns-query
|
||||
- https://94.140.14.14/dns-query
|
||||
- https://94.140.15.15/dns-query
|
||||
- https://dns.alidns.com/dns-query
|
||||
- https://doh.pub/dns-query
|
||||
proxy-server-nameserver:
|
||||
- https://dns.alidns.com/dns-query
|
||||
- https://doh.pub/dns-query
|
||||
@@ -74,21 +70,20 @@ proxies:
|
||||
short-id: "7c947a71b94f369e"
|
||||
network: tcp
|
||||
|
||||
- name: Beijing-Direct
|
||||
- name: US-Direct
|
||||
type: vless
|
||||
server: salmonstill.cn
|
||||
server: 173.242.118.60
|
||||
port: 443
|
||||
uuid: "113e167a-a2be-4b46-9010-60020108626c"
|
||||
uuid: "4d222c16-53bb-4402-814e-c8188cebcea6"
|
||||
udp: true
|
||||
flow: xtls-rprx-vision
|
||||
packet-encoding: xudp
|
||||
tls: true
|
||||
servername: news.apple.com
|
||||
skip-cert-verify: true
|
||||
servername: www.microsoft.com
|
||||
client-fingerprint: chrome
|
||||
reality-opts:
|
||||
public-key: "62y5gDjPrdeuePGl-D2IW4Cw9Kb8_bSBBTmArvL7Nhs"
|
||||
short-id: "7c947a71b94f369e"
|
||||
public-key: "jr_zQjC4mvlQITuG5Ap5Mxqe5EBbGyyvwbVLDEi8OCA"
|
||||
short-id: "a1b2c3d4"
|
||||
network: tcp
|
||||
|
||||
# ========================
|
||||
@@ -101,7 +96,7 @@ proxy-groups:
|
||||
|
||||
- name: 国外
|
||||
type: select
|
||||
proxies: [Xray-Real, 直连]
|
||||
proxies: [US-Direct, 直连]
|
||||
|
||||
- name: Steam-rule
|
||||
type: select
|
||||
@@ -135,10 +130,6 @@ proxy-groups:
|
||||
type: select
|
||||
proxies: [国外, 国内, 直连, 拒绝]
|
||||
|
||||
- name: PT-BT
|
||||
type: select
|
||||
proxies: [Beijing-Direct, 直连]
|
||||
|
||||
# ========================
|
||||
# rule-providers
|
||||
# ========================
|
||||
@@ -296,7 +287,7 @@ listeners:
|
||||
port: 7891
|
||||
listen: 0.0.0.0
|
||||
udp: true
|
||||
proxy: Xray-Real
|
||||
proxy: US-Direct
|
||||
|
||||
- name: direct-mixed
|
||||
type: mixed
|
||||
@@ -314,11 +305,14 @@ rules:
|
||||
- DOMAIN-SUFFIX,volces.com,直连
|
||||
- DOMAIN-KEYWORD,raylink,直连
|
||||
- IP-CIDR,49.232.242.90/32,直连
|
||||
- IP-CIDR,43.165.178.10/32,直连
|
||||
- IP-CIDR,173.242.118.60/32,直连
|
||||
- DOMAIN-SUFFIX,ubuntu.com,国外
|
||||
- DOMAIN-SUFFIX,canonical.com,国外
|
||||
- DOMAIN-SUFFIX,okx.com,国外
|
||||
- DOMAIN-SUFFIX,okxc.com,国外
|
||||
- RULE-SET,Ads,Block
|
||||
- RULE-SET,Private_Domain,国内
|
||||
- RULE-SET,Private_IP,国内,no-resolve
|
||||
- SRC-IP-CIDR,192.168.1.200/32,PT-BT,no-resolve
|
||||
- RULE-SET,China_Domain,国内
|
||||
- RULE-SET,Oracle,国内
|
||||
- RULE-SET,China_IP,国内,no-resolve
|
||||
|
||||
@@ -32,10 +32,8 @@ dns:
|
||||
- 223.5.5.5
|
||||
- 223.6.6.6
|
||||
nameserver:
|
||||
- https://9.9.9.9/dns-query
|
||||
- https://149.112.112.112/dns-query
|
||||
- https://94.140.14.14/dns-query
|
||||
- https://94.140.15.15/dns-query
|
||||
- https://dns.alidns.com/dns-query
|
||||
- https://doh.pub/dns-query
|
||||
proxy-server-nameserver:
|
||||
- https://dns.alidns.com/dns-query
|
||||
- https://doh.pub/dns-query
|
||||
@@ -69,6 +67,22 @@ proxies:
|
||||
short-id: "7c947a71b94f369e"
|
||||
network: tcp
|
||||
|
||||
- name: US-Direct
|
||||
type: vless
|
||||
server: 173.242.118.60
|
||||
port: 443
|
||||
uuid: "4d222c16-53bb-4402-814e-c8188cebcea6"
|
||||
udp: true
|
||||
flow: xtls-rprx-vision
|
||||
packet-encoding: xudp
|
||||
tls: true
|
||||
servername: www.microsoft.com
|
||||
client-fingerprint: chrome
|
||||
reality-opts:
|
||||
public-key: "jr_zQjC4mvlQITuG5Ap5Mxqe5EBbGyyvwbVLDEi8OCA"
|
||||
short-id: "a1b2c3d4"
|
||||
network: tcp
|
||||
|
||||
# ========================
|
||||
# 策略组
|
||||
# ========================
|
||||
@@ -79,7 +93,7 @@ proxy-groups:
|
||||
|
||||
- name: 国外
|
||||
type: select
|
||||
proxies: [Xray-Real, 直连]
|
||||
proxies: [US-Direct, 直连]
|
||||
|
||||
- name: Steam-rule
|
||||
type: select
|
||||
@@ -270,7 +284,7 @@ listeners:
|
||||
port: 7891
|
||||
listen: 127.0.0.1
|
||||
udp: true
|
||||
proxy: Xray-Real
|
||||
proxy: US-Direct
|
||||
|
||||
- name: direct-mixed
|
||||
type: mixed
|
||||
@@ -285,9 +299,14 @@ listeners:
|
||||
rules:
|
||||
- DOMAIN,vs18.bj2cu.u3.ucweb.com,拒绝
|
||||
- DOMAIN-SUFFIX,salmonstill.cn,直连
|
||||
- DOMAIN-SUFFIX,hf-mirror.com,国内
|
||||
- DOMAIN-KEYWORD,raylink,直连
|
||||
- IP-CIDR,49.232.242.90/32,直连
|
||||
- IP-CIDR,43.165.178.10/32,直连
|
||||
- IP-CIDR,173.242.118.60/32,直连
|
||||
- DOMAIN-SUFFIX,ubuntu.com,国外
|
||||
- DOMAIN-SUFFIX,canonical.com,国外
|
||||
- DOMAIN-SUFFIX,okx.com,国外
|
||||
- DOMAIN-SUFFIX,okxc.com,国外
|
||||
- RULE-SET,Ads,Block
|
||||
- RULE-SET,Private_Domain,国内
|
||||
- RULE-SET,Private_IP,国内,no-resolve
|
||||
Reference in New Issue
Block a user