Configuration: make it run, then tune it
The file below starts as-is. Once these seven keys make sense, everything else is addition and subtraction.
Minimal working config
mixed-port: 7890
allow-lan: false
mode: rule
log-level: info
external-controller: 127.0.0.1:9090
dns:
enable: true
nameserver:
- 223.5.5.5
- 119.29.29.29
proxies:
- name: node-1
type: vless
server: example.com
port: 443
proxy-groups:
- name: PROXY
type: select
proxies: [node-1]
rules:
- GEOIP,CN,DIRECT
- MATCH,PROXYIndentation is syntax
YAML accepts spaces, never tabs. Convert tabs to two spaces or you get yaml: line N: found character that cannot start any token.
Seven keys you will actually touch
| Key | Effect | Common mistake |
|---|---|---|
mixed-port | Shared HTTP and SOCKS5 port, default 7890 | Fighting another proxy tool for the port |
allow-lan | Whether LAN devices may connect | On without a secret is an open proxy |
mode | rule, global or direct | Writing rules crashes on start |
external-controller | Control API the client reads state from | Binding 0.0.0.0 exposes it |
dns.enable | Whether the kernel owns DNS | Enabled with an empty nameserver breaks resolution |
tun.enable | Virtual adapter capturing all traffic | Enabled without permission: operation not permitted |
rules | Routing rules, first match wins | No final MATCH: unmatched traffic goes direct |
Four group types cover most cases
- select
- Manual choice. Use it for decisions only you can make, like "streaming" or "work"
- url-test
- Picks the fastest by latency, re-tested every
intervalseconds - fallback
- Uses the first healthy node in order; suits a primary and a backup line
- load-balance
- Spreads one domain across nodes. Good for downloads, bad for anything needing a stable exit IP
proxy-groups:
- name: AUTO
type: url-test
url: https://www.gstatic.com/generate_204
interval: 300
tolerance: 50
proxies: [node-1, node-2]Order decides the outcome
Rules evaluate top to bottom and stop at the first match, so exceptions belong above the catch-all: specific domains first, then GEOIP,CN,DIRECT, then MATCH,PROXY. Put MATCH first and nothing below it ever runs.
DOMAIN-SUFFIX,example.com,PROXY: the workhorse.DOMAIN-KEYWORD,google,PROXY: broad and easy to over-match; use sparingly.IP-CIDR,10.0.0.0/8,DIRECT,no-resolve: LAN bypass without triggering DNS.GEOIP,CN,DIRECT: needs the GeoIP data files.
Validate before restarting
mihomo -t -f ./config.yaml
# configuration file ./config.yaml test is successfulValidate, then restart the service or hit reload in the client. Skipping this turns every typo into a log-reading session.
Questions
- Where does the config live?
- Desktop clients manage their own directory. A standalone kernel reads
config.yamlfrom the working directory you pass with-d. - I changed the port and nothing works.
- You probably changed it in one place only. The kernel listens on the new port while the system proxy still points at the old one, so everything times out.
- Does TOML or JSON work?
- No. mihomo parses YAML. JSON is structurally compatible but the parser is YAML; do not mix them.