Advanced Guides · Windows 11

Advanced Clash Configuration Guide

From proxy groups to a local controller dashboard: configure mihomo layer by layer and verify where each connection goes.

If you’re importing a subscription or setting up the system proxy for the first time, get a working connection with the user guide before returning to this guide. The sections are organized by configuration layer, making it easier to look up fields, migrate settings, and troubleshoot changes. Clash for Windows is no longer maintained; the examples below target mihomo and may not work with older cores. For a new installation, check the recommended Clash Plus client on the download page, then confirm which core the client actually uses and how it handles configuration.

Proxy Group Types and Routing

Rules determine which category a connection matches; proxy groups choose an available outbound. If a connection matches “Manual Outbound,” that only means the rule passed it to that group—you still need to check which route the group currently selects. For troubleshooting, use Rule mode to keep the test conditions fixed. Switching to Global changes more than the proxy group: it also bypasses the existing destination-based routing. See the comparison of Rule, Global, and Direct modes for how traffic flows in each mode.

Choose a group for the job before adding automatic switching

TypeHow it selectsBest for
selectChoose a member manuallyInitial testing and workloads that need a fixed outbound
url-testSelect automatically based on probe resultsChoosing the best route among similar options when a fixed outbound isn’t required
fallbackPrefer the first available member in the listA clear primary-and-backup setup where availability comes first
load-balanceDistribute connections according to the group’s strategyIndependent connections that can use different outbounds

For admin consoles that require persistent sessions and services sensitive to outbound changes, prefer a manually selected group. Automatic latency tests measure how members perform against a specified probe URL—not the full route to your destination or its throughput. When tuning an automatic group, compare two candidates at the same time of day, then check whether switching outbounds forces the application to sign in again. A fallback group prioritizes order; the primary route doesn’t have to be the fastest. If it still passes the probe, don’t replace it just because the backup is faster.

Load balancing distributes connections; it doesn’t combine multiple routes to speed up a single download. A single page may also open separate connections for sign-in, APIs, and static assets, so don’t put sites that need a stable outbound directly into a load-balanced group. When designing your routing, start with one main group and one Direct action. Add subgroups only after connection logs show that a workload needs separate handling. Rules can then target stable group names, so changing subscriptions won’t require editing them one by one.

Test the selection path with a minimal config that doesn’t depend on a subscription

This is a standalone test config you can load on its own. The manual group has only two built-in members, Direct and Reject, to help distinguish between “the rule didn’t match” and “the rule matched, but the group action wasn’t what I expected.” Don’t overwrite an active subscription with a temporary config. If a port is already in use, choose an unused local port and update the test app’s proxy address to match.

mixed-port: 7890
allow-lan: false
mode: rule
proxy-groups:
  - name: Manual Outbound
    type: select
    proxies:
      - DIRECT
      - REJECT
rules:
  - DOMAIN,example.com,Manual Outbound
  - MATCH,DIRECT

In the client, set the group to DIRECT and send a request through the specified local proxy, for example: curl.exe --proxy http://127.0.0.1:7890 --head https://example.com/. Confirm that the connection log shows the destination domain and selected group, then choose REJECT and run the request again. Both requests should go through the same group, but the second should not establish a successful proxy tunnel. Restore the original config when you’re done. Repeatedly refreshing in a browser can reuse connections or serve cached content; starting a fresh command-line request each time is easier to interpret.

Naming and troubleshooting with real routes

In an existing config, proxies references declared node or group names, while use references declared proxy providers. Names must match exactly, and a group must not reference itself, directly or indirectly. If an update leaves only built-in options, first check whether the provider loaded and whether filters removed all its members. Then check whether the group still has a stale selection that no longer exists. Don’t change routing rules to fix missing members. If the rule match appears as expected in the logs, look at the group definition or provider instead.

For an automatic group, choose a probe URL that all candidate routes can reach reliably. Set the probe interval to match how quickly you need to detect failures; shorter isn’t always better. Frequent probes across many groups and candidates add requests and make brief network jitter more likely to trigger a switch. For acceptance testing, record at least three things: whether the group contains the expected candidates, whether manual selection can establish a new connection, and how the automatic group behaves when the primary route recovers. If probes pass but the service fails, note the actual destination and where the failure occurs, then check DNS or the server response. Don’t keep changing groups based only on what the UI shows.

Manage Rules with Rule Providers

Rule providers keep reusable match conditions out of the main config. A provider loads the rule file; RULE-SET places that collection in the matching order and specifies the action to take when it matches. Adding a provider without referencing it won’t change any connections. Removing a provider while leaving its reference may prevent the config from loading. Node subscriptions supply available outbounds; rule providers supply match conditions. They serve different purposes, even if both downloads happen to be YAML files.

Understand matching behavior and file format separately

Use behavior: domain for a set of domains, ipcidr for address ranges, and classical for entries that include rule types. Behavior defines what each line matches; format defines how the file is parsed. For example, a YAML file typically lists entries under a top-level payload key, while a text file has one entry per line. Don’t copy YAML list markers into a text file. Before using a third-party rule set, inspect its contents instead of guessing from the extension or repository title. A page that opens in a browser isn’t necessarily a usable rule file.

Get the matching flow working with a local file before switching to periodic downloads. The example puts one exact domain in a classical rule set, ahead of the Direct fallback. It’s only for observing a controlled rejection; remove it after testing. Put the first snippet in a temporary config and save the second as rules/manual-local.yaml in the core’s working directory. Don’t combine the two snippets into one file.

mode: rule
mixed-port: 7890
rule-providers:
  manual-local:
    type: file
    behavior: classical
    format: yaml
    path: ./rules/manual-local.yaml
rules:
  - RULE-SET,manual-local,REJECT
  - MATCH,DIRECT
payload:
  - DOMAIN,example.com

Manage remote sources, caching, and rule coverage

For remote rules, set the provider to type: http, point url to the raw file at a trusted source, set interval in seconds, and give it a dedicated local cache path. Don’t let two sources in the same directory share a cache file. A failed first download may behave differently from a failed update when a usable copy is already saved. Check provider status and logs in the client; being able to read the old file doesn’t mean the update succeeded. Paths are resolved relative to the core’s working directory, not necessarily the subscription file or desktop shortcut.

Review rule files as part of your config. Before adding a source, check which domains and address ranges it covers, and look for broad entries that could capture a large amount of traffic. Pay particular attention to business domains, identity providers, and update services that might be routed incorrectly. Rules are processed from top to bottom, and the first match wins: put high-priority exceptions before broad sets and leave MATCH last. If an address appears in multiple sets, the reference order in the main config determines the result—not when the remote files were last updated.

Validate downloads, parsing, and matching separately

First, confirm the remote response is the actual rule file—not a sign-in page, rate-limit message, or error page after a redirect. Next, confirm the core parses it successfully and that the declared behavior matches the entries. Only then test a new connection for a match. Choose at least one destination that should match and one that should reach the fallback. If domain rules work but address rules don’t, check whether the connection already has an IP address, whether matching requires DNS resolution, and whether the relevant entries use no-resolve. That option controls whether DNS is triggered for that kind of rule during matching; it doesn’t disable resolution for the entire connection.

If a download fails, first check whether fetching the file depends on an outbound route that hasn’t been established yet. That can create a startup loop: updates need a working route, but the route’s config won’t be ready until the update finishes. Keep a known-good copy and test the update path separately from the service traffic. Don’t change the default outbound for all traffic just to get updates working. If only one set starts behaving differently after an update, restore its file and reference order first, leaving the other sets untouched. Once things work again, compare the old and new entries for the affected domain.

Optimize DNS Settings and Trace Resolution Paths

The first step in DNS troubleshooting is to find out who’s making the query—not to switch servers right away. An app using an HTTP proxy can send the domain to the proxy directly. Other apps may resolve it locally first or use encrypted DNS on their own. A site opening in your browser doesn’t prove that Windows and the core used the same resolver. Track “the correct address was returned” separately from “the client connected using that address,” especially when TUN is enabled or a corporate networking client is running.

Separate default, bootstrap, and proxy-server DNS

FieldPurposeCommon misconception
default-nameserverBootstrap resolution for DNS upstreams specified by hostnameA fixed outbound for all DNS queries
nameserverDefault upstream for regular queriesAssuming list order defines a fixed primary and backup
nameserver-policySelect an upstream based on matching criteria such as the domainAssuming upstream selection also changes the website’s proxy route
proxy-server-nameserverChoose an upstream to resolve hostnames used by proxy serversAssuming this resolves every website accessed through a proxy

If an encrypted DNS upstream is specified by hostname, its address must be resolved before the first connection can be made. If that bootstrap query depends on a proxy that isn’t up yet, you may see failures only on a cold start, followed by apparent recovery. Don’t wait until the network is back before changing fields: reload the config, close existing connections, and make the first query again. For corporate domains, ask your administrator which internal resolvers to use and what queries they permit. Don’t send internal hostnames to public services as a test.

nameserver-policy can send internal and public domains to different resolvers, but that doesn’t guarantee the subsequent connection uses the right interface. If the name resolves to the correct internal address but routing sends the connection through the wrong outbound, fix the rules or routes. Conversely, adding a Direct rule for an internal service won’t necessarily make it reachable if the app first got a nonexistent answer from the wrong resolver. Verify the DNS answer first, then check the rule and outbound in the connection log to keep these failure modes from masking each other.

Compare using a dedicated DNS listener

Enable the following in a temporary config first, using redir-host to return real addresses. Leave system DNS unchanged for now. The example uses public resolvers for comparison and is only for testing public domains; it isn’t suitable for internal domains and may not be reachable on every network. If the config already has a dns section, merge only the relevant fields instead of adding a second top-level key. Keep the listener bound to the loopback address.

dns:
  enable: true
  listen: 127.0.0.1:1053
  ipv6: false
  enhanced-mode: redir-host
  default-nameserver:
    - 1.1.1.1
  nameserver:
    - https://cloudflare-dns.com/dns-query

In Windows Command Prompt or PowerShell, run nslookup -port=1053 -type=A example.com 127.0.0.1. This checks only the core’s listener and its upstream path. Then run Resolve-DnsName example.com -Type A to check resolution from Windows. The two commands don’t need to return identical addresses: resolver location, caches, and server-side routing can all affect the result. Focus on whether each returns a usable answer, which side times out on failure, and whether later connections actually use the path you observed.

Use the symptoms to identify which layer to change

If every query times out, check the listener port and upstream reachability. If only proxy server hostnames fail, look at their DNS resolution and startup dependencies. If just one internal suffix fails, check the domain match and whether the resolver is on the right network. If public domains resolve but websites won’t load, read the connection log first. Distinguish a connection timeout from a failed TLS handshake or a server rejection before checking address families. In the example above, dns.ipv6: false changes AAAA response behavior in that DNS module only; it doesn’t disable IPv6 in Windows or in apps.

Before comparing results, close the tested app’s existing connections. If needed, run ipconfig /flushdns to clear the Windows DNS cache. This doesn’t clear the browser’s or core’s own cache. If the result doesn’t change, check whether the request actually reached the resolver under test again. Keep a baseline config and change one variable at a time—such as the upstream, policy match, or address family. A brief recovery doesn’t confirm the cause; retest at least once after restarting the core and reconnecting to the network.

How TUN and Fake-IP Work Together

With a system proxy, apps that support proxy settings send requests to a proxy port. TUN uses a virtual network interface and routes to send selected traffic to the core. Fake-IP operates at the DNS layer: it returns a virtual address mapped to a domain, which the core restores when the connection arrives. They’re often used together, but they solve different problems. If an app gets a virtual address but packets leave through a physical adapter or another tunnel, adding domain rules won’t help.

Take over traffic first; change DNS responses second

Before updating the config, note the original system proxy, virtual adapters, DNS mode, and active network. Keep real-address responses that already work, enable TUN, and test an app that doesn’t use the system proxy. Once you’ve confirmed its connection actually goes through TUN, switch to Fake-IP for a second round of testing. If the client offers a service mode, follow its instructions to authorize installation or start the service, then check that the virtual interface and routes were actually created. Don’t treat the UI toggle as the only evidence. Follow your organization’s network and permission requirements on managed devices.

These fields apply after traffic capture is working. Reuse the upstream you verified in the previous section. Keep the existing upstream and listener settings in dns, and change only the relevant fields to the values shown here. Before enabling them, check for address-range conflicts with existing virtual networks, test environments, or organizational routes. fake-ip-filter lets matching names bypass virtual responses. If the existing config uses a different filter mode, verify what it means; don’t assume the list always contains exclusions.

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:
    - "localhost"
    - "+.local"

stack controls how TUN handles traffic; changing the network stack won’t fix every app compatibility issue. auto-route sets up routes for traffic capture, while auto-detect-interface identifies the core’s outbound interface. They aren’t interchangeable. Entries under dns-hijack apply to regular DNS requests that enter the captured path; they don’t capture encrypted DNS sent directly by an app. If the browser uses its own encrypted DNS, test its response separately from the system resolver.

Tell interface, routing, and mapping failures apart

In PowerShell, use Get-NetAdapter to check whether the virtual adapter appears, then use Get-NetRoute -AddressFamily IPv4 to compare relevant routes before and after enabling TUN. If the interface is missing, check service and permission logs first. If it’s present but the tested app has no connection entry at all, check whether the destination is in the capture scope and whether another VPN controls the same traffic. If an entry appears without the expected domain, compare it with the actual DNS response and check whether DNS bypassed the core or reused a pre-switch cache entry.

Test at least one public domain, one local service that must remain reachable, and the first new connection after switching between Wi-Fi and Ethernet. Being able to browse public sites doesn’t prove that local printers, file shares, or corporate clients are unaffected. For local devices, compare access by hostname and by IP address. If the IP works but the hostname doesn’t, DNS or local discovery is more likely. If both fail, check routes and firewall policy. Don’t use disabling system protections as a substitute for diagnosis.

Shut down in order to avoid stale virtual addresses

If Fake-IP breaks an internal domain, add a narrowly scoped exception for the verified name and test again; don’t exclude every site at once. If you can’t tell how broadly the issue affects traffic, pause the impacted work, restore the previous DNS mode in the client, and exit TUN. Confirm that routes were removed before restarting affected apps or clearing their caches. Closing the window may not stop a background service. Removing routes while leaving Fake-IP resolution and cached mappings in place can also leave connections failing. Finally, check whether the system proxy needs to be restored instead of leaving both traffic-capture methods enabled and making the test results hard to interpret.

When to Use Domain Sniffing

Some apps resolve a domain to an address first, then send only the IP at the network layer. When that happens, the core may not know the destination domain at first, so even an accurate domain rule can’t match and routing may fall back to an IP rule or a catch-all. Domain sniffing tries to recover the hostname from recognizable connection metadata, such as an HTTP host field or the server name in some TLS handshakes. It doesn’t decrypt traffic and can’t infer a domain from arbitrary connections. Decide whether to enable it by starting with a reproducible connection that lacks a hostname.

Limit protocols and ports; observe before overriding the destination

The example observes common HTTP and TLS ports only. It doesn’t include QUIC or override the connection destination. parse-pure-ip allows attempts to identify connections that provide only a destination address. force-dns-mapping relates to sniffing traffic with a DNS mapping; when testing connections that originally lacked a hostname, don’t force handling of traffic that already has a DNS mapping. override-destination controls whether a detected hostname replaces the original destination. That’s separate from whether the hostname can be observed at all.

sniffer:
  enable: true
  parse-pure-ip: true
  force-dns-mapping: false
  override-destination: false
  sniff:
    HTTP:
      ports:
        - 80
    TLS:
      ports:
        - 443

Merge these fields into the existing sniffer section. If the subscription sets destination overrides separately under protocol entries, check that those local settings match your expectations too. Don’t add every port to the sniffing scope on the first try: custom protocols may not resemble standard handshakes, and an overly broad scope can cause hard-to-explain compatibility issues. Add one protocol or port at a time only if needed, leaving other settings unchanged. To exclude specific traffic, use domains or source and destination address ranges supported by your test results. For connections whose hostname hasn’t been identified, a domain exclusion alone isn’t enough.

Compare rule names with the actual connection destination

Start by noting the original destination address, port, protocol, and matched rule in the connection list. Close the app’s existing connections, enable sniffing, repeat the same request, and check whether a hostname appears and a more specific domain rule matches. For a controlled comparison, use a test service you administer: connect to its known address and provide its correct TLS server name. Don’t make an incorrect destination appear to work by ignoring certificate errors. Requests that already send a domain directly to the proxy can’t show that sniffing recovered new information.

If a hostname appears but the matched rule doesn’t change, check rule order first: a broad address rule or earlier rule set may have matched already. If the rule changes but the connection fails, check the selected proxy group and final destination separately. Make sure a destination override didn’t trigger another round of resolution or routing. Services that share IP addresses may use the same address for multiple domains, so one observation isn’t enough to justify a permanent domain-specific rule for that IP. After testing, keep the narrowest rule that explains the result; don’t turn a temporary experiment into a global fix.

Know the limits and leave room for compatibility

Sniffing may return nothing if a connection has no visible hostname, its handshake is encrypted, or its protocol isn’t in scope. For example, ECH can protect the actual server name, and the visible outer name may not identify the site the app is visiting. Being able to inspect TLS doesn’t mean you’ll get the same result from every QUIC connection. For an internal app that connects to a fixed address, routing it according to the expected address range is often a better fit than trying to invent a hostname. A hostname in the logs also doesn’t mean the traffic contents were read.

If enabling sniffing breaks only a few apps, first disable destination overrides and force a fresh connection. If the issue remains, test with a narrower port range or an exclusion for the test target. If there’s no evidence that the workload needs sniffing, leave it off and fix DNS or routing at the appropriate layer. Be specific in your notes: “hostname not observed,” “hostname appeared but the rule didn’t change,” or “rule changed but the connection failed.” These point to different issues—recognition conditions, rule order, and outbound routing—and shouldn’t be troubleshot by toggling the same setting at random.

Local Overrides and Combining Multiple Subscriptions

A subscription answers “what does the provider supply?” A local override answers “how should this machine run it?” Don’t maintain rules, DNS, and ports directly in a file that can be overwritten by a refresh. Save local changes separately, then confirm whether the client supports YAML merging, field-level overrides, or script-based processing. Mixin in older versions of Clash for Windows is not implemented the same way as overrides in other clients. Similar menu labels don’t guarantee the same merge order or list-handling behavior.

Keep outbound sources separate from local policy

Before adding multiple subscriptions, check whether each source returns a complete config, a file readable by a proxy provider, or a generic subscription that needs conversion. A complete config may declare ports, rules, groups, and DNS all at once. Pasting two files together can create ambiguity through duplicate keys or cross-references. To identify the format, see subscription formats and conversion. Subscription URLs may contain access credentials. Don’t upload them to an untrusted converter or share them in logs.

One maintainable approach is to keep a single local routing table and add separately readable node lists as separate providers. The example uses two local files; each is a proxy provider file with real available nodes listed under the top-level proxies key. It doesn’t add any made-up nodes. Prepare both files first, then merge the snippet into the main config and check the working-directory paths. Here, use references provider names, not subscription URLs or folders.

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
    proxies:
      - DIRECT

First, validate that a config with just one source lists candidates in the group, then test a connection through one of its real outbounds. Add the second source afterward. If you need routing rules, reference Combined Outbound in the existing rule table and keep the original fallback action so loading the config doesn’t change traffic across the board. The two sources may contain nodes with the same name. Use a supported naming option to distinguish them in the UI, or put them in separate subgroups so you don’t mistake two members for the same route while troubleshooting. Don’t rely on a trailing route number as a stable identifier; names may change after a subscription update.

Validate map fields and list fields separately

Scalar values such as ports usually need a clear choice of which value takes precedence. A map such as dns may merge field by field or be replaced as a whole by the client. When changing DNS upstreams, make sure the final config still has the listener and address mode you need. rules and proxy-groups are lists; a UI message saying “override enabled” doesn’t tell you where new entries ended up. A rule appended after MATCH won’t work as intended, and duplicate groups with the same name may cause the core to reject the config.

Start with a small experiment that’s easy to undo: add an exact test rule for an example domain near the top of the local rules, then check the generated config and which rule a new connection actually matches. Remove the test rule afterward. Repeat the check after refreshing the remote subscription to see whether the local entry is still in the expected position. If the client can export the final config, inspect that first. If it only provides logs or a runtime view, at least check rule order, group members, and listening ports. Judge the result by the config the core actually received, not the draft in the override editor.

Roll out changes in a reversible order

Before updating, keep a reloadable baseline and a record of which local overrides go with which provider files. Check YAML indentation, duplicate keys, and all references before switching configs for a small set of tests. Retest at least one manual group, one connection that should match a specific rule, and one that should use the fallback. If you added a second provider, also confirm the first one still works. If something fails, first undo the latest override or restore a known-good config. Don’t reset the system proxy, reset DNS, and reinstall the client all in the same troubleshooting round. When sharing notes, include only relevant fields and remove personal directory names, subscription URLs, node credentials, and internal network details.

External Controller Dashboards and Local APIs

An external controller dashboard uses the controller API to read rules, inspect connections, and manage policies. It isn’t a proxy server for your browser. The proxy port carries app traffic, the DNS listener accepts queries, and the controller port manages the core. Check the binding address and access controls for each separately. If the client’s built-in UI already lets you inspect connections and switch policies, there’s no need to expose another API. If you do need a separate dashboard, start with a loopback binding and local static files.

Bind to loopback and distinguish the UI from the API

external-controller sets the API address, secret protects requests that require authentication, and external-ui points to the dashboard’s static files. This config listens on the local machine only. The password in the example is a dummy for illustration; replace it with a long random value before enabling the config. Don’t use it as-is or save it in a public repository. If the client already starts a managed controller API, don’t add another field with the same name to compete for the port. Check first whether the client allows overrides and where the API actually listens.

external-controller: 127.0.0.1:9090
secret: "your-password"
external-ui: ./dashboard

Put trusted dashboard files in the dashboard directory under the core’s working directory, and make sure index.html is directly inside it—not buried in another folder created when you unpacked an archive. After reloading the active config, open http://127.0.0.1:9090/ui/ on the local machine. If the dashboard asks for a backend, use the local loopback API and the password you just set. Serving static files doesn’t mean the API is authenticated. If the page shell loads, the file path is working; verify API responses separately.

Troubleshoot the port, authentication, and static files separately

SymptomCheck firstWhat to look for
Connection refusedWhether the core is running, the actual listener, and port conflictsListening address and associated process
API returns 401API authentication and an outdated password saved in the dashboardUnauthenticated requests are rejected; authorized requests can read status
Dashboard entry point returns 404Directory path, entry file, and whether the client manages the serviceStatic entry point is reachable; test the API separately
Dashboard loads but status doesn’t updateDashboard backend, browser console, and live API requestsDashboard reads the current config and refreshes connection status

Use these PowerShell commands to check local listeners and send an unauthenticated probe to the API. If the first command returns nothing, check the startup logs. If it shows a listener, confirm its address and process belong to the expected core. An unauthorized response to the second command means an HTTP service requiring authentication answered; it doesn’t prove dashboard sign-in works. Authenticate in the local dashboard, then check whether it can read group status. Don’t put a real password in command history that may be saved or in screenshots you plan to share.

Get-NetTCPConnection -LocalPort 9090 -State Listen
curl.exe --noproxy "127.0.0.1" -i http://127.0.0.1:9090/proxies

Limit management access to what you actually need

Turning off allow-lan doesn’t guarantee that the controller listens only on the local machine. Don’t infer the controller’s status from the proxy port settings. After reloading, confirm the actual address is 127.0.0.1, not a wildcard address on every adapter. Don’t expose the controller port to the public internet or loosen cross-origin access just to make a web page connect. Prefer a dashboard served from the same local address. Even if a page from another origin lets you enter a backend, don’t give it management credentials. Static dashboards and browser sessions may retain config, so don’t save management credentials in a shared browser.

After changing the password, reload the config and close dashboard sessions using the old password. First confirm that unauthenticated access is denied, then verify that a new session can read group status. Finally, test a low-impact connection to make sure the dashboard is controlling the intended local core. If it points to a different instance, changes won’t show up in the client you’re using. When you no longer need an external dashboard, disable the user-configured controller API using the client’s supported method and confirm that the port is no longer listening. For common installation and connection issues, see the download FAQ on the client page, or rebuild a known-good baseline with the connectivity checks in the user guide.