Skip to content
Edit this page

Configuration Overview

ClashRS uses a single YAML configuration file (default config.yaml inside the working directory -d). Before deserialization, ClashRS expands standard YAML anchors and merge keys (<<: *anchor).

By default, unknown YAML keys are silently ignored so profiles authored for Mihomo or Clash can load without modification. Pass --strict-config on the CLI to reject unknown keys at any nesting depth.

Top-Level Sections

Section Description Reference
General & Controller Ports, binding, mode, logging, IPv6, GeoData, hosts, profile, experimental, controller/UI This page
dns Built-in DNS resolver, Fake-IP, fallback filters, local DNS listeners DNS
tun Cross-platform TUN transparent proxy TUN
listeners / tunnels / inbound-providers Multi-protocol inbound listeners & fixed port forwarding Inbounds
proxies Outbound proxy definitions Outbounds
proxy-groups Selection, URL-test, fallback, load-balance, relay, and smart groups Proxy Groups
rules Traffic routing rules Routing Rules
proxy-providers / rule-providers Remote, file, and inline providers Providers

General Options

Inbound Shorthand & Network

Key Alias Type Default Description
port http_port Port None HTTP proxy port (mapped to listener HTTP-IN).
socks-port — Port None SOCKS5 proxy port with UDP enabled (mapped to SOCKS-IN).
mixed-port — Port None Combined HTTP + SOCKS5 port with UDP enabled (mapped to MIXED-IN).
redir-port — Port None Linux TCP Redirect port (redir feature; mapped to REDIR-IN).
tproxy-port — Port None Linux/Android TProxy port (tproxy feature; mapped to TPROXY-IN).
authentication — list[string] [] Credentials for http, socks, and mixed inbounds in "username:password" format (split on the first :; missing : yields an empty password).
allow-lan — bool false Allow connections from non-local addresses. When false, inbound listeners require peer_addr.ip() == local_addr.ip().
bind-address — BindAddress 0.0.0.0 (:: when left default and ipv6: true) Bind IP for top-level shorthand ports. Accepts *, localhost, ::, [::], or any IP literal.
mode — rule | global | direct rule Routing mode (also accepts capitalized Rule, Global, Direct).
log-level — trace | debug | info | warning (warn) | error | silent (off) info Runtime log verbosity. Overridden if RUST_LOG is set.
unified-delay — bool false Measure latency on an already established HTTP connection to exclude handshake overhead.
ipv6 — bool false Global IPv6 switch. Upgrades default bind-address to ::, gates DNS IPv6 (config.ipv6 && dns.ipv6), and enables default IPv6 gateway-v6 in Mihomo TUN mode.
interface interface-name string None Default physical outbound interface name or IP address (used when TUN is enabled).
routing-mark — SocketMark None Outbound socket SO_MARK on Linux (and Android with tproxy feature). Inherited by tun.so-mark (when unset) and DNS clients.

External Controller & Dashboard

Key Alias Type Default Description
external-controller — string None REST API TCP listen address (e.g. 127.0.0.1:9090; :9090 expands to 127.0.0.1:9090). Non-loopback bindings require both non-empty secret and CORS origins.
external-controller-ipc external-controller-unix (Unix), external-controller-pipe (Windows) string None Unix Domain Socket path or Windows Named Pipe (\\.\pipe\clash-rs). Can run alongside TCP. Overridden by --controller-ipc.
external-ui — string None Local directory (relative to -d) served at /ui/. Falls back to the embedded dashboard if empty/missing.
external-ui-url — string None Archive URL (.zip/.tgz) downloaded into external-ui when empty. Supports #force=true and #_clash_outbound=<name>.
secret — string None Bearer token for TCP API authentication (Authorization: Bearer <secret> or ?token=<secret> for WebSockets). Not applied to IPC.
external-controller-cors — object None CORS configuration with allow-origins: list[string] and allow-private-network: bool (default true).
cors-allow-origins — list[string] None Legacy fallback for external-controller-cors.allow-origins.
external-controller: 0.0.0.0:9090
secret: "strong-random-secret"
external-controller-cors:
  allow-origins:
    - "https://metacubex.github.io"
    - "http://127.0.0.1:9090"
  allow-private-network: true

GeoData & Static Hosts

GeoData files are resolved relative to -d (subject to Safe Paths) and are only loaded/downloaded when their path is configured (or automatically defaulted in --compatibility mode).

Key Type Default Description
mmdb string None (Country.mmdb in --compatibility) Country GeoIP MMDB path. Required by GEOIP rules and dns.fallback-filter.geoip.
mmdb-download-url string https://github.com/Loyalsoldier/geoip/releases/latest/download/Country.mmdb Download URL used when mmdb is missing or refreshed via POST /configs/geo.
asn-mmdb string None ASN MMDB database path.
asn-mmdb-download-url string https://git.io/GeoLite2-ASN.mmdb Download URL for asn-mmdb.
geosite string None (geosite.dat in --compatibility) GeoSite database path. Required by GEOSITE rules.
geosite-download-url string or list[string] Loyalsoldier v2ray-rules-dat jsDelivr + GitHub mirror list Single URL or ordered mirror list (non-empty).
hosts map[domain -> IP] {} Static domain-to-IP mappings used when dns.use-hosts: true. localhost -> 127.0.0.1 is always built in.

profile

Controls persistent local caches stored inside -d:

Key Type Default Description
store-selected bool true Persist select proxy group choices to cache.db (clash-rs-cache.db in --compatibility mode).
store-fake-ip bool false Persist Fake-IP mappings to disk. When false, uses an in-memory store (capacity 1,000).
store-smart-stats bool true Persist smart proxy group scoring statistics every 30 seconds.
profile:
  store-selected: true
  store-fake-ip: false
  store-smart-stats: true

experimental

Optional buffer and runtime tuning knobs:

Key Type Default Description
tcp-buffer-size usize (bytes) 65536 (64 KiB) Bidirectional TCP relay copy buffer size.
anytls-duplex-buffer-size usize (bytes) 16384 (16 KiB) Internal duplex pipe buffer size for AnyTLS.
anytls-relay-buffer-size usize (bytes) 4096 (4 KiB) Read buffer size for AnyTLS relay loops.
closed-flows-cap usize 50 Ring-buffer capacity for closed flow records returned by /flows.
ignore-resolve-fail bool false Accepted for config compatibility (currently unused at runtime).

Unsupported Mihomo / Clash Top-Level Keys

The following keys from other Clash forks are not defined in ClashRS (silently ignored normally; rejected under --strict-config):

  • geodata-mode, geodata-loader, geox-url
  • fwmark (use routing-mark instead)
  • skip-auth-prefixes, lan-allowed-ips, lan-disallowed-ips
  • sniffer, ntp, sub-rules, script, find-process-mode, global-client-fingerprint, ebpf