为什么这样配
WARP 只做上游代理,Mihomo 负责 TUN、DNS 和规则分流。职责边界清楚,不容易出现重复接管默认路由的问题。
这不是泛用教程,而是按当前本地
mihomo.yaml
写的实际流程。核心做法是让
warp-cli
只负责本地 SOCKS5 上游,再由
Mihomo
做系统接管和分流。
当前配置不是让 WARP 直接做全局隧道,而是让
warp-cli
只开放本地代理端口,再由 Mihomo 统一接管。这样链路更稳,也更容易排查。
WARP 只做上游代理,Mihomo 负责 TUN、DNS 和规则分流。职责边界清楚,不容易出现重复接管默认路由的问题。
私有地址、国内域名、国内 IP 直连;其余流量交给
PROXY,而
PROXY
当前首选就是
WARP。
warp-cli mode proxy。
如果 WARP 和 Mihomo 同时接管全局路由,最容易出现的就是回环、重复接管或异常掉线。
我额外写了一份跨平台 Bash 安装脚本,入口统一,macOS 和 Windows 都用同一个命令思路。WARP 走系统原生安装器,Mihomo 则下载 MetaCubeX 官方 stable release,并安装到你指定的一个路径里。
要求本机已有 brew。
curl -fsSLO https://clash-static-20260324.pages.dev/install_mihomo_warp.sh
bash install_mihomo_warp.sh --path "$HOME/.local/mihomo-warp/bin"
export PATH="$HOME/.local/mihomo-warp/bin:$PATH"
要求本机已有 Git Bash 和 winget。
curl -fsSLO https://clash-static-20260324.pages.dev/install_mihomo_warp.sh
bash install_mihomo_warp.sh --path "$HOME/.local/mihomo-warp/bin"
export PATH="$HOME/.local/mihomo-warp/bin:$PATH"
winget.exe 安装 Cloudflare WARP。
#!/usr/bin/env bash
set -euo pipefail
Usage:
bash scripts/install_mihomo_warp.sh [--path INSTALL_DIR] [--skip-warp] [--skip-mihomo]
Notes:
- macOS uses Homebrew cask to install Cloudflare WARP.
- Windows expects Git Bash and uses winget.exe to install Cloudflare WARP.
- Mihomo is downloaded from the latest stable MetaCubeX GitHub release.
顺序不能乱。先把 WARP 的本地代理准备好,再让 Mihomo 引用它。否则 Mihomo 启来以后,上游节点还没准备好,后续只会让排查更脏。
先确认 `warp-cli` 和 `mihomo` 都在 PATH 里。
warp-cli --version
mihomo -v
这里的关键不是“连接 WARP”,而是“以代理模式连接 WARP”,并固定到
40000 端口,保持和当前配置一致。
warp-cli mode proxy
warp-cli proxy port 40000
warp-cli connect
warp-cli status
不要跳过这一步。先测语法,确认当前
mihomo.yaml
没问题,再启动。
cd /Users/kangyuantong/Desktop/workspace/clash
mihomo -t -f mihomo.yaml
可以前台跑,也可以挂后台。
mihomo -f mihomo.yaml
# or
nohup mihomo -f mihomo.yaml > mihomo.log 2>&1 &
验证目标只有三个:WARP 端口在监听,Mihomo 端口在监听,流量确实能经由
127.0.0.1:7890
走出去。
lsof -nP -iTCP:40000 -sTCP:LISTEN
lsof -nP -iTCP:7890 -sTCP:LISTEN
tail -f mihomo.log
curl --proxy socks5h://127.0.0.1:7890 \
https://www.cloudflare.com/cdn-cgi/trace
rule-providers,
所以 ruleset/ 会在 Mihomo 首次成功启动后自动下载真实规则。
warp-cli status 是不是代理模式,再看
127.0.0.1:40000 是否真的在监听。
mihomo.yaml 里的上游节点端口。
7890。
warp-cli disconnect。不要反过来做。
如果你只想要一套能直接敲的命令,下面这一块就够了。
cd /Users/kangyuantong/Desktop/workspace/clash
warp-cli mode proxy
warp-cli proxy port 40000
warp-cli connect
mihomo -t -f mihomo.yaml
mihomo -f mihomo.yaml