7182 字
36 分钟
Mihomo 配置文件详细介绍
🤖AI 摘要
AI
Mihomo 配置文件详细介绍
⚠️ 合规使用声明 :本教程仅用于内网流量调试、开发测试及合法网络管理场景,禁止用于任何违法用途。请遵守当地法律法规。
一、配置文件概览
本配置文件是一个功能全面的 Mihomo 配置,适用于作为网关或桌面代理使用。它集成了以下核心特性:
- 基础代理服务:混合端口、HTTP/SOCKS5 代理,支持 IPv6 和局域网共享。
- TUN 透明代理:实现系统全局代理,无需每个应用单独配置。
- DNS 配置:使用 Fake-IP 模式,智能分流国内外域名解析。
- 内置地理数据源:通过
geodata-mode自动下载 GeoIP/GeoSite 数据库,用于域名和 IP 规则匹配。 - 流量嗅探:识别未加密流量中的域名,增强分流准确性。
- 代理提供者:支持多个订阅源,并可自动更新节点列表。
- 广告拦截:通过
rule-providers拉取广告规则集,优先拒绝广告请求。 - 灵活的代理分组:包括手动选择地区分组、自动优选、负载均衡、故障转移等多种策略,并支持选择节点来源(所有提供者或指定提供者)。
- Web 管理面板:自动下载并启用 metacubexd 面板,方便通过浏览器管理。
二、配置模块详解
1. 基础配置
mixed-port: 7890ipv6: trueallow-lan: trueunified-delay: falsetcp-concurrent: trueexternal-controller: 0.0.0.0:9090external-ui: uiexternal-ui-url: "https://ghproxy.cn/github.com/MetaCubeX/metacubexd/archive/gh-pages.zip"find-process-mode: strictglobal-client-fingerprint: chromeprofile: store-selected: true store-fake-ip: true- mixed-port:同时支持 HTTP 和 SOCKS5 的混合代理端口。
- ipv6:启用 IPv6 支持。
- allow-lan:允许局域网其他设备使用此代理。
- unified-delay:关闭统一延迟测试,保持各节点独立延迟数据。
- tcp-concurrent:启用 TCP 并发,提升多连接场景性能。
- external-controller:RESTful API 监听地址,
0.0.0.0:9090表示监听所有接口,允许局域网访问面板。如需仅本机访问,可改为127.0.0.1:9090。 - external-ui 和 external-ui-url:自动下载并挂载 Web 面板(metacubexd),访问
http://<设备IP>:9090/ui即可打开面板。 - find-process-mode:进程查找模式,
strict提高匹配准确性。 - global-client-fingerprint:设置全局 TLS 指纹,伪装成 Chrome 浏览器,减少 TLS 指纹识别风险。
- profile:保存用户手动选择的节点和 Fake-IP 映射,重启后恢复。
2. 内置地理数据源
geodata-mode: truegeox-url: geoip: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip-lite.dat" geosite: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat" mmdb: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb" asn: "https://github.com/xishang0128/geoip/releases/download/latest/GeoLite2-ASN.mmdb"- geodata-mode:启用内置地理数据模式,规则中的
GEOIP和GEOSITE将从配置的 URL 下载数据库。 - geox-url:指定各数据库的下载地址,Mihomo 会自动下载并缓存。
geoip-lite.dat为精简版 IP 归属地数据库,geosite.dat为域名分类数据库,country-lite.mmdb为 MaxMind 格式的 IP 数据库,GeoLite2-ASN.mmdb为 ASN 信息数据库。
3. 流量嗅探
sniffer: enable: true sniff: HTTP: ports: [80, 8080-8880] override-destination: true TLS: ports: [443, 8443] QUIC: ports: [443, 8443] skip-domain: - "Mijia Cloud" - "+.push.apple.com"- enable:开启流量嗅探,能够从 HTTP、TLS 和 QUIC 流量中提取域名,用于分流决策。
- sniff:定义各协议监听的端口。
- override-destination:当嗅探到域名后,使用该域名替代原始目标地址进行规则匹配。
- skip-domain:跳过对指定域名的嗅探(如小米云、苹果推送),避免干扰。
4. TUN 透明代理
tun: enable: true stack: mixed dns-hijack: - "any:53" - "tcp://any:53" auto-route: true auto-redirect: true auto-detect-interface: true- enable:启用 TUN 虚拟网卡,实现全局代理。
- stack:网络栈,
mixed同时支持 TCP 和 UDP。 - dns-hijack:劫持所有发往 53 端口的 DNS 请求,强制使用 Mihomo 内部 DNS。
- auto-route:自动添加路由表,将流量导向 TUN 设备。
- auto-redirect:自动配置 iptables 规则(仅 Linux),实现透明代理。
- auto-detect-interface:自动检测默认出口网卡。
5. DNS 配置
dns: enable: true ipv6: true respect-rules: true enhanced-mode: fake-ip fake-ip-filter: - "*" - "+.lan" - "+.local" - "+.market.xiaomi.com" nameserver: - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query proxy-server-nameserver: - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query nameserver-policy: "geosite:cn,private": - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query "geosite:geolocation-!cn": - "https://dns.cloudflare.com/dns-query" - "https://dns.google/dns-query"- enable:启用内置 DNS 服务器。
- respect-rules:DNS 查询结果将遵守分流规则。
- enhanced-mode:
fake-ip模式,为每个域名分配一个假的 IP,减少真实 DNS 查询,提升隐私和速度。 - fake-ip-filter:对这些域名不返回 Fake-IP,而是进行真实 DNS 查询。
*表示所有域名,但后续的+.lan等是排除项,即对.lan、.local等域名直接查询。 - nameserver:默认 DNS 服务器(用于国内域名或未匹配策略的域名)。
- proxy-server-nameserver:当使用代理节点进行 DNS 查询时使用的 DNS 服务器。
- nameserver-policy:根据域名分类指定不同的 DNS 服务器。这里将中国域名和私有域名交给国内 DoH,非中国域名交给国外 DoH。
6. 代理提供者(订阅)
proxy-providers: 机场A: type: http url: "YOUR_SUBSCRIPTION_URL_1" interval: 86400 health-check: enable: true url: "https://www.gstatic.com/generate_204" interval: 300 override: additional-prefix: "[机场A]" 机场B: ...- 机场A/机场B:自定义的提供者名称,用于在分组中引用。
- type:
http表示通过 HTTP/HTTPS 获取节点列表。 - url:订阅链接,请替换为实际地址。
- interval:更新间隔(秒),
86400为每天更新一次。 - health-check:定期测试节点延迟,
enable: true启用,url测试目标,interval测试频率。 - override:为从该提供者获取的每个节点名称添加前缀,便于识别来源。
7. 直连节点
proxies: - name: "直连" type: direct udp: true- 定义一个直连节点,用于不走代理的流量。
8. 广告拦截规则集(rule-providers)
rule-providers: AD: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/AD.yaml" path: ./rules/AD.yaml ...- rule-providers:定义外部规则集提供者,用于动态更新规则。
- AD、EasyList 等:规则集名称,在
rules中用RULE-SET,名称引用。 - type:
http表示通过 HTTP 获取规则文件。 - behavior:规则行为,
domain表示匹配域名。 - url:规则文件的下载地址。
- path:本地缓存路径。
- interval:更新间隔(秒),
86400每天更新一次。
这些广告规则集用于在规则匹配初期拒绝广告请求。
9. 代理分组
代理分组是分流策略的核心,本配置提供了多种类型的分组。
9.1 顶级手动分组(默认)
- name: 默认 type: select proxies: - 自动选择 - 全部节点 - 负载均衡(散列) - 负载均衡(轮询) - 故障转移 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区- type: select:手动选择模式,用户可在面板中从列出的代理中任选一个。
- proxies:列出了可供选择的子分组和直连节点,作为最终出口的候选。
9.2 地区分组(手动选择,带正则过滤)
例如香港分组:
- name: 香港 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)港|hk|hongkong|hong kong" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"- type: select:手动选择节点。
- 节点来源:可以通过
include-all: true从所有代理提供者中筛选,也可以通过use指定只从某些提供者中筛选。两者只能选其一,本配置中已注释掉两种方式,您需要根据需求取消对应行的注释。- 若取消注释
include-all: true,则从所有提供者中筛选。 - 若取消注释
use,则只从列出的提供者(如机场A、机场B)中筛选。
- 若取消注释
- filter:正则表达式,匹配节点名称中包含“港”、“hk”等关键词的节点。
- exclude-filter:排除包含回国、国内省市、运营商等关键词的节点,确保不选中回国线。
其他地区分组(台湾、日本、美国、新加坡、其它地区)类似,正则表达式已针对各区域调整。
9.3 自动优选分组
- name: 自动选择 type: url-test # include-all: true # use: # - 机场A # - 机场B tolerance: 10 exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"- type: url-test:自动测试节点延迟,选择延迟最低的节点。
- tolerance:延迟差在 10ms 内的节点视为同等,避免频繁切换。
- 同样支持
include-all或use选择节点来源。
9.4 全部节点
- name: 全部节点 type: select # include-all: true # use: # - 机场A # - 机场B- 手动选择所有节点中的具体某个节点,不经过正则过滤。
9.5 负载均衡分组
- name: 负载均衡(散列) type: load-balance # include-all: true # use: # - 机场A # - 机场B strategy: consistent-hashing- name: 负载均衡(轮询) type: load-balance strategy: round-robin- type: load-balance:负载均衡策略。
- strategy:
consistent-hashing一致性哈希,适合需要保持会话一致性的场景;round-robin轮询,轮流使用节点。
9.6 故障转移
- name: 故障转移 type: fallback # include-all: true # use: # - 机场A # - 机场B- type: fallback:按顺序尝试节点,失败时切换到下一个。
9.7 国内流量分组
- name: 国内 type: select proxies: - 直连 - 默认 - 自动选择 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点- 专用于国内域名,默认选项为
直连,但用户可以手动切换为其他分组。
9.8 服务分组
为各常用服务(Google、Telegram、Twitter 等)定义了独立分组,大部分为 select 类型,允许用户手动选择出口。其中 Telegram 分组为 url-test 类型,并配有复杂的正则过滤,自动优选境外节点。
- name: Telegram type: url-test # include-all: true # use: # - 机场A # - 机场B url: "https://www.gstatic.com/generate_204" interval: 300 tolerance: 50 filter: "(?i)(港|hk|hongkong|hong kong|台|tw|taiwan|日|jp|japan|美|us|unitedstates|united states|新|sg|singapore)" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"- url:测速目标。
- interval:测速间隔。
- tolerance:延迟容忍度。
- filter/exclude-filter:筛选境外节点,排除回国节点。
10. 规则(rules)
规则按照从上到下的顺序匹配,匹配即停止。本配置的规则顺序为:
- 广告拦截:使用
RULE-SET引用广告规则集,匹配到的请求直接REJECT。 - 私有 IP 直连:
GEOIP,private,直连,no-resolve,所有私有 IP 地址(如 192.168.x.x)直接连接。 - 域名规则:使用
GEOSITE匹配各服务域名,指向对应的服务分组。例如GEOSITE,google,Google将 Google 域名指向 Google 分组。 - 国内域名:
GEOSITE,cn,国内,将中国域名指向“国内”分组(默认直连)。 - 非中国域名:
GEOSITE,geolocation-!cn,其他,将非中国域名指向“其他”分组。 - IP 规则:
GEOIP,CN,国内,no-resolve,将中国 IP 指向“国内”分组。 - 最终兜底:
MATCH,其他,所有未匹配流量最终走“其他”分组。
三、如何选择节点来源
在代理分组中,我们提供了两种方式来指定节点来源:
include-all: true:从所有已定义的proxy-providers中筛选节点。适合希望合并多个订阅源的情况。use:列出特定的提供者名称,只从这些提供者中筛选节点。适合只想使用部分订阅源的情况。
操作方式:在分组配置中,找到对应的注释行,取消注释所需方式的行,并注释掉另一种方式。例如:
- name: 香港 type: select include-all: true # 取消注释此行,表示从所有提供者中筛选 # use: # 注释掉 use 块,表示不使用指定提供者 # - 机场A # - 机场B filter: ...或者
- name: 香港 type: select # include-all: true # 注释掉 include-all use: # 取消注释 use 块 - 机场A - 机场B filter: ...注意:include-all 和 use 是互斥的,只能选择其一。
四、广告规则集的更新与自定义
广告规则集通过 rule-providers 定义,配置如下:
rule-providers: AD: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/AD.yaml" path: ./rules/AD.yaml- 每个规则集每天(
86400秒)自动从指定 URL 拉取最新版本,并缓存到本地./rules/目录下。 - 如需添加自定义广告规则,可以新建一个
rule-provider,指向自己维护的规则文件,或者在本地path文件中手动添加规则。 - 在
rules部分,使用RULE-SET,名称,REJECT即可引用该规则集进行广告拦截。
五、使用注意事项
- 替换订阅链接:请务必将
YOUR_SUBSCRIPTION_URL_1和YOUR_SUBSCRIPTION_URL_2替换为您的实际订阅地址。 - 节点来源选择:根据您的需求,在每个需要筛选节点的分组中正确选择
include-all或use,并确保提供者名称与proxy-providers中定义的一致。 - 正则表达式:地区分组和服务分组中的正则表达式基于常见节点命名习惯编写,可能无法覆盖所有情况。如果某些节点未被正确归类,可自行调整正则。
- 首次启动:首次启动时会自动下载 GeoIP/GeoSite 数据库、Web 面板以及广告规则集,请确保网络畅通。如果下载失败,可手动下载对应文件放入指定路径。
- Web 面板访问:启动后,通过浏览器访问
http://<设备IP>:9090/ui即可打开面板。如需从外网访问,请确保防火墙允许 9090 端口,并注意安全。 - TUN 模式依赖:TUN 模式需要 root/管理员权限,并确保系统支持(Linux 需开启
net.ipv4.ip_forward)。
六、故障排查
- 查看日志:
sudo journalctl -u Mihomo -f(如果使用 systemd 管理)。 - 检查配置文件语法:
/usr/local/bin/Mihomo -t -d /etc/Mihomo。 - 确认订阅链接是否可访问,规则文件 URL 是否有效。
- 如果某些网站无法访问,尝试调整规则顺序或修改对应分组策略。
七、完整配置文件参考
1.基于内置地理数据 的 Mihomo 配置文件
# ========== 基础配置 ==========mixed-port: 7890ipv6: trueallow-lan: trueunified-delay: falsetcp-concurrent: trueexternal-controller: 0.0.0.0:9090 # 允许局域网访问面板external-ui: uiexternal-ui-url: "https://ghproxy.cn/github.com/MetaCubeX/metacubexd/archive/gh-pages.zip"
find-process-mode: strictglobal-client-fingerprint: chrome
profile: store-selected: true store-fake-ip: true
# ========== 内置地理数据源 ==========geodata-mode: truegeox-url: geoip: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip-lite.dat" geosite: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat" mmdb: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb" asn: "https://github.com/xishang0128/geoip/releases/download/latest/GeoLite2-ASN.mmdb"
# ========== 流量嗅探 ==========sniffer: enable: true sniff: HTTP: ports: [80, 8080-8880] override-destination: true TLS: ports: [443, 8443] QUIC: ports: [443, 8443] skip-domain: - "Mijia Cloud" - "+.push.apple.com"
# ========== TUN 透明代理 ==========tun: enable: true stack: mixed dns-hijack: - "any:53" - "tcp://any:53" auto-route: true auto-redirect: true auto-detect-interface: true
# ========== DNS 配置 ==========dns: enable: true ipv6: true respect-rules: true enhanced-mode: fake-ip fake-ip-filter: - "*" - "+.lan" - "+.local" - "+.market.xiaomi.com" nameserver: - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query proxy-server-nameserver: - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query nameserver-policy: "geosite:cn,private": - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query "geosite:geolocation-!cn": - "https://dns.cloudflare.com/dns-query" - "https://dns.google/dns-query"
# ========== 代理提供者(订阅) ==========proxy-providers: 机场A: type: http url: "YOUR_SUBSCRIPTION_URL_1" # 替换为实际订阅链接 interval: 86400 health-check: enable: true url: "https://www.gstatic.com/generate_204" interval: 300 override: additional-prefix: "[机场A]" 机场B: type: http url: "YOUR_SUBSCRIPTION_URL_2" # 替换为实际订阅链接 interval: 86400 health-check: enable: true url: "https://www.gstatic.com/generate_204" interval: 300 override: additional-prefix: "[机场B]"
# ========== 直连节点 ==========proxies: - name: "直连" type: direct udp: true
# ========== 广告拦截规则集(YAML 格式,保留) ==========rule-providers: AD: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/AD.yaml" path: ./rules/AD.yaml EasyList: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/EasyList.yaml" path: ./rules/EasyList.yaml EasyListChina: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/EasyListChina.yaml" path: ./rules/EasyListChina.yaml EasyPrivacy: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/EasyPrivacy.yaml" path: ./rules/EasyPrivacy.yaml ProgramAD: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/ProgramAD.yaml" path: ./rules/ProgramAD.yaml
# ========== 代理分组 ==========proxy-groups: # 顶级手动分组 - name: 默认 type: select proxies: - 自动选择 - 全部节点 - 负载均衡(散列) - 负载均衡(轮询) - 故障转移 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区
# 地区分组(手动选择,带复杂正则过滤) # 选择使用 include-all: true(所有提供者)或 use(指定提供者) - name: 香港 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)港|hk|hongkong|hong kong" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 台湾 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)台|tw|taiwan" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 日本 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)日|jp|japan" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 美国 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)美|us|unitedstates|united states" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 新加坡 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)(新|sg|singapore)" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 其它地区 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)^(?!.*(?:🇭🇰|🇯🇵|🇺🇸|🇸🇬|🇨🇳|港|hk|hongkong|台|tw|taiwan|日|jp|japan|新|sg|singapore|美|us|unitedstates)).*"
# 自动优选分组 - name: 自动选择 type: url-test # include-all: true # use: # - 机场A # - 机场B tolerance: 10 exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
# 全部节点(手动选择具体节点) - name: 全部节点 type: select # include-all: true # use: # - 机场A # - 机场B
# 负载均衡分组 - name: 负载均衡(散列) type: load-balance # include-all: true # use: # - 机场A # - 机场B strategy: consistent-hashing
- name: 负载均衡(轮询) type: load-balance # include-all: true # use: # - 机场A # - 机场B strategy: round-robin
# 故障转移 - name: 故障转移 type: fallback # include-all: true # use: # - 机场A # - 机场B
# 国内流量分组(默认直连,但可手动切换) - name: 国内 type: select proxies: - 直连 - 默认 - 自动选择 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
# ---- 服务分组 ---- - name: Google type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: Telegram type: url-test # include-all: true # use: # - 机场A # - 机场B url: "https://www.gstatic.com/generate_204" interval: 300 tolerance: 50 filter: "(?i)(港|hk|hongkong|hong kong|台|tw|taiwan|日|jp|japan|美|us|unitedstates|united states|新|sg|singapore)" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: Twitter type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: 哔哩哔哩 type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: 巴哈姆特 type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: YouTube type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: NETFLIX type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: Spotify type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: Github type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: 其他 type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
# ========== 规则 ==========rules: # 广告拦截(优先) - RULE-SET,AD,REJECT - RULE-SET,EasyList,REJECT - RULE-SET,EasyListChina,REJECT - RULE-SET,EasyPrivacy,REJECT - RULE-SET,ProgramAD,REJECT
# 私有 IP 直连 - GEOIP,private,直连,no-resolve
# 域名规则(使用内置 geosite) - GEOSITE,google,Google - GEOSITE,telegram,Telegram - GEOSITE,twitter,Twitter - GEOSITE,youtube,YouTube - GEOSITE,bilibili,哔哩哔哩 - GEOSITE,bahamut,巴哈姆特 - GEOSITE,netflix,NETFLIX - GEOSITE,spotify,Spotify - GEOSITE,github,Github - GEOSITE,cn,国内 - GEOSITE,geolocation-!cn,其他
# IP 规则(仅保留国家/地区级别) - GEOIP,CN,国内,no-resolve
# 最终兜底 - MATCH,其他2.基于外部 rule-providers 的 Mihomo 配置文件
# ========== 基础配置 ==========mixed-port: 7890ipv6: trueallow-lan: trueunified-delay: falsetcp-concurrent: trueexternal-controller: 0.0.0.0:9090 # 允许局域网访问面板external-ui: uiexternal-ui-url: "https://ghproxy.cn/github.com/MetaCubeX/metacubexd/archive/gh-pages.zip"
find-process-mode: strictglobal-client-fingerprint: chrome
profile: store-selected: true store-fake-ip: true
# ========== 流量嗅探 ==========sniffer: enable: true sniff: HTTP: ports: [80, 8080-8880] override-destination: true TLS: ports: [443, 8443] QUIC: ports: [443, 8443] skip-domain: - "Mijia Cloud" - "+.push.apple.com"
# ========== TUN 透明代理 ==========tun: enable: true stack: mixed dns-hijack: - "any:53" - "tcp://any:53" auto-route: true auto-redirect: true auto-detect-interface: true
# ========== DNS 配置 ==========dns: enable: true ipv6: true respect-rules: true enhanced-mode: fake-ip fake-ip-filter: - "*" - "+.lan" - "+.local" - "+.market.xiaomi.com" nameserver: - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query proxy-server-nameserver: - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query nameserver-policy: "rule-set:cn_domain,private_domain": - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query "rule-set:geolocation-!cn": - "https://dns.cloudflare.com/dns-query" - "https://dns.google/dns-query"
# ========== 代理提供者(订阅) ==========proxy-providers: 机场A: type: http url: "YOUR_SUBSCRIPTION_URL_1" # 替换为实际订阅链接 interval: 86400 health-check: enable: true url: "https://www.gstatic.com/generate_204" interval: 300 override: additional-prefix: "[机场A]" 机场B: type: http url: "YOUR_SUBSCRIPTION_URL_2" # 替换为实际订阅链接 interval: 86400 health-check: enable: true url: "https://www.gstatic.com/generate_204" interval: 300 override: additional-prefix: "[机场B]"
# ========== 直连节点 ==========proxies: - name: "直连" type: direct udp: true
# ========== 规则集提供者(使用锚点简化) ==========rule-anchor: ip: &ip {type: http, interval: 86400, behavior: ipcidr, format: mrs} domain: &domain {type: http, interval: 86400, behavior: domain, format: mrs}
rule-providers: # ---- 广告拦截(YAML 格式,可自行替换为 MRS) ---- AD: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/AD.yaml" path: ./rules/AD.yaml EasyList: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/EasyList.yaml" path: ./rules/EasyList.yaml EasyListChina: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/EasyListChina.yaml" path: ./rules/EasyListChina.yaml EasyPrivacy: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/EasyPrivacy.yaml" path: ./rules/EasyPrivacy.yaml ProgramAD: type: http interval: 86400 behavior: domain url: "https://raw.githubusercontent.com/earoftoast/clash-rules/main/ProgramAD.yaml" path: ./rules/ProgramAD.yaml
# ---- 常用域名规则集(MRS 格式) ---- private_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/private.mrs" cn_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/cn.mrs" google_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/google.mrs" telegram_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/telegram.mrs" twitter_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/twitter.mrs" youtube_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/youtube.mrs" bilibili_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/bilibili.mrs" bahamut_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/bahamut.mrs" netflix_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/netflix.mrs" spotify_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/spotify.mrs" github_domain: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/github.mrs" geolocation-!cn: <<: *domain url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/geolocation-!cn.mrs"
# ---- IP 规则集(MRS 格式) ---- private_ip: <<: *ip url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/private.mrs" cn_ip: <<: *ip url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/cn.mrs" google_ip: <<: *ip url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/google.mrs" telegram_ip: <<: *ip url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/telegram.mrs" twitter_ip: <<: *ip url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/twitter.mrs" netflix_ip: <<: *ip url: "https://ghproxy.cn/https://raw.github.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/netflix.mrs"
# ========== 代理分组 ==========proxy-groups: # 顶级手动分组 - name: 默认 type: select proxies: - 自动选择 - 全部节点 - 负载均衡(散列) - 负载均衡(轮询) - 故障转移 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区
# 地区分组(手动选择,带复杂正则过滤) # 选择使用 include-all: true(所有提供者)或 use(指定提供者) - name: 香港 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)港|hk|hongkong|hong kong" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 台湾 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)台|tw|taiwan" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 日本 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)日|jp|japan" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 美国 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)美|us|unitedstates|united states" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 新加坡 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)(新|sg|singapore)" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: 其它地区 type: select # include-all: true # use: # - 机场A # - 机场B filter: "(?i)^(?!.*(?:🇭🇰|🇯🇵|🇺🇸|🇸🇬|🇨🇳|港|hk|hongkong|台|tw|taiwan|日|jp|japan|新|sg|singapore|美|us|unitedstates)).*"
# 自动优选分组 - name: 自动选择 type: url-test # include-all: true # use: # - 机场A # - 机场B tolerance: 10 exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
# 全部节点(手动选择具体节点) - name: 全部节点 type: select # include-all: true # use: # - 机场A # - 机场B
# 负载均衡分组 - name: 负载均衡(散列) type: load-balance # include-all: true # use: # - 机场A # - 机场B strategy: consistent-hashing
- name: 负载均衡(轮询) type: load-balance # include-all: true # use: # - 机场A # - 机场B strategy: round-robin
# 故障转移 - name: 故障转移 type: fallback # include-all: true # use: # - 机场A # - 机场B
# 国内流量分组(默认直连,但可手动切换) - name: 国内 type: select proxies: - 直连 - 默认 - 自动选择 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
# ---- 服务分组 ---- - name: Google type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: Telegram type: url-test # include-all: true # use: # - 机场A # - 机场B url: "https://www.gstatic.com/generate_204" interval: 300 tolerance: 50 filter: "(?i)(港|hk|hongkong|hong kong|台|tw|taiwan|日|jp|japan|美|us|unitedstates|united states|新|sg|singapore)" exclude-filter: "(?i)回国|安徽|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|黑龙江|河南|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|天津|西藏|新疆|云南|浙江|官网|国内|国际|移动|联通|电信|cn|china"
- name: Twitter type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: 哔哩哔哩 type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: 巴哈姆特 type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: YouTube type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: NETFLIX type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: Spotify type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: Github type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
- name: 其他 type: select proxies: - 默认 - 自动选择 - 直连 - 香港 - 台湾 - 日本 - 新加坡 - 美国 - 其它地区 - 全部节点
# ========== 规则 ==========rules: # 广告拦截(优先) - RULE-SET,AD,REJECT - RULE-SET,EasyList,REJECT - RULE-SET,EasyListChina,REJECT - RULE-SET,EasyPrivacy,REJECT - RULE-SET,ProgramAD,REJECT
# 私有 IP 直连 - RULE-SET,private_ip,直连,no-resolve
# 域名规则 - RULE-SET,google_domain,Google - RULE-SET,telegram_domain,Telegram - RULE-SET,twitter_domain,Twitter - RULE-SET,youtube_domain,YouTube - RULE-SET,bilibili_domain,哔哩哔哩 - RULE-SET,bahamut_domain,巴哈姆特 - RULE-SET,netflix_domain,NETFLIX - RULE-SET,spotify_domain,Spotify - RULE-SET,github_domain,Github - RULE-SET,cn_domain,国内 - RULE-SET,geolocation-!cn,其他
# IP 规则 - RULE-SET,google_ip,Google,no-resolve - RULE-SET,telegram_ip,Telegram,no-resolve - RULE-SET,twitter_ip,Twitter,no-resolve - RULE-SET,netflix_ip,NETFLIX,no-resolve - RULE-SET,cn_ip,国内,no-resolve
# 最终兜底 - MATCH,其他 Mihomo 配置文件详细介绍
https://www.daitcc.top/posts/mihomo-配置文件详细介绍/ 如果这篇文章对你有帮助或启发,可以请作者喝杯咖啡 ☕️