快速設定
不想從零開始寫設定?這份範本已經把訂閱、地區分組、常見串流媒體/社交應用的分流規則都設好了,只需要把 proxy-providers 裡的訂閱位址換成自己的即可直接使用。
這份範本做了什麼
-
proxy-providers透過訂閱連結動態拉取節點,範例裡預留了兩個訂閱位(provider1/provider2),填自己的訂閱位址即可,名稱不能重複。
-
按地區自動分組用
include-all: true+filter正規表示式,把所有節點按名稱關鍵詞自動歸類到香港/台灣/日本/新加坡/美國/其他地區,不用手動維護節點列表。 -
按應用/地區分流用
GEOSITE和GEOIP規則集把 Google、Telegram、YouTube、Netflix、嗶哩嗶哩、國內流量等自動分流到對應的策略組,未命中的規則預設走「其他」分組。
完整範例(GEOSITE / GEOIP 版)
這個版本使用 mihomo 內建的 GEOSITE/GEOIP 資料庫做分流判斷,設定最簡單,無需額外的規則集合檔案。
config.yaml YAML
# url 裡填寫自己的訂閱,名稱不能重複 proxy-providers: provider1: url: "" type: http interval: 86400 health-check: { enable: true, url: "https://www.gstatic.com/generate_204", interval: 300 } proxies: - name: "直連" type: direct udp: true mixed-port: 7890 ipv6: true allow-lan: true unified-delay: false tcp-concurrent: true external-controller: 127.0.0.1:9090 external-ui: ui external-ui-url: "https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip" find-process-mode: strict global-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] tun: enable: true stack: mixed dns-hijack: - "any:53" auto-route: true auto-detect-interface: true dns: enable: true ipv6: true enhanced-mode: fake-ip fake-ip-filter: - "*" - "+.lan" - "+.local" default-nameserver: - tls://223.5.5.5 nameserver: - https://doh.pub/dns-query - https://dns.alidns.com/dns-query proxy-groups: - name: 預設 type: select proxies: [自動選擇, 直連, 香港, 台灣, 日本, 新加坡, 美國, 其他地區, 全部節點] - name: Google type: select proxies: [預設, 香港, 台灣, 日本, 新加坡, 美國, 其他地區, 全部節點, 自動選擇, 直連] # Telegram / Twitter / 嗶哩嗶哩 / 巴哈姆特 / YouTube / NETFLIX / Spotify / Github 同理 - name: 國內 type: select proxies: [直連, 預設, 香港, 台灣, 日本, 新加坡, 美國, 其他地區, 全部節點, 自動選擇] - name: 其他 type: select proxies: [預設, 香港, 台灣, 日本, 新加坡, 美國, 其他地區, 全部節點, 自動選擇, 直連] # 分隔,下面是地區分組,靠 filter 正規表示式自動歸類,不用手動維護節點 - name: 香港 type: select include-all: true exclude-type: direct filter: "(?i)港|hk|hongkong|hong kong" # 台灣/日本/新加坡/美國分組寫法相同,僅 filter 關鍵詞不同 - name: 其他地區 type: select include-all: true exclude-type: direct filter: "(?i)^(?!.*(?:港|hk|台|tw|日|jp|新|sg|美|us)).*" - name: 全部節點 type: select include-all: true exclude-type: direct - name: 自動選擇 type: url-test include-all: true exclude-type: direct tolerance: 10 rules: - GEOIP,lan,直連,no-resolve - GEOSITE,github,Github - GEOSITE,youtube,YouTube - GEOSITE,google,Google - GEOSITE,telegram,Telegram - GEOSITE,netflix,NETFLIX - GEOSITE,bilibili,Bilibili - GEOSITE,CN,國內 - GEOSITE,geolocation-!cn,其他 - GEOIP,CN,國內 - MATCH,其他
進階:換成 RULE-SET 版本
上面用的是核心內建的 GEOSITE/GEOIP 資料庫,勝在設定簡單,但更新頻率跟隨核心版本。如果想要更及時的規則資料,可以把 GEOSITE/GEOIP 換成 RULE-SET,引用 MetaCubeX 社群維護的規則集合(每天自動更新):
config.yaml YAML
rule-anchor: ip: &ip { type: http, interval: 86400, behavior: ipcidr, format: mrs } domain: &domain { type: http, interval: 86400, behavior: domain, format: mrs } rule-providers: cn_domain: <<: *domain url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/cn.mrs" github_domain: <<: *domain url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/github.mrs" cn_ip: <<: *ip url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/cn.mrs" rules: - RULE-SET,private_ip,直連,no-resolve - RULE-SET,github_domain,Github - RULE-SET,cn_domain,國內 - RULE-SET,cn_ip,國內 - MATCH,其他
思路和 GEOSITE 版一樣,只是把內建資料庫換成了線上拉取的規則檔案(&domain/&ip 錨點複用了公共的 http/interval/behavior/format 欄位,見 語法 一節的錨點用法)。更多寫法可以參考 規則集合 頁面。