mihomo 安装
访问 codex
下载 mihomo-linux-amd64-v3-v1.19.29.deb
sh
curl -fL --retry 3 --retry-delay 2 \
-o /tmp/mihomo.deb \
https://github.com/MetaCubeX/mihomo/releases/download/v1.19.29/mihomo-linux-amd64-v3-v1.19.29.deb
sudo apt install -y /tmp/mihomo.deb
mihomo -v检查附带服务
sh
dpkg -L mihomo
systemctl status mihomo --no-pager安装日志
sh
qin@aier:~$ mihomo -v
Mihomo Meta v1.19.29 linux amd64 with go1.26.5 Sat Jul 18 12:22:36 UTC 2026
Use tags: with_gvisor
qin@aier:~$ dpkg -L mihomo
/.
/etc
/etc/mihomo
/etc/mihomo/config.yaml
/usr
/usr/share
/usr/share/licenses
/usr/share/licenses/mihomo
/usr/share/licenses/mihomo/LICENSE
/usr/share/doc
/usr/share/doc/mihomo
/usr/share/doc/mihomo/changelog.gz
/usr/bin
/usr/bin/mihomo
/usr/lib
/usr/lib/systemd
/usr/lib/systemd/system
/usr/lib/systemd/system/mihomo.service
/usr/lib/systemd/system/mihomo@.service
qin@aier:~$ systemctl status mihomo --no-pager
○ mihomo.service - mihomo Daemon, Another Clash Kernel.
Loaded: loaded (/usr/lib/systemd/system/mihomo.service; disabled; preset: enabled)
Active: inactive (dead)
Docs: https://wiki.metacubex.one配置
sh
sudo cp /etc/mihomo/config.yaml /etc/mihomo/config.yaml.bak
sudo nano /etc/mihomo/config.yaml狗狗目前韩国比较稳定,有限使用韩国 :
sh
mixed-port: 7890
allow-lan: false
bind-address: 127.0.0.1
mode: rule
log-level: info
ipv6: false
unified-delay: true
tcp-concurrent: true
profile:
store-selected: true
proxy-providers:
subscription:
type: http
url: "在这里填写你的 Clash 订阅 URL"
path: ./proxy_providers/subscription.yaml
interval: 86400
proxy: DIRECT
health-check:
enable: true
url: https://www.gstatic.com/generate_204
interval: 300
timeout: 5000
lazy: true
proxy-groups:
- name: KOREA
type: url-test
use:
- subscription
filter: '(?i)(🇰🇷|韩国|韓國|首尔|首爾|仁川|Korea|Seoul|\bKR\b)'
url: https://www.gstatic.com/generate_204
interval: 300
tolerance: 100
timeout: 5000
empty-fallback: REJECT
- name: BACKUP
type: url-test
use:
- subscription
filter: '(?i)(🇯🇵|日本|东京|大阪|Japan|\bJP\b|🇸🇬|新加坡|狮城|Singapore|\bSG\b|🇺🇸|美国|洛杉矶|硅谷|United States|USA)'
exclude-filter: '(?i)(🇭🇰|香港|Hong Kong|\bHK\b)'
url: https://www.gstatic.com/generate_204
interval: 300
tolerance: 100
timeout: 5000
empty-fallback: REJECT
- name: PROXY
type: fallback
proxies:
- KOREA
- BACKUP
url: https://www.gstatic.com/generate_204
interval: 300
timeout: 5000
rules:
# OpenAI API、登录与 Codex
- DOMAIN-SUFFIX,openai.com,PROXY
- DOMAIN-SUFFIX,chatgpt.com,PROXY
- DOMAIN-SUFFIX,oaistatic.com,PROXY
- DOMAIN-SUFFIX,oaiusercontent.com,PROXY
# GitHub 网站、API、Git HTTPS 和下载
- DOMAIN-SUFFIX,github.com,PROXY
# GitHub Raw、Release、用户上传资源
- DOMAIN-SUFFIX,githubusercontent.com,PROXY
# GitHub 网站静态资源
- DOMAIN-SUFFIX,githubassets.com,PROXY
# GitHub Pages
- DOMAIN-SUFFIX,github.io,PROXY
# GitHub Container Registry
- DOMAIN-SUFFIX,ghcr.io,PROXY
# GitHub Copilot
- DOMAIN-SUFFIX,githubcopilot.com,PROXY
# GitHub 状态页
- DOMAIN-SUFFIX,githubstatus.com,PROXY
# 其他所有请求默认直连
- MATCH,DIRECT保护配置
sh
sudo chown root:root /etc/mihomo/config.yaml
sudo chmod 600 /etc/mihomo/config.yaml检查并重启
sh
sudo mihomo -t -d /etc/mihomo
sudo systemctl enable --now mihomo
systemctl status mihomo --no-pager查看订阅下载或节点错误:
sh
journalctl -u mihomo -n 100 --no-pager如果修改了配置
sh
sudo mihomo -t -d /etc/mihomo
sudo systemctl restart mihomo
sleep 3
systemctl status mihomo --no-pager
journalctl -u mihomo -n 50 --no-pagercodex 测试
sh
curl -x http://127.0.0.1:7890 https://ipinfo.io/json
curl -I https://github.comsh
curl -x http://127.0.0.1:7890 \
-w '\nHTTP status: %{http_code}\n' \
https://api.openai.com/v1/models环境变量
sh
vim ~/.bashrcsh
# Local Mihomo proxy
export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
export ALL_PROXY=socks5h://127.0.0.1:7890
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTPS_PROXY"
export all_proxy="$ALL_PROXY"
export NO_PROXY=127.0.0.1,localhost
export no_proxy="$NO_PROXY"sh
source ~/.bashrc