Files
sing-box-extended-mirror/docs/configuration/route/index.zh.md
T

186 lines
4.3 KiB
Markdown
Raw Normal View History

2024-11-13 19:05:28 +08:00
---
2025-01-29 13:13:33 +08:00
icon: material/alert-decagram
2024-11-13 19:05:28 +08:00
---
2022-08-24 16:23:21 +08:00
# 路由
2026-03-03 20:59:13 +08:00
!!! quote "sing-box 1.14.0 中的更改"
:material-plus: [find_neighbor](#find_neighbor)
:material-plus: [dhcp_lease_files](#dhcp_lease_files)
2025-01-29 13:13:33 +08:00
!!! quote "sing-box 1.12.0 中的更改"
:material-plus: [default_domain_resolver](#default_domain_resolver)
:material-note-remove: [geoip](#geoip)
:material-note-remove: [geosite](#geosite)
2024-11-13 19:05:28 +08:00
!!! quote "sing-box 1.11.0 中的更改"
2026-03-16 12:24:10 +08:00
:material-plus: [default_network_strategy](#default_network_strategy)
2024-11-13 19:05:28 +08:00
:material-plus: [default_network_type](#default_network_type)
:material-plus: [default_fallback_network_type](#default_fallback_network_type)
2024-11-16 12:15:14 +08:00
:material-plus: [default_fallback_delay](#default_fallback_delay)
2024-11-13 19:05:28 +08:00
2023-12-01 13:24:18 +08:00
!!! quote "sing-box 1.8.0 中的更改"
:material-plus: [rule_set](#rule_set)
:material-delete-clock: [geoip](#geoip)
:material-delete-clock: [geosite](#geosite)
2022-08-24 16:23:21 +08:00
### 结构
```json
{
"route": {
"geoip": {},
"geosite": {},
"rules": [],
2023-12-01 13:24:18 +08:00
"rule_set": [],
2022-08-24 16:23:21 +08:00
"final": "",
"auto_detect_interface": false,
2022-09-09 15:40:35 +08:00
"override_android_vpn": false,
2024-11-12 19:37:10 +08:00
"default_interface": "",
"default_mark": 0,
"find_process": false,
2026-03-03 20:59:13 +08:00
"find_neighbor": false,
"dhcp_lease_files": [],
2024-11-12 19:37:10 +08:00
"default_network_strategy": "",
"default_fallback_delay": ""
2022-08-24 16:23:21 +08:00
}
}
```
2024-11-13 19:05:28 +08:00
!!! note ""
当内容只有一项时,可以忽略 JSON 数组 [] 标签
2022-08-25 09:45:22 +08:00
### 字段
2022-08-24 16:23:21 +08:00
2023-12-14 22:23:52 +08:00
| 键 | 格式 |
|-----------|-----------------------|
| `geoip` | [GeoIP](./geoip/) |
2023-12-01 13:24:18 +08:00
| `geosite` | [Geosite](./geosite/) |
#### rule
一组 [路由规则](./rule/) 。
#### rule_set
!!! question "自 sing-box 1.8.0 起"
2025-12-22 05:28:10 +08:00
一组 [规则集](/zh/configuration/rule-set/)。
2022-08-24 16:23:21 +08:00
#### final
2023-11-16 01:11:28 +08:00
默认出站标签。如果为空,将使用第一个可用于对应协议的出站。
2022-08-24 16:23:21 +08:00
#### auto_detect_interface
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-09-09 15:40:35 +08:00
默认将出站连接绑定到默认网卡,以防止在 tun 下出现路由环路。
2022-08-24 16:23:21 +08:00
如果设置了 `outbound.bind_interface` 设置,则不生效。
2022-09-09 15:40:35 +08:00
#### override_android_vpn
2023-11-09 17:04:08 +08:00
!!! quote ""
2022-09-09 15:40:35 +08:00
仅支持 Android。
启用 `auto_detect_interface` 时接受 Android VPN 作为上游网卡。
2022-08-24 16:23:21 +08:00
#### default_interface
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-09-09 15:40:35 +08:00
默认将出站连接绑定到指定网卡,以防止在 tun 下出现路由环路。
2022-08-24 16:23:21 +08:00
如果设置了 `auto_detect_interface` 设置,则不生效。
#### default_mark
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
默认为出站连接设置路由标记。
2023-11-16 01:11:28 +08:00
如果设置了 `outbound.routing_mark` 设置,则不生效。
2024-11-12 19:37:10 +08:00
#### find_process
!!! quote ""
仅支持 Linux、Windows 和 macOS。
在没有 `process_name`、`process_path`、`package_name`、`user` 或 `user_id` 规则时启用进程搜索以输出日志。
2026-03-03 20:59:13 +08:00
#### find_neighbor
!!! question "自 sing-box 1.14.0 起"
!!! quote ""
仅支持 Linux 和 macOS。
2026-03-03 20:59:13 +08:00
在没有 `source_mac_address` 或 `source_hostname` 规则时启用邻居解析以输出日志。
2026-03-03 20:59:13 +08:00
参阅 [邻居解析](/configuration/shared/neighbor/) 了解设置方法。
2026-03-03 20:59:13 +08:00
#### dhcp_lease_files
!!! question "自 sing-box 1.14.0 起"
!!! quote ""
仅支持 Linux 和 macOS。
2026-03-03 20:59:13 +08:00
用于主机名和 MAC 地址解析的自定义 DHCP 租约文件路径。
为空时自动从常见 DHCP 服务器(dnsmasq、odhcpd、ISC dhcpd、Kea)检测。
2025-01-29 13:13:33 +08:00
#### default_domain_resolver
!!! question "自 sing-box 1.12.0 起"
2026-03-16 12:24:10 +08:00
详情参阅 [拨号字段](/zh/configuration/shared/dial/#domain_resolver)。
2025-01-29 13:13:33 +08:00
可以被 `outbound.domain_resolver` 覆盖。
2024-11-12 19:37:10 +08:00
#### network_strategy
2024-11-13 19:05:28 +08:00
!!! question "自 sing-box 1.11.0 起"
2024-11-12 19:37:10 +08:00
2026-03-16 12:24:10 +08:00
详情参阅 [拨号字段](/zh/configuration/shared/dial/#network_strategy)。
2024-11-12 19:37:10 +08:00
当 `outbound.bind_interface`, `outbound.inet4_bind_address` 或 `outbound.inet6_bind_address` 已设置时不生效。
可以被 `outbound.network_strategy` 覆盖。
与 `default_interface` 冲突。
2024-11-13 19:05:28 +08:00
#### default_network_type
2024-11-12 19:37:10 +08:00
2024-11-13 19:05:28 +08:00
!!! question "自 sing-box 1.11.0 起"
2024-11-12 19:37:10 +08:00
2026-03-16 12:24:10 +08:00
详情参阅 [拨号字段](/zh/configuration/shared/dial/#default_network_type)。
2024-11-13 19:05:28 +08:00
#### default_fallback_network_type
!!! question "自 sing-box 1.11.0 起"
2026-03-16 12:24:10 +08:00
详情参阅 [拨号字段](/zh/configuration/shared/dial/#default_fallback_network_type)。
2024-11-13 19:05:28 +08:00
#### default_fallback_delay
2024-11-12 19:37:10 +08:00
2024-11-13 19:05:28 +08:00
!!! question "自 sing-box 1.11.0 起"
2024-11-12 19:37:10 +08:00
2026-03-16 12:24:10 +08:00
详情参阅 [拨号字段](/zh/configuration/shared/dial/#fallback_delay)。