MIHOMO / CONFIG.YAML

Clash Meta Advanced Configuration Guide

Field references and troubleshooting steps for proxy groups, rule providers, DNS, and TUN.

Getting Started walks you through importing a profile, choosing a mode, and verifying your first connection. This page is organized by core configuration topics for users who are already connected and want to adjust rules or troubleshoot issues. Haven't chosen a client yet? Visit the Download Center to browse by platform and architecture, and check which platforms Clash Plus supports. The YAML examples below are for mihomo; whether a client exposes each setting depends on the configuration it actually runs.

01 / PROXY GROUPS

Proxy Group Types and Routing

Separate rule matching from group selection

In Rule mode, each connection is evaluated against the rules in order. The first match sends it to the specified outbound. If that outbound is a proxy group, the core then selects a member based on the group type; a member can itself be another group. Selecting a node in the UI does not mean every connection will use it. Check the matched rule and outbound chain in the connection details first, then inspect the group selection. For example, if a work domain should go direct but the details show the catch-all outbound, check whether the domain is visible and whether the rule appears early enough—don't switch nodes one by one. Global and Direct modes are useful for comparison, but they won't verify that your rule list is correct.

Choose a group based on what you need to control

TypeHow it selectsBest for
selectThe user selects a member from the available optionsWhen you need a fixed outbound or want to switch manually
url-testSelects based on test results; tolerance prevents small fluctuations from triggering a switchWhen several candidates can serve the same purpose
fallbackUses the first available candidate in the listed orderWhen primary/backup order matters more than probe latency
load-balanceDistributes connections according to the group's strategyWhen different connections can use different outbounds

For logins, uploads, and remote sessions that need a stable outbound, use a manual group. Automatic latency tests measure a candidate's response to a specific probe address; they don't measure video throughput or prove that a destination allows access from that outbound. A fallback group is useful when you know which route should be tried first. Put the backup first, and it may be used as the preferred route. Load balancing distributes connections; it won't split one download across multiple nodes to make it faster. Avoid assigning multiple outbounds arbitrarily to services that rely on a consistent source IP.

Combine a manual entry point with automatic selection

This snippet assumes the same configuration already defines proxies named “Primary” and “Backup.” The main outbound provides a manual entry point, with the default candidate listed first; you can also select a specific route for comparison. The test interval is in seconds and tolerance is in milliseconds. Use a probe address that candidates can reach and that responds consistently with a lightweight request. On managed networks, use an approved test address. Merge this snippet into your existing file only if the required outbounds are already configured.

proxy-groups:
  - name: Main Outbound
    type: select
    proxies: [Auto Select, Primary, Backup]
  - name: Auto Select
    type: url-test
    proxies: [Primary, Backup]
    url: https://www.gstatic.com/generate_204
    interval: 300
    tolerance: 80
rules:
  - DOMAIN-SUFFIX,example.com,DIRECT
  - MATCH,Main Outbound

When copying this snippet, merge it into the existing lists instead of adding a second top-level key with the same name. Node names, group names, and rule targets must match exactly; don't rely on labels truncated in the UI. Use proxies for fixed members and use to include members from proxy providers. If you split groups by name filters, a subscription rename can leave a group empty. Check the actual candidate list before adjusting the expression. Nesting can reduce duplication, but avoid circular references and don't stack multiple automatic groups with the same role in front of one outbound.

Use a new connection to verify that switching worked

Test two known candidates against the same destination before enabling the automatic group, then compare the logs from that test. If every candidate times out, check whether the probe address resolves, whether the client reports certificate errors, and whether the provider actually loaded its nodes. Don't start by reducing the probe interval to a few seconds. If only some candidates fail, test the real destination manually to tell whether the probe address is unreachable or the route itself is down. A tolerance that's too low can cause repeated switches between similar results; one that's too high can keep a slower candidate selected. Judge it against several consecutive tests.

Switching groups usually affects only new connections. Browsers may reuse existing connections, and active downloads won't migrate just because you changed a panel setting. Closing the destination tab may not stop every background connection; retest with a new client session or a tool that clearly opens a fresh connection. If the group reverts after a restart, check whether the client saves your selection and whether it loads the same configuration file at startup. For the full latency test and first-connection walkthrough, see First Connection Checklist.

02 / RULE PROVIDERS

Manage Rules with Rule Providers

Separate match conditions while keeping routing decisions local

rule-providers defines where rule data comes from and how to interpret it. The top-level rules list determines when that data is checked and which outbound handles a match. A remote update can change what a provider matches, but its position in the local rule list and the outbound used for a match remain under local configuration. Keep business exceptions that need frequent review in the main file; move large, frequently updated lists from independent sources into providers. This makes routing priority easier to follow and lets you remove a provider reference on its own if an upstream source has a problem.

Rule mode uses the first matching rule. If a subdomain must go direct but is also covered by a broad proxy rule provider, put the Direct rule for that domain before the provider reference. The same applies when multiple providers overlap: whichever provider appears first determines the outbound for overlapping entries. Put the catch-all MATCH rule last. Moving an entire provider to the top to fix one exception can change other traffic too, especially when the provider includes many vendor domains.

Distinguish match behavior from file format

behavior: domain reads domain entries, ipcidr reads address ranges, and classical reads match conditions with rule types. format describes whether the file is YAML, plain text, or MRS. Don't rely on the file extension instead of checking its actual contents, and don't load an MRS file that supports only domains or address ranges as though it were general-purpose rule text. A subscription service's full configuration has its own top-level structure; it isn't a rule provider. Login and error pages can sometimes return a success status too, but they still aren't valid rule data.

Test the behavior with a local file before switching to remote updates. This configuration assumes a proxy group named “Main Outbound” already exists. Rule file paths are relative to the core's working directory, which may differ from the directory containing an imported profile in a graphical client.

rule-providers:
  work-sites:
    type: file
    behavior: classical
    format: yaml
    path: ./rules/work-sites.yaml
rules:
  - RULE-SET,work-sites,DIRECT
  - MATCH,Main Outbound

Write the following content to rules/work-sites.yaml in a location the core can access. Put only match conditions in the provider file; keep the DIRECT outbound on the reference line in the main configuration. The domains here are examples. For testing, use domains whose ownership is clear and that you are allowed to access.

payload:
  - DOMAIN,login.example.com
  - DOMAIN-SUFFIX,intra.example.com

Check three states when switching to remote updates

Change the provider's type to http, then add a real rule URL in url and an interval in seconds. Give each provider its own local cache path. Keep the existing behavior and format only if they match the remote content. After switching, check the initial download, provider load, and connection match separately: a successful request doesn't guarantee successful parsing, and successful parsing doesn't mean the current test connection will match. If the address is reachable only through a specific outbound, review the download route. Don't make the initial update depend on a rule provider that hasn't been downloaded yet to select that outbound.

Set the update interval to match how often the source changes. Short intervals generate repeated requests and may trigger upstream rate limits; long intervals delay rule changes. When troubleshooting, note the last successful update and trigger one manual refresh using the method supported by your client. Don't infer that new rules are still inactive from logs for an old connection, and don't rely only on the file modification time: the core may not have reloaded it, or may be using a different cache. Keep a working copy of the old cache before deleting it so you can recover if the remote source becomes unavailable.

For regression testing, prepare at least one destination that should match, one similar destination that should not, and one expected to match an earlier exception. Check the outbound for each to distinguish an overly broad provider, an ordering problem, and stale data. If the core receives an address rather than a domain, investigate traffic interception and how the domain is supplied. Don't add an entire shared address range to the same outbound just to make one domain match.

03 / DNS

DNS Configuration and Resolution Path Optimization

First check whether the client sends DNS queries to the core

Apps may use the system resolver or send encrypted DNS requests themselves. Enabling mihomo's dns only gives the core DNS resolution capabilities; whether an ordinary app uses them also depends on whether the proxy protocol carries a domain or an IP address, how the system resolver is configured, and whether TUN intercepts the relevant requests. A page loading in your browser doesn't tell you which DNS server was used. When troubleshooting, first confirm that the connection reached the core, then check whether the core is resolving the domain or only received an address the app had already resolved.

After switching networks, a device may get a new private DNS resolver. Public resolvers usually don't know local hostnames or internal corporate service endpoints. If an internal name resolves only on the work network, first confirm the original resolution path, then configure a dedicated upstream for that domain or keep resolution on the system path. If the query returns the right address but the connection still fails, check the route and rule for that destination instead of changing upstreams again. DNS returns a destination address; it doesn't make that address reachable.

Choose upstreams by resolution role

nameserver is the default upstream for ordinary queries. nameserver-policy can route specific domains to different upstreams. default-nameserver provides bootstrap resolution for DNS upstreams specified by hostname; an address reachable directly is a good fit. proxy-server-nameserver resolves hostnames used by proxy nodes. They serve different layers: if the proxy server's address isn't known yet, you can't require that same proxy to resolve it. An existing cache may temporarily hide this kind of loop after a configuration change, only for it to appear on the next cold start.

The example uses real-IP answers to isolate DNS issues and public upstreams to show how the fields fit together; it isn't a recommended combination for every network. First confirm that your network allows access to these upstreams. If your environment requires a specific resolver, use the address provided by your administrator. The two HTTPS endpoints in the example belong to different services and handle ordinary and policy-routed queries respectively; they are not backups for each other.

dns:
  enable: true
  enhanced-mode: redir-host
  default-nameserver:
    - 223.5.5.5
  nameserver:
    - https://dns.alidns.com/dns-query
  proxy-server-nameserver:
    - 223.5.5.5
  nameserver-policy:
    "+.example.com":
      - https://dns.google/dns-query

Don't treat every mechanism as a timeout fallback

When configuring a backup upstream for ordinary queries, fallback and fallback-filter affect which answers are accepted; they aren't a simple switch that activates only after the primary resolver times out. If your goal is to route different domains through different resolution paths, domain policies are easier to verify. Different upstreams may also return different CDN endpoints, so query time alone doesn't tell you how the subsequent connection will perform. Before enabling respect-rules, set up an independently reachable path for resolving proxy nodes and check which outbound the DNS upstream itself uses. This avoids rules and queries waiting on each other.

If you've configured a separate direct-nameserver for the Direct outbound, don't assume ordinary domain policies automatically apply to that resolution path. To make it follow domain policies, check whether your core supports direct-nameserver-follow-policy and test with a destination that should go direct. Whether a query returns an IPv6 address and whether the device can connect over IPv6 are separate questions. Change related settings only when gathering comparison data. If the failure affects only one address family, check its routes, interfaces, and interception first instead of treating its complete deactivation as a universal fix.

Track cache state, query results, and connection results separately

When troubleshooting, keep the domain and network constant. Record the query result, then inspect the matched rule, destination address, and failure stage for a new connection. If the old address still appears after a configuration change, it could be in the system, browser, or core cache—or the app could be reusing an old connection. Identify which layer you measured, then clear that layer or start a new session using the method your client supports. If your comparison browser has its own Secure DNS enabled, you can temporarily switch it to the system resolver for a controlled test, then restore the setting. A query missing from the core log doesn't by itself mean the upstream is down.

04 / TUN & FAKE-IP

TUN Traffic Interception and Fake-IP Mapping

These settings solve different problems

TUN handles traffic entering a virtual interface: it determines which system routes send connections to the core. Fake-IP affects DNS responses: the core returns a synthetic address for a domain, then restores the domain mapping when it receives a connection to that address so domain-based rules can still match. Enabling one doesn't configure the other. The system proxy depends on whether apps honor system settings; if an app doesn't, changing the listening port or adding another proxy group won't automatically route it through the core. First identify whether traffic isn't being intercepted or whether the intercepted connection lacks a matchable domain.

Verify interception on your current network with a minimal configuration

Merge the following fields into a configuration that already has outbounds, rules, and a working DNS upstream. Merge existing dns and tun sections by field; don't declare the same top-level key twice. The address range in this example is for synthetic responses from the core, not a public range to access through a physical network interface. Before adding routes, make sure it doesn't overlap with your test network, lab, or existing virtual networks. The filter list is only a compatibility example; if your client maintains its own list, keep the entries you still need.

tun:
  enable: true
  stack: mixed
  auto-route: true
  auto-detect-interface: true
  dns-hijack:
    - "any:53"
    - "tcp://any:53"
dns:
  enable: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter-mode: blacklist
  fake-ip-filter:
    - "+.local"
    - "+.lan"

The dns-hijack rules apply to ordinary DNS traffic that has been intercepted. They won't unwrap HTTPS-based encrypted DNS requests initiated by an app, and they can't guarantee that every OS sends requests to local or LAN resolvers through the virtual interface. Fake-IP filter entries mean the listed domains won't use synthetic addresses; they don't automatically configure the right upstream for internal domains. If a printer or internal site still won't resolve, check multicast discovery, system search domains, and private DNS paths separately instead of repeatedly switching network stacks.

Check permissions and actual routes for your platform

On desktop systems, first check that the client successfully created a virtual interface and that the main routing table shows the expected intercepted routes. A Windows GUI client may manage permissions through a service; if the service isn't running, a remembered toggle in the UI doesn't mean the routes are active. On Linux, check that the process can create a TUN interface and manage routes; in a container, confirm the device and required permissions are actually passed through. On macOS, consider the system interface and permissions used by the client when checking which traffic is intercepted. On mobile, if the client uses the system VPN interface, check system authorization, VPN status, and whether another VPN is already active. Desktop service settings don't apply there.

auto-detect-interface can help identify an outbound interface, but its default may not be enough when multiple NICs are present, wired and wireless are both active, or another VPN is running. After switching networks, compare the outbound interface and default route, then check whether node connections leave through the expected NIC. For diagnosis, stop other interception mechanisms and leave only one path active. If you need LAN access, record the original destination subnets and gateway. Any bypass route should be limited to the actual LAN subnet; don't broadly exempt large address ranges from interception.

Roll back and retest based on the symptoms

If an app times out after receiving a synthetic address, check whether connections to that address reach the same core instance, whether the mapping is still available, and whether the app is holding an old response from before the configuration change. If the app rejects synthetic addresses outright, add a precise filter only for affected domains, then compare with real-IP mode. If the whole device loses internet access after TUN is enabled, disable TUN first and confirm the default route is restored. Then retest the interface, node resolution, and a regular webpage in that order. Use the same test destination and change just one of the network stack, route range, or resolution mode at a time.

05 / SNIFFER

Domain Sniffing and Destination Override

Use sniffing to fill in domain details, not as a substitute for DNS

The core may already know a domain from an explicit proxy request or a synthetic address mapping. In other cases, an app resolves a name first and connects directly to the address. The rule engine may then see only an IP and fail to match the intended domain rule. Sniffing attempts to recover a domain from protocol metadata in intercepted connections, such as the Host header in plain HTTP or a visible name in a TLS handshake. It doesn't rerun DNS or decrypt the app's content. Connections without usable metadata still need address-based rules or the final catch-all rule.

Some clients change connection behavior through pre-resolution, connection coalescing, or their own encrypted DNS. Logs for the same destination can differ between a browser and a native app; a match in one browser version doesn't prove that all traffic for the service exposes the same domain. With an encrypted ClientHello, the real hostname may not be recoverable from the handshake. Whether QUIC provides usable information depends on the packets and implementation. Even when a name is recovered, it doesn't uniquely identify an app, account, or every subsequent request.

Check rule matches first; consider destination override later

The configuration below limits sniffing to common ports, giving connections that expose only a destination IP a chance to be inspected. override-destination: false is a good starting point: use the detected domain for rule matching without changing the original destination just because a name was found. Use skip-dst-address to exclude destination ranges and skip-domain to exclude domains. Set address ranges for your actual network rather than copying a whole range and guessing why some connections aren't detected.

sniffer:
  enable: true
  parse-pure-ip: true
  override-destination: false
  sniff:
    HTTP:
      ports: [80, 8080]
    TLS:
      ports: [443, 8443]
    QUIC:
      ports: [443]
  skip-domain:
    - "+.local"
  skip-dst-address:
    - 192.168.0.0/16

Before enabling destination override, understand how the outbound resolves domain names. A new lookup may send the connection to a different endpoint, which is especially common with CDNs, internal load balancers, and private domains. If an app depends on the original address or the server uses the endpoint to distinguish tenants, overriding the destination can break the connection for reasons unrelated to rules. If override is genuinely needed, enable it only for controlled cases in the protocol-specific configuration, and record the original address, detected name, actual outbound, and final reachability for comparison. If you only need domain rules to match, preserving the original destination is usually the better first step.

Start with a connection that didn't match

In the connection details, first check the destination port and protocol, then confirm that the core actually intercepted the connection. A DNS log entry doesn't prove that the subsequent data connection also passed through the core. If you still see only an IP, check in order whether the port is in scope, the destination is excluded, the protocol is supported, and the connection actually uses a handshake with a visible name. If a domain is already visible but the wrong rule matches, check rule order and match scope first. Forcing sniffing on traffic with an existing mapping is a separate choice. Without evidence that the mapping is unreliable, don't broaden its scope based on guesswork.

Keep the outbound and upstreams unchanged during testing; compare two new connections, one with sniffing off and one with it on. Check both the rule match and any new handshake failures, app delays, or repeated reconnects. If many issues appear only after expanding the port range, revert to known application ports instead of sniffing all traffic. For a stable business rule, an address rule may also work if the destination has a clearly defined, maintainable range. If the address is shared by a hosted service, check the potential for misclassification first.

06 / PROFILE MERGE

Local Overrides and Multiple Subscription Merging

Identify each input before combining anything

Check the response content before importing; don't rely on the link's file extension. A full configuration containing listening ports, DNS, proxy groups, and rules can be imported as a client profile. A file containing only a proxies list is better suited to a proxy provider. Whether an encoded node list can be imported directly depends on whether the client converts it. Pasting a full configuration URL into a proxy provider doesn't import its rules. To extract nodes from it, confirm that the parser accepts the response, or use a local conversion workflow you control. For format details, see Subscription URL Import and Format Guide.

Concatenating two YAML files that each have a top-level rules list won't produce a clearly ordered rule table. Duplicate keys may be rejected or the later list may overwrite the earlier one. Keep node sources in their respective providers and put the final rules, proxy groups, DNS, and listener settings in one main configuration to define the update boundaries clearly. If both full configurations have their own rules, document what each is intended to do, then build one ordered list of exceptions, business rules, and a catch-all. Don't leave both catch-all rules in the middle.

Combine routes with separate providers

The example uses local files to show how merging works. Each input file should have a top-level proxies list with working proxy entries that have unique names. Before enabling it, confirm that the files are in the working directory the core actually uses. For HTTP providers, configure a subscription URL, cache path, and update interval for each one; don't let two subscriptions write to the same cache. Add health checks only if needed, using a probe address that is reliably reachable. Avoid checking the same candidates repeatedly at a high frequency.

proxy-providers:
  source-a:
    type: file
    path: ./providers/source-a.yaml
  source-b:
    type: file
    path: ./providers/source-b.yaml
proxy-groups:
  - name: Combined Outbound
    type: select
    use: [source-a, source-b]
rules:
  - MATCH,Combined Outbound

If node names collide, identify their sources before combining them. Prefer adding stable source prefixes in a controlled conversion step, or use provider override fields supported by your core version. Renaming the provider doesn't rename each node in it. Also check fixed node references in groups, filters, and previously saved selections. A new node added by a subscription may happen to match a broad filter and end up in a business group it wasn't intended for. Before rollout, check each group's actual members and the outbound used for at least one business destination.

Give each client override one clear responsibility

A client's local override isn't a universal mihomo field. A GUI may use merge templates, scripts, list prepending, or full replacement. Even two options both labeled “Override” may handle arrays differently. Start with a test rule that won't disrupt everyday connections, verify where it is inserted, and inspect or export the final runtime configuration before widening the change. For a simple mapping, such as a DNS toggle, change only the intended field. For an ordered rules list, define exactly where it should be inserted so an override doesn't leave you with only the test rule.

Keep rollback copies for subscriptions, conversion, and runtime configuration

Before an update, save separate working copies of the subscription, local overrides, and final effective configuration. After the update, confirm that providers load and groups aren't empty, then check one direct connection and one proxied connection. Only then test startup recovery and scheduled refreshes. If a manual import works but breaks after an update, check whether you edited generated output instead of the override source. On a load error, find the first specific cause in the core log and distinguish an unreadable path, bad indentation, a missing reference, and a port conflict. Rolling back only the failing layer is easier to diagnose than reinstalling the client and replacing every subscription at once.

07 / EXTERNAL CONTROLLER

External Controller API and Dashboard

Know the difference between the controller, proxy port, and dashboard

mixed-port handles proxy traffic, external-controller exposes the control API, and the dashboard is a frontend that calls that API. They fail in different ways: a webpage loading through the proxy doesn't mean the dashboard can read connections, and a dashboard listing groups doesn't mean apps are using the right proxy port. The controller can change runtime state as well as read it, so don't expose it like an ordinary static website. If you're using the client's built-in dashboard, confirm that it connects to the core instance started in this session. Before entering an address in an external dashboard, check the actual listening port so you don't connect to another running instance.

Bind the controller to loopback by default

This example binds the controller to the local IPv4 loopback address. Before merging it, make sure the port is free, replace the example secret with a randomly generated value used only for this purpose, and restrict access to the configuration file. The secret is not proxy authentication; don't reuse subscription credentials or your system login password. Loopback binding and authentication serve different roles: binding limits network reachability, while the secret restricts local processes or authorized forwarding clients that can connect. Enabling LAN access for the proxy doesn't control access to the controller; check these settings separately.

external-controller: 127.0.0.1:9090
secret: "demo-not-for-deployment"

To serve dashboard files from the core, set external-ui to a trusted local dashboard directory, then open /ui/ at the controller address. The directory must be within the core's permitted paths and contain prepared frontend files, not source files or an archive. Setting external-ui alone doesn't turn any local directory into a usable dashboard. Hosting it under the same controller address can avoid cross-origin configuration differences. You'll still need to enter the controller secret as prompted by the dashboard; don't put the secret in a shareable URL.

Test the API before opening the dashboard in a browser

These commands are for common command-line environments with curl. Set MIHOMO_API_SECRET securely in the current session; don't put it in website files or shared terminal screenshots. Start with a read-only version endpoint: if it can't connect, check the listening address, port, and whether the core is running. If the response says unauthorized, check the secret. If you get a webpage instead of the expected API data, check whether you contacted the proxy port, dashboard path, or another local service.

curl --noproxy '*' --silent --show-error --include \
  -H "Authorization: Bearer ${MIHOMO_API_SECRET}" \
  http://127.0.0.1:9090/version

If the command succeeds but the dashboard still reports an error, check the browser's network panel. If the page and API differ in protocol, host, or port, they're different origins. The browser may block requests because of CORS, mixed content, or local network access restrictions. Don't allow all origins just because the dashboard says it can't connect. Allow a specific page origin only when you genuinely need a cross-origin deployment and your core supports it; prefer same-origin hosting when that meets your needs. If ordinary API requests work but the log stream doesn't, check the browser's long-lived connection request and whether any intermediary supports it.

Separate temporary actions from persistent configuration

After switching proxy groups in the dashboard, open a new connection and check its matched rule and outbound chain. The dashboard's immediate state may not be written back to the original YAML; whether it survives a restart depends on the client's or core's storage settings. Put DNS, listener, and rule changes you want to keep in a maintainable configuration source, then reload it instead of relying on a one-off dashboard action. Record the runtime state after changes and check it again after a restart, especially when multiple configurations share a controller address.

To manage the core from another device, use a controlled management channel to reach the loopback interface. Don't expose the controller port directly to the public internet or a shared network. After deployment, verify locally that you can read the status, then confirm the port is unreachable from devices that should not have access. If you suspect the secret appeared in a public screenshot, command log, or configuration backup, restrict reachability first, then rotate the secret and confirm the runtime configuration has loaded the new value. A misconfigured dashboard shouldn't prevent basic proxy checks: even with the dashboard disabled, use core logs to check startup, rule matches, and outbound connections separately.