2023-12-01 13:24:18 +08:00
|
|
|
|
---
|
2025-01-29 13:13:33 +08:00
|
|
|
|
icon: material/alert-decagram
|
2023-12-01 13:24:18 +08:00
|
|
|
|
---
|
|
|
|
|
|
|
2026-03-03 20:59:13 +08:00
|
|
|
|
!!! quote "sing-box 1.14.0 中的更改"
|
|
|
|
|
|
|
|
|
|
|
|
:material-plus: [source_mac_address](#source_mac_address)
|
2026-04-07 20:02:32 +08:00
|
|
|
|
:material-plus: [source_hostname](#source_hostname)
|
|
|
|
|
|
:material-plus: [match_response](#match_response)
|
|
|
|
|
|
:material-delete-clock: [rule_set_ip_cidr_accept_empty](#rule_set_ip_cidr_accept_empty)
|
|
|
|
|
|
:material-plus: [response_rcode](#response_rcode)
|
|
|
|
|
|
:material-plus: [response_answer](#response_answer)
|
|
|
|
|
|
:material-plus: [response_ns](#response_ns)
|
2026-04-10 11:54:47 +08:00
|
|
|
|
:material-plus: [response_extra](#response_extra)
|
2026-04-10 15:02:55 +08:00
|
|
|
|
:material-plus: [package_name_regex](#package_name_regex)
|
|
|
|
|
|
:material-alert: [ip_version](#ip_version)
|
|
|
|
|
|
:material-alert: [query_type](#query_type)
|
2026-03-03 20:59:13 +08:00
|
|
|
|
|
2025-08-14 11:04:04 +08:00
|
|
|
|
!!! quote "sing-box 1.13.0 中的更改"
|
|
|
|
|
|
|
|
|
|
|
|
:material-plus: [interface_address](#interface_address)
|
|
|
|
|
|
:material-plus: [network_interface_address](#network_interface_address)
|
|
|
|
|
|
:material-plus: [default_interface_address](#default_interface_address)
|
|
|
|
|
|
|
2025-01-29 13:13:33 +08:00
|
|
|
|
!!! quote "sing-box 1.12.0 中的更改"
|
|
|
|
|
|
|
2025-03-06 14:02:16 +08:00
|
|
|
|
:material-plus: [ip_accept_any](#ip_accept_any)
|
2025-01-29 13:13:33 +08:00
|
|
|
|
:material-delete-clock: [outbound](#outbound)
|
|
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
!!! quote "sing-box 1.11.0 中的更改"
|
|
|
|
|
|
|
|
|
|
|
|
:material-plus: [action](#action)
|
|
|
|
|
|
:material-alert: [server](#server)
|
|
|
|
|
|
:material-alert: [disable_cache](#disable_cache)
|
|
|
|
|
|
:material-alert: [rewrite_ttl](#rewrite_ttl)
|
|
|
|
|
|
:material-alert: [client_subnet](#client_subnet)
|
|
|
|
|
|
:material-plus: [network_type](#network_type)
|
|
|
|
|
|
:material-plus: [network_is_expensive](#network_is_expensive)
|
|
|
|
|
|
:material-plus: [network_is_constrained](#network_is_constrained)
|
|
|
|
|
|
|
2024-06-24 09:41:00 +08:00
|
|
|
|
!!! quote "sing-box 1.10.0 中的更改"
|
|
|
|
|
|
|
|
|
|
|
|
:material-delete-clock: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source)
|
|
|
|
|
|
:material-plus: [rule_set_ip_cidr_match_source](#rule_set_ip_cidr_match_source)
|
2024-09-15 11:42:57 +08:00
|
|
|
|
:material-plus: [rule_set_ip_cidr_accept_empty](#rule_set_ip_cidr_accept_empty)
|
|
|
|
|
|
:material-plus: [process_path_regex](#process_path_regex)
|
2024-06-24 09:41:00 +08:00
|
|
|
|
|
2024-02-03 17:45:27 +08:00
|
|
|
|
!!! quote "sing-box 1.9.0 中的更改"
|
|
|
|
|
|
|
|
|
|
|
|
:material-plus: [geoip](#geoip)
|
|
|
|
|
|
:material-plus: [ip_cidr](#ip_cidr)
|
2024-02-09 18:37:25 +08:00
|
|
|
|
:material-plus: [ip_is_private](#ip_is_private)
|
2024-11-06 19:02:55 +08:00
|
|
|
|
:material-plus: [client_subnet](#client_subnet)
|
2024-02-21 14:27:55 +08:00
|
|
|
|
:material-plus: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source)
|
2024-02-03 17:45:27 +08:00
|
|
|
|
|
2023-12-01 13:24:18 +08:00
|
|
|
|
!!! quote "sing-box 1.8.0 中的更改"
|
|
|
|
|
|
|
|
|
|
|
|
:material-plus: [rule_set](#rule_set)
|
|
|
|
|
|
:material-plus: [source_ip_is_private](#source_ip_is_private)
|
|
|
|
|
|
:material-delete-clock: [geoip](#geoip)
|
|
|
|
|
|
:material-delete-clock: [geosite](#geosite)
|
|
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
### 结构
|
|
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"dns": {
|
|
|
|
|
|
"rules": [
|
|
|
|
|
|
{
|
|
|
|
|
|
"inbound": [
|
|
|
|
|
|
"mixed-in"
|
|
|
|
|
|
],
|
|
|
|
|
|
"ip_version": 6,
|
2023-02-08 16:18:40 +08:00
|
|
|
|
"query_type": [
|
|
|
|
|
|
"A",
|
|
|
|
|
|
"HTTPS",
|
|
|
|
|
|
32768
|
|
|
|
|
|
],
|
2022-08-24 16:23:21 +08:00
|
|
|
|
"network": "tcp",
|
|
|
|
|
|
"auth_user": [
|
|
|
|
|
|
"usera",
|
|
|
|
|
|
"userb"
|
|
|
|
|
|
],
|
|
|
|
|
|
"protocol": [
|
|
|
|
|
|
"tls",
|
|
|
|
|
|
"http",
|
|
|
|
|
|
"quic"
|
|
|
|
|
|
],
|
|
|
|
|
|
"domain": [
|
|
|
|
|
|
"test.com"
|
|
|
|
|
|
],
|
|
|
|
|
|
"domain_suffix": [
|
|
|
|
|
|
".cn"
|
|
|
|
|
|
],
|
|
|
|
|
|
"domain_keyword": [
|
|
|
|
|
|
"test"
|
|
|
|
|
|
],
|
|
|
|
|
|
"domain_regex": [
|
|
|
|
|
|
"^stun\\..+"
|
|
|
|
|
|
],
|
|
|
|
|
|
"source_ip_cidr": [
|
2024-02-03 17:45:27 +08:00
|
|
|
|
"10.0.0.0/24",
|
|
|
|
|
|
"192.168.0.1"
|
2022-08-24 16:23:21 +08:00
|
|
|
|
],
|
2023-12-01 13:24:18 +08:00
|
|
|
|
"source_ip_is_private": false,
|
2022-08-24 16:23:21 +08:00
|
|
|
|
"source_port": [
|
|
|
|
|
|
12345
|
|
|
|
|
|
],
|
|
|
|
|
|
"source_port_range": [
|
|
|
|
|
|
"1000:2000",
|
|
|
|
|
|
":3000",
|
|
|
|
|
|
"4000:"
|
|
|
|
|
|
],
|
|
|
|
|
|
"port": [
|
|
|
|
|
|
80,
|
|
|
|
|
|
443
|
|
|
|
|
|
],
|
|
|
|
|
|
"port_range": [
|
|
|
|
|
|
"1000:2000",
|
|
|
|
|
|
":3000",
|
|
|
|
|
|
"4000:"
|
|
|
|
|
|
],
|
|
|
|
|
|
"process_name": [
|
|
|
|
|
|
"curl"
|
|
|
|
|
|
],
|
2022-08-31 14:33:52 +08:00
|
|
|
|
"process_path": [
|
|
|
|
|
|
"/usr/bin/curl"
|
|
|
|
|
|
],
|
2024-09-15 11:42:57 +08:00
|
|
|
|
"process_path_regex": [
|
|
|
|
|
|
"^/usr/bin/.+"
|
|
|
|
|
|
],
|
2022-08-24 16:23:21 +08:00
|
|
|
|
"package_name": [
|
|
|
|
|
|
"com.termux"
|
|
|
|
|
|
],
|
2026-04-10 11:54:47 +08:00
|
|
|
|
"package_name_regex": [
|
|
|
|
|
|
"^com\\.termux.*"
|
|
|
|
|
|
],
|
2022-08-24 16:23:21 +08:00
|
|
|
|
"user": [
|
|
|
|
|
|
"sekai"
|
|
|
|
|
|
],
|
|
|
|
|
|
"user_id": [
|
|
|
|
|
|
1000
|
|
|
|
|
|
],
|
2022-09-10 22:42:20 +08:00
|
|
|
|
"clash_mode": "direct",
|
2024-11-11 16:30:25 +08:00
|
|
|
|
"network_type": [
|
|
|
|
|
|
"wifi"
|
|
|
|
|
|
],
|
|
|
|
|
|
"network_is_expensive": false,
|
|
|
|
|
|
"network_is_constrained": false,
|
2025-08-14 11:04:04 +08:00
|
|
|
|
"interface_address": {
|
|
|
|
|
|
"en0": [
|
|
|
|
|
|
"2000::/3"
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
"network_interface_address": {
|
|
|
|
|
|
"wifi": [
|
|
|
|
|
|
"2000::/3"
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
"default_interface_address": [
|
|
|
|
|
|
"2000::/3"
|
|
|
|
|
|
],
|
2026-03-03 20:59:13 +08:00
|
|
|
|
"source_mac_address": [
|
|
|
|
|
|
"00:11:22:33:44:55"
|
|
|
|
|
|
],
|
|
|
|
|
|
"source_hostname": [
|
|
|
|
|
|
"my-device"
|
|
|
|
|
|
],
|
2023-11-09 17:04:08 +08:00
|
|
|
|
"wifi_ssid": [
|
|
|
|
|
|
"My WIFI"
|
|
|
|
|
|
],
|
|
|
|
|
|
"wifi_bssid": [
|
|
|
|
|
|
"00:00:00:00:00:00"
|
|
|
|
|
|
],
|
2023-12-01 13:24:18 +08:00
|
|
|
|
"rule_set": [
|
|
|
|
|
|
"geoip-cn",
|
|
|
|
|
|
"geosite-cn"
|
|
|
|
|
|
],
|
2024-06-24 09:41:00 +08:00
|
|
|
|
"rule_set_ip_cidr_match_source": false,
|
2026-04-07 20:02:32 +08:00
|
|
|
|
"match_response": false,
|
|
|
|
|
|
"ip_cidr": [
|
|
|
|
|
|
"10.0.0.0/24",
|
|
|
|
|
|
"192.168.0.1"
|
|
|
|
|
|
],
|
|
|
|
|
|
"ip_is_private": false,
|
2026-04-10 10:15:02 +08:00
|
|
|
|
"ip_accept_any": false,
|
2026-04-07 20:02:32 +08:00
|
|
|
|
"response_rcode": "",
|
|
|
|
|
|
"response_answer": [],
|
|
|
|
|
|
"response_ns": [],
|
|
|
|
|
|
"response_extra": [],
|
2022-08-24 16:23:21 +08:00
|
|
|
|
"invert": false,
|
|
|
|
|
|
"outbound": [
|
|
|
|
|
|
"direct"
|
|
|
|
|
|
],
|
2024-11-11 16:30:25 +08:00
|
|
|
|
"action": "route",
|
2025-03-06 14:02:16 +08:00
|
|
|
|
"server": "local",
|
|
|
|
|
|
|
|
|
|
|
|
// 已弃用
|
2026-04-07 20:02:32 +08:00
|
|
|
|
|
|
|
|
|
|
"rule_set_ip_cidr_accept_empty": false,
|
2025-03-06 14:02:16 +08:00
|
|
|
|
"rule_set_ipcidr_match_source": false,
|
|
|
|
|
|
"geosite": [
|
|
|
|
|
|
"cn"
|
|
|
|
|
|
],
|
|
|
|
|
|
"source_geoip": [
|
|
|
|
|
|
"private"
|
|
|
|
|
|
],
|
|
|
|
|
|
"geoip": [
|
|
|
|
|
|
"cn"
|
|
|
|
|
|
]
|
2022-08-24 16:23:21 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"type": "logical",
|
|
|
|
|
|
"mode": "and",
|
|
|
|
|
|
"rules": [],
|
2024-11-11 16:30:25 +08:00
|
|
|
|
"action": "route",
|
|
|
|
|
|
"server": "local"
|
2022-08-24 16:23:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
!!! note ""
|
|
|
|
|
|
|
|
|
|
|
|
当内容只有一项时,可以忽略 JSON 数组 [] 标签
|
|
|
|
|
|
|
|
|
|
|
|
### 默认字段
|
|
|
|
|
|
|
|
|
|
|
|
!!! note ""
|
|
|
|
|
|
|
|
|
|
|
|
默认规则使用以下匹配逻辑:
|
2026-08-22 14:19:37 +08:00
|
|
|
|
(`domain` || `domain_suffix` || `domain_keyword` || `domain_regex` || `geosite` || `ip_cidr` || `ip_is_private` || `ip_accept_any`) &&
|
2022-09-14 22:03:26 +08:00
|
|
|
|
(`port` || `port_range`) &&
|
2023-12-01 13:24:18 +08:00
|
|
|
|
(`source_geoip` || `source_ip_cidr` || `source_ip_is_private`) &&
|
2022-09-14 22:03:26 +08:00
|
|
|
|
(`source_port` || `source_port_range`) &&
|
|
|
|
|
|
`other fields`
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
2026-03-25 10:32:09 +08:00
|
|
|
|
另外,引用规则集中的每个分支都可视为与外层规则合并,不同分支之间仍保持 OR 语义。
|
2023-12-01 13:24:18 +08:00
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
#### inbound
|
|
|
|
|
|
|
2023-12-14 22:23:52 +08:00
|
|
|
|
[入站](/zh/configuration/inbound/) 标签.
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
|
|
|
|
|
#### ip_version
|
|
|
|
|
|
|
2026-04-10 15:02:55 +08:00
|
|
|
|
!!! quote "sing-box 1.14.0 中的更改"
|
|
|
|
|
|
|
|
|
|
|
|
此字段现在也会在 DNS 规则被未指定具体 DNS 服务器的内部域名解析匹配时生效,
|
|
|
|
|
|
例如未设置 `server` 的 [`resolve`](../../route/rule_action/#resolve) 路由规则动作。
|
|
|
|
|
|
此前只有来自客户端的 DNS 查询才会评估此字段。完整列表参阅
|
|
|
|
|
|
[迁移指南](/zh/migration/#dns-规则中的-ip_version-和-query_type-行为更改)。
|
|
|
|
|
|
|
|
|
|
|
|
在 DNS 规则中设置此字段后,该 DNS 规则在同一 DNS 配置中不能与
|
|
|
|
|
|
旧版地址筛选字段 (DNS 规则)、旧版 DNS 规则动作 `strategy` 选项,
|
|
|
|
|
|
或旧版 `rule_set_ip_cidr_accept_empty` DNS 规则项共存。如需与
|
|
|
|
|
|
基于地址的筛选组合,请使用 [`evaluate`](../rule_action/#evaluate) 动作和
|
|
|
|
|
|
[`match_response`](#match_response)。
|
|
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
4 (A DNS 查询) 或 6 (AAAA DNS 查询)。
|
|
|
|
|
|
|
2022-08-25 09:45:22 +08:00
|
|
|
|
默认不限制。
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
2023-02-08 16:18:40 +08:00
|
|
|
|
#### query_type
|
|
|
|
|
|
|
2026-04-10 15:02:55 +08:00
|
|
|
|
!!! quote "sing-box 1.14.0 中的更改"
|
|
|
|
|
|
|
|
|
|
|
|
此字段现在也会在 DNS 规则被未指定具体 DNS 服务器的内部域名解析匹配时生效,
|
|
|
|
|
|
例如未设置 `server` 的 [`resolve`](../../route/rule_action/#resolve) 路由规则动作。
|
|
|
|
|
|
此前只有来自客户端的 DNS 查询才会评估此字段。完整列表参阅
|
|
|
|
|
|
[迁移指南](/zh/migration/#dns-规则中的-ip_version-和-query_type-行为更改)。
|
|
|
|
|
|
|
|
|
|
|
|
在 DNS 规则中设置此字段后,该 DNS 规则在同一 DNS 配置中不能与
|
|
|
|
|
|
旧版地址筛选字段 (DNS 规则)、旧版 DNS 规则动作 `strategy` 选项,
|
|
|
|
|
|
或旧版 `rule_set_ip_cidr_accept_empty` DNS 规则项共存。如需与
|
|
|
|
|
|
基于地址的筛选组合,请使用 [`evaluate`](../rule_action/#evaluate) 动作和
|
|
|
|
|
|
[`match_response`](#match_response)。
|
|
|
|
|
|
|
2023-02-08 16:18:40 +08:00
|
|
|
|
DNS 查询类型。值可以为整数或者类型名称字符串。
|
|
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
#### network
|
|
|
|
|
|
|
|
|
|
|
|
`tcp` 或 `udp`。
|
|
|
|
|
|
|
|
|
|
|
|
#### auth_user
|
|
|
|
|
|
|
|
|
|
|
|
认证用户名,参阅入站设置。
|
|
|
|
|
|
|
|
|
|
|
|
#### protocol
|
|
|
|
|
|
|
|
|
|
|
|
探测到的协议, 参阅 [协议探测](/zh/configuration/route/sniff/)。
|
|
|
|
|
|
|
|
|
|
|
|
#### domain
|
|
|
|
|
|
|
2022-08-24 16:56:29 +08:00
|
|
|
|
匹配完整域名。
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
|
|
|
|
|
#### domain_suffix
|
|
|
|
|
|
|
|
|
|
|
|
匹配域名后缀。
|
|
|
|
|
|
|
|
|
|
|
|
#### domain_keyword
|
|
|
|
|
|
|
|
|
|
|
|
匹配域名关键字。
|
|
|
|
|
|
|
|
|
|
|
|
#### domain_regex
|
|
|
|
|
|
|
|
|
|
|
|
匹配域名正则表达式。
|
|
|
|
|
|
|
|
|
|
|
|
#### geosite
|
|
|
|
|
|
|
2025-03-06 14:02:16 +08:00
|
|
|
|
!!! failure "已在 sing-box 1.12.0 中被移除"
|
2023-12-01 13:24:18 +08:00
|
|
|
|
|
2026-03-16 12:24:10 +08:00
|
|
|
|
GeoSite 已在 sing-box 1.8.0 废弃且在 sing-box 1.12.0 中被移除,参阅 [迁移指南](/zh/migration/#迁移-geosite-到规则集)。
|
2023-12-01 13:24:18 +08:00
|
|
|
|
|
|
|
|
|
|
匹配 Geosite。
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
|
|
|
|
|
#### source_geoip
|
|
|
|
|
|
|
2025-03-06 14:02:16 +08:00
|
|
|
|
!!! failure "已在 sing-box 1.12.0 中被移除"
|
2023-12-01 13:24:18 +08:00
|
|
|
|
|
2026-03-16 12:24:10 +08:00
|
|
|
|
GeoIP 已在 sing-box 1.8.0 废弃且在 sing-box 1.12.0 中被移除,参阅 [迁移指南](/zh/migration/#迁移-geoip-到规则集)。
|
2023-12-01 13:24:18 +08:00
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
匹配源 GeoIP。
|
|
|
|
|
|
|
|
|
|
|
|
#### source_ip_cidr
|
|
|
|
|
|
|
|
|
|
|
|
匹配源 IP CIDR。
|
|
|
|
|
|
|
2023-12-01 13:24:18 +08:00
|
|
|
|
#### source_ip_is_private
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.8.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
匹配非公开源 IP。
|
|
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
#### source_port
|
|
|
|
|
|
|
|
|
|
|
|
匹配源端口。
|
|
|
|
|
|
|
|
|
|
|
|
#### source_port_range
|
|
|
|
|
|
|
|
|
|
|
|
匹配源端口范围。
|
|
|
|
|
|
|
|
|
|
|
|
#### port
|
|
|
|
|
|
|
|
|
|
|
|
匹配端口。
|
|
|
|
|
|
|
|
|
|
|
|
#### port_range
|
|
|
|
|
|
|
|
|
|
|
|
匹配端口范围。
|
|
|
|
|
|
|
|
|
|
|
|
#### process_name
|
|
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
|
!!! quote ""
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
2022-08-25 09:45:22 +08:00
|
|
|
|
仅支持 Linux、Windows 和 macOS.
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
|
|
|
|
|
匹配进程名称。
|
|
|
|
|
|
|
2022-08-31 14:33:52 +08:00
|
|
|
|
#### process_path
|
|
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
|
!!! quote ""
|
2022-08-31 14:33:52 +08:00
|
|
|
|
|
|
|
|
|
|
仅支持 Linux、Windows 和 macOS.
|
|
|
|
|
|
|
|
|
|
|
|
匹配进程路径。
|
|
|
|
|
|
|
2024-09-15 11:42:57 +08:00
|
|
|
|
#### process_path_regex
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.10.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
|
|
|
|
|
仅支持 Linux、Windows 和 macOS.
|
|
|
|
|
|
|
|
|
|
|
|
使用正则表达式匹配进程路径。
|
|
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
#### package_name
|
|
|
|
|
|
|
|
|
|
|
|
匹配 Android 应用包名。
|
|
|
|
|
|
|
2026-04-10 11:54:47 +08:00
|
|
|
|
#### package_name_regex
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.14.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
使用正则表达式匹配 Android 应用包名。
|
|
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
#### user
|
|
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
|
!!! quote ""
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
2022-08-25 09:45:22 +08:00
|
|
|
|
仅支持 Linux。
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
|
|
|
|
|
匹配用户名。
|
|
|
|
|
|
|
|
|
|
|
|
#### user_id
|
|
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
|
!!! quote ""
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
2022-08-25 09:45:22 +08:00
|
|
|
|
仅支持 Linux。
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
|
|
|
|
|
匹配用户 ID。
|
|
|
|
|
|
|
2022-09-10 22:42:20 +08:00
|
|
|
|
#### clash_mode
|
|
|
|
|
|
|
|
|
|
|
|
匹配 Clash 模式。
|
|
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
#### network_type
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.11.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
|
|
|
|
|
仅在 Android 与 Apple 平台图形客户端中支持。
|
|
|
|
|
|
|
|
|
|
|
|
匹配网络类型。
|
|
|
|
|
|
|
|
|
|
|
|
Available values: `wifi`, `cellular`, `ethernet` and `other`.
|
|
|
|
|
|
|
|
|
|
|
|
#### network_is_expensive
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.11.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
|
|
|
|
|
仅在 Android 与 Apple 平台图形客户端中支持。
|
|
|
|
|
|
|
|
|
|
|
|
匹配如果网络被视为计费 (在 Android) 或被视为昂贵,
|
|
|
|
|
|
像蜂窝网络或个人热点 (在 Apple 平台)。
|
|
|
|
|
|
|
|
|
|
|
|
#### network_is_constrained
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.11.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
|
|
|
|
|
仅在 Apple 平台图形客户端中支持。
|
|
|
|
|
|
|
|
|
|
|
|
匹配如果网络在低数据模式下。
|
|
|
|
|
|
|
2025-08-14 11:04:04 +08:00
|
|
|
|
#### interface_address
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.13.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
|
|
|
|
|
仅支持 Linux、Windows 和 macOS.
|
|
|
|
|
|
|
|
|
|
|
|
匹配接口地址。
|
|
|
|
|
|
|
|
|
|
|
|
#### network_interface_address
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.13.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
|
|
|
|
|
仅在 Android 与 Apple 平台图形客户端中支持。
|
|
|
|
|
|
|
|
|
|
|
|
匹配网络接口(可用值同 `network_type`)地址。
|
|
|
|
|
|
|
|
|
|
|
|
#### default_interface_address
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.13.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
|
|
|
|
|
仅支持 Linux、Windows 和 macOS.
|
|
|
|
|
|
|
|
|
|
|
|
匹配默认接口地址。
|
|
|
|
|
|
|
2026-03-03 20:59:13 +08:00
|
|
|
|
#### source_mac_address
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.14.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
2026-03-06 21:43:21 +08:00
|
|
|
|
仅支持 Linux、macOS,或在 Android 和 macOS 图形客户端中支持。参阅 [邻居解析](/configuration/shared/neighbor/) 了解设置方法。
|
2026-03-03 20:59:13 +08:00
|
|
|
|
|
|
|
|
|
|
匹配源设备 MAC 地址。
|
|
|
|
|
|
|
|
|
|
|
|
#### source_hostname
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.14.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
2026-03-06 21:43:21 +08:00
|
|
|
|
仅支持 Linux、macOS,或在 Android 和 macOS 图形客户端中支持。参阅 [邻居解析](/configuration/shared/neighbor/) 了解设置方法。
|
2026-03-03 20:59:13 +08:00
|
|
|
|
|
|
|
|
|
|
匹配源设备从 DHCP 租约获取的主机名。
|
|
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
|
#### wifi_ssid
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
2025-12-07 11:05:43 +08:00
|
|
|
|
仅在 Android 与 Apple 平台图形客户端和 Linux 中支持。
|
2023-11-09 17:04:08 +08:00
|
|
|
|
|
|
|
|
|
|
匹配 WiFi SSID。
|
|
|
|
|
|
|
|
|
|
|
|
#### wifi_bssid
|
|
|
|
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
2025-12-07 11:05:43 +08:00
|
|
|
|
仅在 Android 与 Apple 平台图形客户端和 Linux 中支持。
|
2023-11-09 17:04:08 +08:00
|
|
|
|
|
|
|
|
|
|
匹配 WiFi BSSID。
|
|
|
|
|
|
|
2023-12-01 13:24:18 +08:00
|
|
|
|
#### rule_set
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.8.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
匹配[规则集](/zh/configuration/route/#rule_set)。
|
|
|
|
|
|
|
2024-02-21 14:27:55 +08:00
|
|
|
|
#### rule_set_ipcidr_match_source
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.9.0 起"
|
|
|
|
|
|
|
2024-06-24 09:41:00 +08:00
|
|
|
|
!!! failure "已在 sing-box 1.10.0 废弃"
|
|
|
|
|
|
|
2024-11-22 17:17:01 +08:00
|
|
|
|
`rule_set_ipcidr_match_source` 已重命名为 `rule_set_ip_cidr_match_source` 且将在 sing-box 1.11.0 中被移除。
|
2024-06-24 09:41:00 +08:00
|
|
|
|
|
|
|
|
|
|
使规则集中的 `ip_cidr` 规则匹配源 IP。
|
|
|
|
|
|
|
|
|
|
|
|
#### rule_set_ip_cidr_match_source
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.10.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
使规则集中的 `ip_cidr` 规则匹配源 IP。
|
2024-02-21 14:27:55 +08:00
|
|
|
|
|
2026-04-07 20:02:32 +08:00
|
|
|
|
#### match_response
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.14.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
启用响应匹配。启用后,此规则将匹配已评估的响应(由前序 [`evaluate`](/zh/configuration/dns/rule_action/#evaluate) 动作设置),而不仅是匹配原始查询。
|
|
|
|
|
|
|
|
|
|
|
|
该已评估的响应也可以被后续的 [`respond`](/zh/configuration/dns/rule_action/#respond) 动作直接返回。
|
|
|
|
|
|
|
|
|
|
|
|
响应匹配字段(`response_rcode`、`response_answer`、`response_ns`、`response_extra`)需要此选项。
|
2026-04-10 10:15:02 +08:00
|
|
|
|
当与 `evaluate` 或响应匹配字段一起使用时,`ip_cidr`、`ip_is_private` 和 `ip_accept_any` 也需要此选项。
|
|
|
|
|
|
|
|
|
|
|
|
#### ip_accept_any
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.12.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
当 DNS 查询响应包含至少一个地址时匹配。
|
2026-04-07 20:02:32 +08:00
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
#### invert
|
|
|
|
|
|
|
|
|
|
|
|
反选匹配结果。
|
|
|
|
|
|
|
|
|
|
|
|
#### outbound
|
|
|
|
|
|
|
2025-01-29 13:13:33 +08:00
|
|
|
|
!!! failure "已在 sing-box 1.12.0 废弃"
|
|
|
|
|
|
|
2026-03-16 12:24:10 +08:00
|
|
|
|
`outbound` 规则项已废弃且将在 sing-box 1.14.0 中被移除,参阅 [迁移指南](/zh/migration/#迁移-outbound-dns-规则项到域解析选项)。
|
2025-01-29 13:13:33 +08:00
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
匹配出站。
|
|
|
|
|
|
|
2023-03-29 10:30:31 +08:00
|
|
|
|
`any` 可作为值用于匹配任意出站。
|
|
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
#### action
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
2022-08-24 18:43:39 +08:00
|
|
|
|
==必填==
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
参阅 [规则动作](../rule_action/)。
|
|
|
|
|
|
|
|
|
|
|
|
#### server
|
|
|
|
|
|
|
|
|
|
|
|
!!! failure "已在 sing-box 1.11.0 废弃"
|
|
|
|
|
|
|
|
|
|
|
|
已移动到 [DNS 规则动作](../rule_action#route).
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
|
|
|
|
|
#### disable_cache
|
|
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
!!! failure "已在 sing-box 1.11.0 废弃"
|
|
|
|
|
|
|
|
|
|
|
|
已移动到 [DNS 规则动作](../rule_action#route).
|
2022-08-24 16:23:21 +08:00
|
|
|
|
|
2023-03-25 12:03:23 +08:00
|
|
|
|
#### rewrite_ttl
|
|
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
!!! failure "已在 sing-box 1.11.0 废弃"
|
2023-03-25 12:03:23 +08:00
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
已移动到 [DNS 规则动作](../rule_action#route).
|
2024-02-09 18:37:25 +08:00
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
#### client_subnet
|
2024-05-12 15:06:21 +08:00
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
!!! failure "已在 sing-box 1.11.0 废弃"
|
2024-02-09 18:37:25 +08:00
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
已移动到 [DNS 规则动作](../rule_action#route).
|
2024-02-09 18:37:25 +08:00
|
|
|
|
|
2026-04-07 20:02:32 +08:00
|
|
|
|
### 旧版地址筛选字段
|
|
|
|
|
|
|
|
|
|
|
|
!!! failure "已在 sing-box 1.14.0 废弃"
|
|
|
|
|
|
|
|
|
|
|
|
旧版地址筛选字段已废弃,且将在 sing-box 1.16.0 中被移除,
|
|
|
|
|
|
参阅[迁移指南](/zh/migration/#迁移地址筛选字段到响应匹配)。
|
2024-02-03 17:45:27 +08:00
|
|
|
|
|
2024-06-24 09:41:00 +08:00
|
|
|
|
仅对地址请求 (A/AAAA/HTTPS) 生效。 当查询结果与地址筛选规则项不匹配时,将跳过当前规则。
|
2024-02-03 17:45:27 +08:00
|
|
|
|
|
2024-02-14 20:42:58 +08:00
|
|
|
|
!!! info ""
|
2024-02-03 17:45:27 +08:00
|
|
|
|
|
|
|
|
|
|
引用的规则集中的 `ip_cidr` 项也作为地址筛选字段生效。
|
|
|
|
|
|
|
2024-02-14 20:42:58 +08:00
|
|
|
|
!!! note ""
|
|
|
|
|
|
|
|
|
|
|
|
启用 `experimental.cache_file.store_rdrc` 以缓存结果。
|
|
|
|
|
|
|
2024-02-03 17:45:27 +08:00
|
|
|
|
#### geoip
|
|
|
|
|
|
|
2025-03-06 14:02:16 +08:00
|
|
|
|
!!! failure "已在 sing-box 1.12.0 中被移除"
|
|
|
|
|
|
|
2026-03-16 12:24:10 +08:00
|
|
|
|
GeoIP 已在 sing-box 1.8.0 废弃且在 sing-box 1.12.0 中被移除,参阅 [迁移指南](/zh/migration/#迁移-geoip-到规则集)。
|
2025-03-06 14:02:16 +08:00
|
|
|
|
|
2024-02-03 17:45:27 +08:00
|
|
|
|
|
|
|
|
|
|
与查询响应匹配 GeoIP。
|
|
|
|
|
|
|
|
|
|
|
|
#### ip_cidr
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.9.0 起"
|
|
|
|
|
|
|
2024-06-24 09:41:00 +08:00
|
|
|
|
与查询响应匹配 IP CIDR。
|
2024-02-03 17:45:27 +08:00
|
|
|
|
|
2026-04-07 20:02:32 +08:00
|
|
|
|
作为旧版地址筛选字段已废弃。请改为配合 `match_response` 使用,
|
|
|
|
|
|
参阅[迁移指南](/zh/migration/#迁移地址筛选字段到响应匹配)。
|
|
|
|
|
|
|
2024-02-03 17:45:27 +08:00
|
|
|
|
#### ip_is_private
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.9.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
与查询响应匹配非公开 IP。
|
|
|
|
|
|
|
2026-04-07 20:02:32 +08:00
|
|
|
|
作为旧版地址筛选字段已废弃。请改为配合 `match_response` 使用,
|
|
|
|
|
|
参阅[迁移指南](/zh/migration/#迁移地址筛选字段到响应匹配)。
|
|
|
|
|
|
|
|
|
|
|
|
#### rule_set_ip_cidr_accept_empty
|
|
|
|
|
|
|
|
|
|
|
|
!!! question "自 sing-box 1.10.0 起"
|
|
|
|
|
|
|
|
|
|
|
|
!!! failure "已在 sing-box 1.14.0 废弃"
|
|
|
|
|
|
|
|
|
|
|
|
`rule_set_ip_cidr_accept_empty` 已废弃且将在 sing-box 1.16.0 中被移除,
|
|
|
|
|
|
参阅[迁移指南](/zh/migration/#迁移地址筛选字段到响应匹配)。
|
|
|
|
|
|
|
|
|
|
|
|
使规则集中的 `ip_cidr` 规则接受空查询响应。
|
|
|
|
|
|
|
|
|
|
|
|
### 响应匹配字段
|
2024-06-24 09:41:00 +08:00
|
|
|
|
|
2026-04-07 20:02:32 +08:00
|
|
|
|
!!! question "自 sing-box 1.14.0 起"
|
2024-06-24 09:41:00 +08:00
|
|
|
|
|
2026-04-07 20:02:32 +08:00
|
|
|
|
已评估的响应的匹配字段。需要将 `match_response` 设为 `true`,
|
|
|
|
|
|
且需要前序规则使用 [`evaluate`](/zh/configuration/dns/rule_action/#evaluate) 动作来填充响应。
|
|
|
|
|
|
|
|
|
|
|
|
该已评估的响应也可以被后续的 [`respond`](/zh/configuration/dns/rule_action/#respond) 动作直接返回。
|
|
|
|
|
|
|
|
|
|
|
|
#### response_rcode
|
|
|
|
|
|
|
|
|
|
|
|
匹配 DNS 响应码。
|
|
|
|
|
|
|
|
|
|
|
|
接受的值与 [predefined 动作 rcode](/zh/configuration/dns/rule_action/#rcode) 中相同。
|
|
|
|
|
|
|
|
|
|
|
|
#### response_answer
|
|
|
|
|
|
|
|
|
|
|
|
匹配 DNS 应答记录。
|
|
|
|
|
|
|
|
|
|
|
|
记录格式与 [predefined 动作 answer](/zh/configuration/dns/rule_action/#answer) 中相同。
|
|
|
|
|
|
|
|
|
|
|
|
#### response_ns
|
|
|
|
|
|
|
|
|
|
|
|
匹配 DNS 名称服务器记录。
|
|
|
|
|
|
|
|
|
|
|
|
记录格式与 [predefined 动作 ns](/zh/configuration/dns/rule_action/#ns) 中相同。
|
|
|
|
|
|
|
|
|
|
|
|
#### response_extra
|
|
|
|
|
|
|
|
|
|
|
|
匹配 DNS 额外记录。
|
|
|
|
|
|
|
|
|
|
|
|
记录格式与 [predefined 动作 extra](/zh/configuration/dns/rule_action/#extra) 中相同。
|
2024-06-24 09:41:00 +08:00
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
### 逻辑字段
|
|
|
|
|
|
|
|
|
|
|
|
#### type
|
|
|
|
|
|
|
|
|
|
|
|
`logical`
|
|
|
|
|
|
|
|
|
|
|
|
#### mode
|
|
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
==必填==
|
|
|
|
|
|
|
2022-08-24 16:23:21 +08:00
|
|
|
|
`and` 或 `or`
|
|
|
|
|
|
|
|
|
|
|
|
#### rules
|
|
|
|
|
|
|
2024-11-11 16:30:25 +08:00
|
|
|
|
==必填==
|
|
|
|
|
|
|
2026-03-25 10:32:09 +08:00
|
|
|
|
包括的规则。
|