LinuxCommandLibrary

clash

Proxy network traffic based on rules

TLDR

Specify a configuration [d]irectory

$ clash -d [path/to/directory]
copy


Specify a configuration [f]ile
$ clash -f [path/to/configuration_file]
copy

SYNOPSIS

clash [OPTIONS] [config.yaml]

PARAMETERS

-d <string>
    Config root directory (default: ".")

-f <string>
    Path to config file (default: "")

-p <string>
    HTTP proxy/API listen address (default: ":9090")

-test
    Test config validity and exit

-u <string>
    Run as specific user

-v <int>
    Log level: 0=panic,1=fatal,2=error,3=warn,4=info,5=debug (default 1)

-ver
    Display version and exit

DESCRIPTION

Clash is a modern, open-source rule-based tunnel written in Go, providing fine-grained control over internet traffic routing.

It supports protocols like Shadowsocks, VMess, Trojan, Hysteria, and more, with features such as proxy groups, URL-test/health-checks, load balancing, and fallback policies.

On Linux, Clash excels in TUN/TPROXY modes for transparent system-wide proxying, DNS hijacking, and process-based routing. It includes a RESTful API server, web dashboard (external UI), and logging.

Configuration uses human-readable YAML files defining proxies, rules (domain, geoip, ipcidr, process, etc.), and modes (global, rule, direct).

Popular for censorship circumvention, privacy, and geoblocking bypass, Clash is lightweight, performant, and extensible via plugins in forks like Clash Premium/Meta.

Usage involves downloading the binary, editing config.yaml, and running as user/service. Supports auto-update and speed tests.

CAVEATS

Not in standard repos; download from GitHub. TUN mode needs root/CAP_NET_ADMIN. Misconfigs risk traffic leaks. Use trusted proxy nodes.

INSTALLATION

Download Linux amd64/arm binary from https://github.com/Dreamacro/clash/releases. chmod +x clash; create config.yaml.

CONFIG EXAMPLE

Minimal config.yaml:
port: 7890
socks-port: 7891
allow-lan: true
mode: rule
proxies: [...]
rules: [...]

HISTORY

Released in 2019 by Dreamacro as Go-based proxy successor to Python tools. Gained traction with TUN/redirect support (2020), API/dashboard. Forks: Clash Premium (native TUN), mihomo/Clash.Meta (2023+ enhancements).

SEE ALSO

iptables(8), nft(8), systemd(1)

Copied to clipboard