English
route — routing
The section decides where each connection accepted by an inbound goes: to which outbound or group, whether to refuse it, or whether to hand it to the built-in DNS.
yaml
groups:
main:
members: [proxy-de, direct]
rule_sets:
ads:
remote: https://example.org/ads.srs
route:
rules:
- do: sniff
- match:
protocol: dns
to: hijack-dns
- match:
rule_set: ads
to: block
- match:
domain_suffix: [lan, local]
to:
outbound: direct
final:
group: mainOrder of processing: the rules are checked from top to bottom; a rule with do performs an intermediate action and the check goes on, a rule with to ends the route. If no to matched, final applies.
- Rules — how a rule is built:
match,do,to, the logicany,all,not. - Conditions — everything that can be written in
match. - Actions —
toanddo: outbounds, refusal, sniffing, resolving, connection parameters. - Rule-sets — sets of conditions that
rule_setrefers to.
final
A required field: what to do with a connection that no rule ended. It takes the same values as a rule's to:
final | Meaning |
|---|---|
outbound: <name> | To an outbound |
group: <name> | To a group |
block | Refuse |
block: drop | Refuse silently |
hijack-dns | Answer with the built-in DNS |
bypass | Past the proxy; what reaches the process goes directly |
The outbound or group from final is also the default outbound: everything that connects without a route goes through it, for example downloading rule-sets without via. final: block refuses such connections too. For final: bypass the loader adds a plain direct outbound named bypass (bypass-1, … if the name is taken) and makes it the default outbound. The other values work as a last rule without conditions; the default outbound is then the first outbound in outbounds.
Other fields
| Field | Meaning |
|---|---|
find_process | Determine the owning process of every connection, even if no rule needs it (visible in the dashboard). The process_*, user, user_id conditions look up the process without this flag too |
find_neighbor | The same for the source's MAC address and host name (the neighbor table and DHCP leases), which the source_mac_address and source_hostname conditions need |
dhcp_lease_files | DHCP lease files for find_neighbor and for the local upstream with neighbor_domain; by default /tmp/dhcp.leases, /var/lib/dhcp/dhcpd.leases, /var/lib/dhcpd/dhcpd.leases, /var/lib/kea/kea-leases4.csv, /var/lib/kea/kea-leases6.csv (those that exist) |
auto_detect_interface | Watch the default interface and bind outgoing sockets to it |
tcp_half_close_timeout | A duration, 60s by default. When one side of a TCP connection has finished sending (FIN), the other direction keeps being forwarded, but the connection is closed if nothing goes over it for longer than this. Long silent answers to a half-closed request (ssh host cmd < /dev/null) need a larger value, for example 1h |
dial | Default socket parameters, see below |
default_http_client | The name of a client from http_clients through which rule-sets without a client of their own are downloaded |
override_android_vpn | Accepted for compatibility; has no effect on Linux, check warns |
yaml
route:
final:
outbound: direct
auto_detect_interface: true
dial:
fwmark: 0xff
find_process: truedial
How all sockets of the kernel dial by default: outbounds, DNS upstreams, rule-set downloads.
| Field | Meaning |
|---|---|
interface | The interface to bind to |
fwmark | The mark for sockets without a mark of their own |
interfaces | A block {strategy, type, fallback} like dial.interfaces; the strategy requires auto_detect_interface or dial.interface |
fallback_delay | As in the dial block |
tcp.congestion | The congestion control algorithm for sockets without their own (dial.tcp.congestion) |
Priority: the outbound's own dial, then outbounds.defaults.dial, then route.dial.
The sing-box fields rule_set, default_domain_resolver, geoip and geosite are a load error with a hint, see Migration.
Checking a route
ours explain shows which rules would match for a given connection (Command line); in the dashboard the same is the route check.