2023-12-20 20:00:00 +08:00
|
|
|
!!! quote "Changes in sing-box 1.8.0"
|
|
|
|
|
|
|
|
:material-plus: [gso](#gso)
|
|
|
|
:material-alert-decagram: [stack](#stack)
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
!!! quote ""
|
2022-07-10 16:41:38 +08:00
|
|
|
|
2022-08-05 16:55:46 +08:00
|
|
|
Only supported on Linux, Windows and macOS.
|
2022-07-10 16:41:38 +08:00
|
|
|
|
|
|
|
### Structure
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2022-08-31 12:50:26 +08:00
|
|
|
"type": "tun",
|
|
|
|
"tag": "tun-in",
|
|
|
|
"interface_name": "tun0",
|
|
|
|
"inet4_address": "172.19.0.1/30",
|
2022-09-10 10:21:42 +08:00
|
|
|
"inet6_address": "fdfe:dcba:9876::1/126",
|
2022-09-09 15:40:35 +08:00
|
|
|
"mtu": 9000,
|
2023-12-20 20:00:00 +08:00
|
|
|
"gso": false,
|
2022-08-31 12:50:26 +08:00
|
|
|
"auto_route": true,
|
|
|
|
"strict_route": true,
|
2022-10-12 16:20:17 +08:00
|
|
|
"inet4_route_address": [
|
|
|
|
"0.0.0.0/1",
|
|
|
|
"128.0.0.0/1"
|
|
|
|
],
|
|
|
|
"inet6_route_address": [
|
|
|
|
"::/1",
|
|
|
|
"8000::/1"
|
|
|
|
],
|
2023-10-30 12:00:00 +08:00
|
|
|
"inet4_route_exclude_address": [
|
|
|
|
"192.168.0.0/16"
|
|
|
|
],
|
|
|
|
"inet6_route_exclude_address": [
|
|
|
|
"fc00::/7"
|
|
|
|
],
|
2022-08-31 12:50:26 +08:00
|
|
|
"endpoint_independent_nat": false,
|
2023-12-20 19:55:14 +08:00
|
|
|
"udp_timeout": "5m",
|
2022-09-15 12:20:38 +08:00
|
|
|
"stack": "system",
|
2023-08-20 16:49:25 +08:00
|
|
|
"include_interface": [
|
|
|
|
"lan0"
|
|
|
|
],
|
|
|
|
"exclude_interface": [
|
|
|
|
"lan1"
|
|
|
|
],
|
2022-08-31 12:50:26 +08:00
|
|
|
"include_uid": [
|
|
|
|
0
|
|
|
|
],
|
|
|
|
"include_uid_range": [
|
|
|
|
"1000-99999"
|
|
|
|
],
|
|
|
|
"exclude_uid": [
|
|
|
|
1000
|
|
|
|
],
|
|
|
|
"exclude_uid_range": [
|
|
|
|
"1000-99999"
|
|
|
|
],
|
|
|
|
"include_android_user": [
|
|
|
|
0,
|
|
|
|
10
|
|
|
|
],
|
|
|
|
"include_package": [
|
|
|
|
"com.android.chrome"
|
|
|
|
],
|
|
|
|
"exclude_package": [
|
|
|
|
"com.android.captiveportallogin"
|
|
|
|
],
|
2023-03-05 15:19:13 +08:00
|
|
|
"platform": {
|
|
|
|
"http_proxy": {
|
|
|
|
"enabled": false,
|
|
|
|
"server": "127.0.0.1",
|
|
|
|
"server_port": 8080
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
... // Listen Fields
|
2022-07-10 16:41:38 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-08-15 00:25:49 +08:00
|
|
|
!!! note ""
|
|
|
|
|
|
|
|
You can ignore the JSON Array [] tag when the content is only one item
|
|
|
|
|
2022-08-08 20:57:50 +08:00
|
|
|
!!! warning ""
|
|
|
|
|
2022-08-15 00:25:49 +08:00
|
|
|
If tun is running in non-privileged mode, addresses and MTU will not be configured automatically, please make sure the settings are accurate.
|
2022-08-08 20:57:50 +08:00
|
|
|
|
2022-08-31 12:50:26 +08:00
|
|
|
### Fields
|
2022-07-10 16:41:38 +08:00
|
|
|
|
2022-08-08 20:57:50 +08:00
|
|
|
#### interface_name
|
|
|
|
|
|
|
|
Virtual device name, automatically selected if empty.
|
|
|
|
|
2022-07-10 16:41:38 +08:00
|
|
|
#### inet4_address
|
|
|
|
|
|
|
|
==Required==
|
|
|
|
|
|
|
|
IPv4 prefix for the tun interface.
|
|
|
|
|
|
|
|
#### inet6_address
|
|
|
|
|
|
|
|
IPv6 prefix for the tun interface.
|
|
|
|
|
|
|
|
#### mtu
|
|
|
|
|
|
|
|
The maximum transmission unit.
|
|
|
|
|
2023-12-20 20:00:00 +08:00
|
|
|
#### gso
|
|
|
|
|
|
|
|
!!! question "Since sing-box 1.8.0"
|
|
|
|
|
|
|
|
!!! quote ""
|
|
|
|
|
|
|
|
Only supported on Linux.
|
|
|
|
|
|
|
|
Enable generic segmentation offload.
|
|
|
|
|
2022-07-10 16:41:38 +08:00
|
|
|
#### auto_route
|
|
|
|
|
|
|
|
Set the default route to the Tun.
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
!!! quote ""
|
2022-07-10 16:41:38 +08:00
|
|
|
|
2022-07-15 11:51:51 +08:00
|
|
|
To avoid traffic loopback, set `route.auto_detect_interface` or `route.default_interface` or `outbound.bind_interface`
|
2022-07-10 16:41:38 +08:00
|
|
|
|
2022-09-09 15:40:35 +08:00
|
|
|
!!! note "Use with Android VPN"
|
|
|
|
|
|
|
|
By default, VPN takes precedence over tun. To make tun go through VPN, enable `route.override_android_vpn`.
|
|
|
|
|
2022-08-26 23:52:17 +08:00
|
|
|
#### strict_route
|
|
|
|
|
2022-10-01 11:48:46 +08:00
|
|
|
Enforce strict routing rules when `auto_route` is enabled:
|
2022-08-26 23:52:17 +08:00
|
|
|
|
2022-11-06 10:15:13 +08:00
|
|
|
*In Linux*:
|
|
|
|
|
2022-08-26 23:52:17 +08:00
|
|
|
* Let unsupported network unreachable
|
|
|
|
* Route all connections to tun
|
|
|
|
|
2024-04-26 19:46:41 +08:00
|
|
|
It prevents address leaks and makes DNS hijacking work on Android.
|
2022-08-26 23:52:17 +08:00
|
|
|
|
2022-11-06 10:15:13 +08:00
|
|
|
*In Windows*:
|
|
|
|
|
|
|
|
* Add firewall rules to prevent DNS leak caused by
|
|
|
|
Windows' [ordinary multihomed DNS resolution behavior](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/dd197552%28v%3Dws.10%29)
|
|
|
|
|
|
|
|
It may prevent some applications (such as VirtualBox) from working properly in certain situations.
|
|
|
|
|
2022-10-12 16:20:17 +08:00
|
|
|
#### inet4_route_address
|
|
|
|
|
|
|
|
Use custom routes instead of default when `auto_route` is enabled.
|
|
|
|
|
|
|
|
#### inet6_route_address
|
|
|
|
|
|
|
|
Use custom routes instead of default when `auto_route` is enabled.
|
|
|
|
|
2023-10-30 12:00:00 +08:00
|
|
|
#### inet4_route_exclude_address
|
|
|
|
|
|
|
|
Exclude custom routes when `auto_route` is enabled.
|
|
|
|
|
|
|
|
#### inet6_route_exclude_address
|
|
|
|
|
|
|
|
Exclude custom routes when `auto_route` is enabled.
|
|
|
|
|
2022-07-27 12:03:07 +08:00
|
|
|
#### endpoint_independent_nat
|
|
|
|
|
2022-09-09 15:40:35 +08:00
|
|
|
!!! info ""
|
|
|
|
|
|
|
|
This item is only available on the gvisor stack, other stacks are endpoint-independent NAT by default.
|
|
|
|
|
2022-08-05 16:55:46 +08:00
|
|
|
Enable endpoint-independent NAT.
|
2022-07-27 12:03:07 +08:00
|
|
|
|
|
|
|
Performance may degrade slightly, so it is not recommended to enable on when it is not needed.
|
|
|
|
|
|
|
|
#### udp_timeout
|
|
|
|
|
|
|
|
UDP NAT expiration time in seconds, default is 300 (5 minutes).
|
|
|
|
|
2022-08-08 20:57:50 +08:00
|
|
|
#### stack
|
|
|
|
|
2023-12-20 20:00:00 +08:00
|
|
|
!!! quote "Changes in sing-box 1.8.0"
|
2022-08-08 20:57:50 +08:00
|
|
|
|
2023-12-20 20:00:00 +08:00
|
|
|
:material-delete-alert: The legacy LWIP stack has been deprecated and removed.
|
2022-08-08 20:57:50 +08:00
|
|
|
|
2023-12-20 20:00:00 +08:00
|
|
|
TCP/IP stack.
|
|
|
|
|
|
|
|
| Stack | Description |
|
|
|
|
|----------|-------------------------------------------------------------------------------------------------------|
|
|
|
|
| `system` | Perform L3 to L4 translation using the system network stack |
|
|
|
|
| `gvisor` | Perform L3 to L4 translation using [gVisor](https://github.com/google/gvisor)'s virtual network stack |
|
|
|
|
| `mixed` | Mixed `system` TCP stack and `gvisor` UDP stack |
|
2022-08-08 20:57:50 +08:00
|
|
|
|
2023-12-20 20:00:00 +08:00
|
|
|
Defaults to the `mixed` stack if the gVisor build tag is enabled, otherwise defaults to the `system` stack.
|
2022-08-08 20:57:50 +08:00
|
|
|
|
2023-08-20 16:49:25 +08:00
|
|
|
#### include_interface
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
!!! quote ""
|
2023-08-20 16:49:25 +08:00
|
|
|
|
|
|
|
Interface rules are only supported on Linux and require auto_route.
|
|
|
|
|
|
|
|
Limit interfaces in route. Not limited by default.
|
|
|
|
|
|
|
|
Conflict with `exclude_interface`.
|
|
|
|
|
|
|
|
#### exclude_interface
|
|
|
|
|
|
|
|
Exclude interfaces in route.
|
|
|
|
|
|
|
|
Conflict with `include_interface`.
|
|
|
|
|
2022-08-15 00:25:49 +08:00
|
|
|
#### include_uid
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
!!! quote ""
|
2022-08-15 00:25:49 +08:00
|
|
|
|
2022-08-15 11:40:49 +08:00
|
|
|
UID rules are only supported on Linux and require auto_route.
|
2022-08-15 00:25:49 +08:00
|
|
|
|
|
|
|
Limit users in route. Not limited by default.
|
|
|
|
|
|
|
|
#### include_uid_range
|
|
|
|
|
|
|
|
Limit users in route, but in range.
|
|
|
|
|
2022-08-15 11:40:49 +08:00
|
|
|
#### exclude_uid
|
|
|
|
|
|
|
|
Exclude users in route.
|
|
|
|
|
|
|
|
#### exclude_uid_range
|
|
|
|
|
|
|
|
Exclude users in route, but in range.
|
|
|
|
|
2022-08-15 00:25:49 +08:00
|
|
|
#### include_android_user
|
|
|
|
|
2023-11-09 17:04:08 +08:00
|
|
|
!!! quote ""
|
2022-08-15 00:25:49 +08:00
|
|
|
|
2022-08-15 11:40:49 +08:00
|
|
|
Android user and package rules are only supported on Android and require auto_route.
|
2022-08-15 00:25:49 +08:00
|
|
|
|
|
|
|
Limit android users in route.
|
|
|
|
|
2023-12-20 20:00:00 +08:00
|
|
|
| Common user | ID |
|
|
|
|
|--------------|----|
|
|
|
|
| Main | 0 |
|
|
|
|
| Work Profile | 10 |
|
2022-08-15 00:25:49 +08:00
|
|
|
|
2022-08-15 11:40:49 +08:00
|
|
|
#### include_package
|
2022-08-15 00:25:49 +08:00
|
|
|
|
2022-08-15 11:40:49 +08:00
|
|
|
Limit android packages in route.
|
2022-08-15 00:25:49 +08:00
|
|
|
|
2022-08-15 11:40:49 +08:00
|
|
|
#### exclude_package
|
2022-08-15 00:25:49 +08:00
|
|
|
|
2022-08-15 11:40:49 +08:00
|
|
|
Exclude android packages in route.
|
2022-08-15 00:25:49 +08:00
|
|
|
|
2023-03-05 15:19:13 +08:00
|
|
|
#### platform
|
|
|
|
|
|
|
|
Platform-specific settings, provided by client applications.
|
|
|
|
|
|
|
|
#### platform.http_proxy
|
|
|
|
|
|
|
|
System HTTP proxy settings.
|
|
|
|
|
2022-07-10 16:41:38 +08:00
|
|
|
### Listen Fields
|
|
|
|
|
2023-12-14 22:23:52 +08:00
|
|
|
See [Listen Fields](/configuration/shared/listen/) for details.
|