Fields change between versions. Before editing a config by hand, read the official docs for your version: https://sing-box.sagernet.org/
The skeleton of a config
A sing-box config is one JSON object. The most important top-level fields:
| Field | Role |
|---|---|
inbounds | Entry points: where the program accepts traffic (local ports, a TUN adapter) |
outbounds | Exits: where traffic finally goes (direct, proxy nodes, groups) |
route | Routing: rules decide which exit a request uses |
dns | DNS: which servers resolve names, and the resolution strategy |
log | Log level and output |
Understanding the data flow
A request enters an inbound, the rules in route are matched in order, and the match points to an outbound. If nothing matches, the default exit is used.
How rules work
Rules can match on domain, domain suffix, IP range, process name, rule sets and more. Newer versions recommend referencing external rule lists through rule-set instead of the older geosite/geoip files.
DNS and routing work together
DNS resolution itself must go through routing, or resolution requests can take the wrong exit. A common approach is to assign different DNS servers to different domains. When this breaks, the symptom is usually "connected, but some sites will not load".
Advice for beginners
- You do not have to hand-write configs at first. Import a subscription in a graphical client.
- To learn, export the config the client generates and read it against the skeleton above.
- Back up before editing, and change one thing at a time.
- For errors caused by version differences, look up the migration notes for that version.