Routing in Clash
Everything on this page applies to Clash apps on mihomo: Koala Clash, Clash Verge, FlClash, ClashFest, SlothClash and others. Happ and INCY get a routing profile from these same settings in the routing header, and INCY with autoselect on gets the rules inside the whole config, see Autoselect in INCY. v2RayTun, Hiddify and other Xray and sing-box apps don’t get these routes.
Settings → Routing → Routing in Clash apps:
- Russian sites direct (default): Russian sites bypass the VPN based on geodata.
- Everything through the VPN.
- Only what is blocked: sites from Russian blocklists and services you sent to the VPN yourself go through the tunnel. Everything else goes direct.
Services
Section titled “Services”For each service you can choose: “Like the rest” (follows the mode), “Through the VPN”, “Direct”, “Block” or “Through a server”, meaning a specific node. The services: ads and trackers, YouTube, Telegram, Discord, WhatsApp and Signal, Instagram and Facebook, TikTok, X (Twitter), ChatGPT, Claude and Gemini, Netflix and Spotify, Twitch, games (Steam, Epic, Riot…), GitHub, torrents.
Past the VPN: Russian apps and sites (banks, government services, marketplaces) bypass the tunnel. On Android and desktop this works by app names, on iPhone by sites.
Empty: the panel’s default DNS. Ready sets: “The panel’s”, “All through the VPN”, “Russian domains by Yandex”. Servers are written as in mihomo: an IP or https://, tls://, quic://, and #PROXY at the end sends the query through the VPN. You can also set DNS for the servers’ addresses and your own DNS for domains, one per line like +.cn: https://dns.alidns.com/dns-query.
The Show the profile button shows what the app will get.
DNS at the exit
Section titled “DNS at the exit”Settings → Routing → DNS at the exit. On from the first start, on every node.
Some apps (Happ, v2RayTun, v2rayNG and others on the Xray core) look a site’s address up on the device and send the node a ready IP. A site may then decide the user is in their own country and say “not available in your region”. With this setting the node finds out which site the user goes to and connects to it from its own country. It does not get in the way of mihomo (Clash) clients: they send the node the site’s name anyway.
- Find out the site on the server: the node reads the site’s name from the connection (TLS, HTTP and QUIC on ports 443, 8443, 80 and 8080–8880). Other ports are left alone.
- DNS server: “The server’s own” fits almost always. There are presets for Cloudflare, Google and Quad9 (over DoH) and an own list: up to 8 servers, for example
1.1.1.1,tls://dns.google,https://1.1.1.1/dns-query,quic://dns.adguard-dns.com.
Nodes older than 0.5.2.0 skip this setting; after mikan update it works by itself.
Your own Clash profile
Section titled “Your own Clash profile”The “How to set it up” switch → Own YAML opens an editor for the whole mihomo config: DNS, fake-ip, TUN, sniffer, groups, rules. “Start from the simple one” copies the current settings as a starting point, and the ready snippets add DNS fake-ip, TUN, sniffer, QUIC blocking, and a group by country or by node.
The panel inserts the user’s servers itself, so don’t write a proxies section. A group picks them up like this:
proxy-groups: - name: VPN type: select include-all-proxies: true # all of the user's servers exclude-filter: "Hysteria" # filters as in mihomo - name: Germany type: url-test Arikan: nodes: [Germany] # nodes by name or id types: [vless, hysteria2] # protocol typesrules: - MATCH,VPN- A group that ends up with no servers for this app gets REJECT.
- After your
MATCH,<group>the panel addsMATCH,REJECT, and before your rules it puts direct routes to the addresses of the panel and nodes. - On save the panel checks the YAML, the group names and the references to them. The size limit is 512 KB. If the profile later fails to build, the app gets the built-in one.
- While your own YAML is on, the simple-mode settings don’t reach Clash apps. Stash and non-mihomo apps always get the simple profile.
“Back to the simple one” turns your own profile off.
Custom rules
Section titled “Custom rules”Settings → Clash rules: one rule per line, TYPE,VALUE,TARGET[,no-resolve], lines with # are comments. Rules go before the routing mode in every Clash profile, while the addresses of the panel and nodes still go direct.
DOMAIN-SUFFIX,example.ru,DIRECTDOMAIN-SUFFIX,openai.com,PROXYGEOSITE,category-ads-all,REJECTPROCESS-NAME,Telegram.exe,PROXYIP-CIDR,192.168.0.0/16,DIRECT,no-resolve- Types: DOMAIN, DOMAIN-SUFFIX, DOMAIN-KEYWORD, GEOSITE, GEOIP, IP-CIDR, IP-CIDR6, IP-SUFFIX, SRC-IP-CIDR, DST-PORT, SRC-PORT, NETWORK, PROCESS-NAME, PROCESS-PATH. DOMAIN-REGEX, IP-ASN, SRC-GEOIP and DOMAIN-WILDCARD are received only by apps with a recent core.
- Targets: DIRECT, REJECT, REJECT-DROP, PROXY (the main group), the name of the main group or of the auto-select group.
- Every line is checked on save, and an error names the line number, so a typo won’t break clients’ profiles. Up to 500 rules.
The example buttons add common rules in one click.
Torrent blocking
Section titled “Torrent blocking”On the same tab: Block torrents. Nodes look at the first bytes of a connection and recognize the BitTorrent handshake, DHT, uTP and trackers. Encrypted BitTorrent may slip through.
On a catch: only drop the connection, or ban the user for a chosen time. The ban applies to the user, not the IP, and takes effect on all nodes at once. A single tracker request bans nobody; it takes three within ten minutes, because a web page can make a browser send such a request.
In the user’s card you can lift a ban or turn on “Do not check for torrents”. Those caught are listed under “Caught”, and a “Torrent caught” notification arrives in Telegram.
