Back δΈ­ζ–‡
Featured image of post From Subscription URL to Rule-Based Routing: How Clash Verge Works

From Subscription URL to Rule-Based Routing: How Clash Verge Works

A 3-minute walkthrough connecting proxy providers, subscriptions, routing rules, and Fake-IP through a single web request.

πŸ€– Note: This article was drafted with AI assistance and carefully reviewed and edited by the author.

Preface

When using Clash, many people wonder: how do the proxy provider, subscription URL, and desktop client actually fit together? And when something breaks, what can you check besides switching nodes?

This guide strips away noisy parameters and walks through the core architecture in 4 diagrams and a 3-minute read.


1. Roles at a Glance: Who Does What?

The diagram below separates the Control Plane from the Data Plane:

flowchart TD
    subgraph ControlPlane ["Control Plane (Involved when updating config)"]
        A["Provider Panel / Subscription Service"] -->|1. Provides URL| B["Subscription URL"]
        B -->|2. Downloads config| C["YAML Config File"]
        C -->|3. Loads rules| D["Clash Verge Rev UI"]
    end

    subgraph DataPlane ["Data Plane (Runs on every web request)"]
        E["Browser / App"] -->|4. Sends request| F["Mihomo Core"]
        D -.->|Configures| F
        F -->|5. Rule routing| G{"Choose Outbound"}
        G -->|Direct| H["Target Website"]
        G -->|Proxy| I["Proxy Node"] --> H
        G -->|Block| J["REJECT"]
    end
  • Provider: The server / route supplier;
  • Node: A concrete exit server;
  • Subscription URL: The download address for route metadata (only used when updating config β€” normal web traffic never passes through it);
  • Clash Verge Rev: The desktop GUI controller;
  • Mihomo: The actual core engine that inspects domains, matches rules, and forwards traffic.

2. Main Pipeline: The 4-Step Journey of a Web Request

When you open a website (such as video.example) in your browser, local traffic passes through 4 steps:

flowchart TD
    A["Browser Request"] -->|Step 1| B["Traffic Capture"]
    B -->|Step 2| C["Fake-IP Domain Resolution"]
    C -->|Step 3| D["Rule Table Matching"]
    D -->|Step 4| E["Proxy Group Selection"]
    E --> F["Establish Connection"]

Step 1: Traffic Capture (System Proxy vs. TUN)

graph TD
    App1["Browser / Standard Apps"] -->|Uses proxy port| Proxy["System Proxy 7890"] --> Mihomo
    App2["Terminal / Games / Legacy Apps"] -->|Ignores system proxy| NIC["Physical NIC"]
    
    subgraph TUNMode ["TUN Virtual NIC Mode (Force Capture)"]
        NIC2["Virtual NIC"] --> Mihomo["Mihomo Core"]
    end
    App2 -.->|With TUN enabled| NIC2
  • System Proxy: Tells the browser to send traffic to the core. (Some CLI tools and games ignore this setting.)
  • TUN Mode: Creates a virtual network interface to forcibly capture all network traffic, solving apps that bypass the system proxy.

Step 2: Fake-IP Domain Recognition

Mihomo’s Fake-IP mechanism solves traditional DNS poisoning and slow DNS lookups:

sequenceDiagram
    autonumber
    participant Browser
    participant MihomoCore as Mihomo Core
    participant Outbound as Proxy Node / Target

    Browser->>MihomoCore: Query IP for video.example
    MihomoCore-->>Browser: Return fake IP (e.g. 198.18.0.25)
    Note over MihomoCore: Store mapping: 198.18.0.25 <-> video.example
    Browser->>MihomoCore: Connect to 198.18.0.25
    Note over MihomoCore: Reverse-lookup mapping to get video.example
    MihomoCore->>Outbound: Route by domain rules and open real connection

⚠️ Note: 198.18.x.x is a local placeholder address, not the real IP of the target server.


Step 3: Rule Matching & Proxy Group Selection

Rules are evaluated top-to-bottom; the first matching rule wins and stops:

flowchart TD
    Req["Captured Domain / IP"] --> R1{"1. Matches DIRECT rule?"}
    R1 -->|Yes| Direct["DIRECT"]
    R1 -->|No| R2{"2. Matches REJECT rule?"}
    R2 -->|Yes| Reject["REJECT"]
    R2 -->|No| R3{"3. Matches Proxy rule?"}
    R3 -->|Yes| Group["Hand off to Proxy Group"]
    R3 -->|No| Match["MATCH Fallback Group"]
    
    Group --> Select{"Proxy Group Type"}
    Match --> Select
    
    Select -->|Manual Select| Node1["User-chosen node"]
    Select -->|Auto URL-Test| Node2["Lowest-latency node"]
    Select -->|Fallback| Node3["Primary first, switch on failure"]

3. Troubleshooting: Diagnose 80% of Issues in One Table

When connectivity fails, trace backwards along the pipeline:

SymptomCause & Fix
Browser works, CLI/games don’tTraffic isn’t entering the core β€” enable TUN Mode.
All nodes time out / show redCheck your local network, whether the subscription expired, or if the test URL is unreachable.
A specific site takes the wrong routeCheck rule ordering or update your rule-sets.
Seeing 198.18.x.x IPsCompletely normal! That’s a Fake-IP placeholder.
Local config edits reset after refreshRemote subscriptions overwrite local changes β€” use Verge’s Merge / Script Override feature.

Summary

Clash isn’t mysterious β€” its core logic is simply a clean four-stage pipeline:

[Capture Traffic] ──> [Identify Domain (Fake-IP)] ──> [Match Rules] ──> [Pick Node (Proxy Group)]