分了tun模式和非tun模式的主机,然后ubuntu专门配置了走外网
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# VPS 流量转发配置
|
||||
|
||||
基于 **Xray + Nginx SNI 分流 + Mihomo 透明代理 + WireGuard**,实现:
|
||||
基于 **Xray + Nginx SNI 分流 + Mihomo TUN 透明代理 + WireGuard**,实现:
|
||||
内网服务反向代理、多 VPS 链路中转、BT 透明代理、Minecraft UDP 转发。
|
||||
|
||||
---
|
||||
@@ -11,10 +11,11 @@
|
||||
|---|---|---|
|
||||
| **北京 VPS** | `salmonstill.cn` / `49.232.242.90` | 公网入口,Nginx + Xray + socat + WireGuard |
|
||||
| **东京 VPS** | `tokyo.salmonstill.cn` / `43.165.178.10` | 代理出口,Xray Reality 出站 |
|
||||
| **旁路由** | `192.168.1.199` / WG `10.0.0.2` | 内网核心,Xray bridge + Mihomo TPROXY |
|
||||
| **旁路由** | `192.168.1.199` / WG `10.0.0.2` | 内网核心,Xray bridge + Mihomo TUN |
|
||||
| **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 代理 |
|
||||
|
||||
---
|
||||
|
||||
@@ -124,26 +125,38 @@
|
||||
|
||||
### 旁路由 (`旁路由的mihomo config.yaml`)
|
||||
|
||||
**TPROXY 透明代理** — `:7893`,nftables 劫持 `192.168.1.200` 的流量。
|
||||
**TUN 透明代理** — `tun` 模式,内核级劫持。创建 `Meta` 虚拟接口(`198.18.0.1/16`),所有经过旁路由网关的设备流量自动被 TUN 接管:
|
||||
|
||||
```yaml
|
||||
tun:
|
||||
enable: true
|
||||
stack: system
|
||||
dns-hijack:
|
||||
- any:53
|
||||
auto-route: true
|
||||
auto-detect-interface: true
|
||||
```
|
||||
|
||||
配合 **fake-ip DNS**(`enhanced-mode: fake-ip`),DNS 请求返回 `198.18.x.x` 假 IP,强制流量进入代理路由。
|
||||
|
||||
**代理节点**:
|
||||
- `US-Direct` — VLESS+Reality → `us.salmonstill.cn:443`(默认国外出口)
|
||||
- `Xray-Real` — VLESS+Reality → `49.232.242.90:443`(备用,经北京→东京)
|
||||
- `Beijing-Direct` — VLESS+Reality → `salmonstill.cn:443`(北京直连,`skip-cert-verify: true`)
|
||||
|
||||
**关键策略组**:
|
||||
- 国外 → `[US-Direct, 直连]`
|
||||
- PT-BT → `[Beijing-Direct, 直连]`(qBittorrent 专用,北京直连出网)
|
||||
|
||||
**核心路由**:`SRC-IP-CIDR,192.168.1.200/32,PT-BT,no-resolve` — qBittorrent 全部走 PT-BT 策略组。
|
||||
|
||||
**防死循环 IP**:`49.232.242.90`(北京 VPS)、`43.165.178.10`(东京 VPS)强制直连。
|
||||
|
||||
**额外监听器**:`:7891`(全局→US-Direct)、`:7892`(强制直连)
|
||||
|
||||
### macOS (`mac 的mihomo config.yaml`)
|
||||
### macOS (`非tun模式的主机mihomo config.yaml`)
|
||||
|
||||
结构与旁路由一致,无 TPROXY,监听器 `:7891` bind 到 `127.0.0.1`。
|
||||
结构与旁路由一致,无 TUN,监听器 `:7890` + `:7891` + `:7892`。
|
||||
|
||||
### Ubuntu / Spark (`tun模式的主机mihomo config.yaml`)
|
||||
|
||||
本地 TUN 模式(`stack: system`),不依赖旁路由网关。设备重启后 `auto-route` 自建路由表,稳定可靠。监听器 `:7890` + `:7891` + `:7892`,节点直连 US-Direct。
|
||||
|
||||
### subscribe.yaml
|
||||
|
||||
@@ -156,12 +169,12 @@
|
||||
详见 [`qbittorrent流量转发.md`](./qbittorrent流量转发.md)。
|
||||
|
||||
```
|
||||
出站: qBittorrent → nftables :7893 → Mihomo PT-BT → Beijing-Direct
|
||||
→ salmonstill.cn:443 (SNI=news.apple.com) → direct → 互联网
|
||||
出站: qBittorrent → SOCKS5 旁路由:1080 (socks-lan) → Xray to_beijing_direct
|
||||
→ salmonstill.cn:443 (SNI=news.apple.com) → proxy_from_lan:9445 → direct → 互联网
|
||||
入站: BT Peer → salmonstill.cn:51413 → portal → 隧道 → bridge → to_qbit → 1.200:51413
|
||||
```
|
||||
|
||||
qBittorrent 设置:监听 `51413`,仅 TCP(关 μTP/UDP),不自设代理。
|
||||
qBittorrent 设置:SOCKS5 代理 → 旁路由 `192.168.1.199:1080`,监听 `51413`,仅 TCP(关 μTP/UDP)。
|
||||
|
||||
---
|
||||
|
||||
@@ -213,10 +226,10 @@ Mihomo 客户端 → salmonstill.cn:443 (SNI=www.microsoft.com)
|
||||
→ mihomo_in :9444 → to_tokyo → 东京 VPS → freedom → 互联网
|
||||
```
|
||||
|
||||
### 路径 3:北京直连代理(qBittorrent)
|
||||
### 路径 3:qBittorrent 代理出站
|
||||
```
|
||||
qBittorrent → nftables → Mihomo :7893 → PT-BT → Beijing-Direct
|
||||
→ salmonstill.cn:443 (SNI=news.apple.com) → direct → 互联网
|
||||
qBittorrent → SOCKS5 旁路由:1080 → Xray to_beijing_direct
|
||||
→ salmonstill.cn:443 (SNI=news.apple.com) → proxy_from_lan → direct → 互联网
|
||||
```
|
||||
|
||||
### 路径 4:BT 入站
|
||||
@@ -247,7 +260,8 @@ BT Peer → salmonstill.cn:51413 → portal → 隧道 → bridge → to_qbit
|
||||
| `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` |
|
||||
| `mac 的mihomo config.yaml` | macOS | `~/Library/LaunchAgents/` (launchctl 管理) |
|
||||
| `非tun模式的主机mihomo config.yaml` | macOS | `~/Library/LaunchAgents/` (launchctl 管理) |
|
||||
| `tun模式的主机mihomo config.yaml` | Spark (Ubuntu) | `/opt/mihomo/config.yaml` (systemd) |
|
||||
| `subscribe.yaml` | 通用 | 订阅模板 |
|
||||
| `subscribe-7891-only.yaml` | 通用 | 精简版模板 |
|
||||
| `qbittorrent流量转发.md` | — | 方案文档 |
|
||||
@@ -266,10 +280,9 @@ BT Peer → salmonstill.cn:51413 → portal → 隧道 → bridge → to_qbit
|
||||
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 容器
|
||||
9. 旁路由: 配置 WireGuard + 端口转发 + SNAT(LuCI)
|
||||
10. NAS: 创建 macvlan 网络 → 启动 qBittorrent 容器
|
||||
11. NAS: 启动 Minecraft 容器
|
||||
```
|
||||
|
||||
---
|
||||
@@ -286,9 +299,10 @@ 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'
|
||||
ip link show Meta # TUN 接口存在且 UP
|
||||
ss -tlnp | grep -E '789[0-2]|1080' # Mihomo 端口 + Xray socks-lan
|
||||
mihomo -d /opt/mihomo -t # 配置文件校验
|
||||
tail /opt/mihomo/logs/mihomo.log | grep TUN # 确认 TUN 无报错
|
||||
wg show
|
||||
|
||||
# qBittorrent 连通性
|
||||
|
||||
Reference in New Issue
Block a user