Skip to content

CLI and environment variables ​

Main-program flags ​

FlagEnvironment variableDescription
-d <dir>CLASH_HOME_DIRConfiguration and data home directory
-f <file>CLASH_CONFIG_FILEConfiguration file; - means stdin
--config <base64>CLASH_CONFIG_STRINGBase64-encoded YAML
--age-secret-key <key>CLASH_AGE_SECRET_KEYAge decryption secret key
--ext-ui <dir>CLASH_OVERRIDE_EXTERNAL_UI_DIROverride the external UI directory
--ext-ctl <addr>CLASH_OVERRIDE_EXTERNAL_CONTROLLEROverride the HTTP Controller address
--ext-ctl-tls <addr>CLASH_OVERRIDE_EXTERNAL_CONTROLLER_TLSOverride the HTTPS Controller address
--ext-ctl-unix <path>CLASH_OVERRIDE_EXTERNAL_CONTROLLER_UNIXOverride the Unix socket
--ext-ctl-pipe <path>CLASH_OVERRIDE_EXTERNAL_CONTROLLER_PIPEOverride the Windows named pipe
--ext-ctl-routing-mark <n>CLASH_OVERRIDE_EXTERNAL_CONTROLLER_ROUTING_MARKLinux Controller socket mark
--secret <secret>CLASH_OVERRIDE_SECRETOverride the ordinary Controller secret
--post-up <command>CLASH_POST_UPRun a shell command after the runtime starts
--post-down <command>CLASH_POST_DOWNRun a shell command during shutdown
-m—Enable geodata mode
-t—Validate the configuration and exit
-v—Print version, platform, Go, build time, and tags

Shell commands

--post-up and --post-down run through the system shell. Do not let an API, user input, or an untrusted configuration source control these values.

Configuration source examples ​

sh
# Default <home>/config.yaml
aster-core

# Explicit home and file
aster-core -d /etc/mihomo -f /etc/mihomo/config.yaml

# stdin
aster-core -d /etc/mihomo -f -

# Base64
aster-core --config "$(base64 -w0 config.yaml)"

Generate credentials and keys ​

UUID ​

sh
aster-core generate uuid

REALITY X25519 ​

sh
aster-core generate reality-keypair

Prints PrivateKey and PublicKey. The server uses the private key; the client uses the public key.

WireGuard ​

sh
aster-core generate wg-keypair

ECH ​

sh
aster-core generate ech-keypair example.com

VLESS Encryption ​

sh
aster-core generate vless-mlkem768
aster-core generate vless-x25519

You can pass an existing seed/private key. The command also prints suggested server and client settings.

Sudoku ​

sh
aster-core generate sudoku-keypair

Age configuration encryption ​

sh
# X25519 identity
aster-core age keygen

# ML-KEM-768 + X25519 hybrid identity
aster-core age keygen-pq

# Convert a secret key to a public recipient
aster-core age convert <secret-key>

# Encrypt and decrypt; source/target may be - for stdio
aster-core age encrypt <public-key> <source> <target>
aster-core age decrypt <secret-key> <source> <target>

Rule-set conversion ​

sh
aster-core convert-ruleset <behavior> <format> <source> <target>

This tool converts rule-provider data among supported formats such as text/YAML/MRS. behavior must match a provider behavior such as domain, ipcidr, or classical.

Advanced environment variables ​

VariablePurpose
XDG_CONFIG_HOMEConfiguration root used when the default Mihomo directory does not exist
SAFE_PATHSExtra allowed file roots, using the OS path-list separator
SKIP_SAFE_PATH_CHECKDisable safe-path checks entirely
DISABLE_EMBED_CADo not use the embedded CA bundle
DISABLE_SYSTEM_CADo not load system CAs
DISABLE_SYSTEM_HOSTSDo not query system hosts
DISABLE_LOOPBACK_DETECTORDisable the loopback connection detector
FORCE_ANETForce the anet path
HOST_PROCLinux procfs root, default /proc
SKIP_SYSTEM_IPV6_CHECKSkip system IPv6 capability detection
DISABLE_NFTABLESDo not use nftables for TUN auto-redirect
DISABLE_OVERRIDE_ANDROID_VPNDisable Android VPN interface override
LISTEN_NAMEDPIPE_SDDLWindows named-pipe SDDL
QUIC_GO_DISABLE_GSODisable quic-go GSO
QUIC_GO_DISABLE_ECNDisable quic-go ECN

Signals and shutdown ​

SignalBehavior
SIGHUPReapply configuration; file mode rereads the file
SIGINTGraceful shutdown
SIGTERMGraceful shutdown

A graceful shutdown runs runtime shutdown, closes listeners, cleans automatic iptables, saves fake-IP, and flushes Aster traffic.