2024-02-18 16:19:33 +00:00
---
2024-11-22 09:41:19 +00:00
icon: material/alert-decagram
2024-02-18 16:19:33 +00:00
---
2024-11-22 09:41:19 +00:00
!!! quote "Changes in sing-box 1.11.0"
:material-delete-alert: [gso ](#gso )
2024-06-07 07:55:21 +00:00
!!! quote "Changes in sing-box 1.10.0"
:material-plus: [address ](#address )
:material-delete-clock: [inet4_address ](#inet4_address )
:material-delete-clock: [inet6_address ](#inet6_address )
:material-plus: [route_address ](#route_address )
:material-delete-clock: [inet4_route_address ](#inet4_route_address )
:material-delete-clock: [inet6_route_address ](#inet6_route_address )
:material-plus: [route_exclude_address ](#route_address )
:material-delete-clock: [inet4_route_exclude_address ](#inet4_route_exclude_address )
:material-delete-clock: [inet6_route_exclude_address ](#inet6_route_exclude_address )
2024-06-22 06:11:49 +00:00
:material-plus: [iproute2_table_index ](#iproute2_table_index )
:material-plus: [iproute2_rule_index ](#iproute2_table_index )
2024-06-07 07:55:21 +00:00
:material-plus: [auto_redirect ](#auto_redirect )
2024-06-22 06:11:49 +00:00
:material-plus: [auto_redirect_input_mark ](#auto_redirect_input_mark )
:material-plus: [auto_redirect_output_mark ](#auto_redirect_output_mark )
2024-06-07 07:55:21 +00:00
:material-plus: [route_address_set ](#route_address_set )
:material-plus: [route_exclude_address_set ](#route_address_set )
2024-02-18 16:19:33 +00:00
!!! quote "Changes in sing-box 1.9.0"
:material-plus: [platform.http_proxy.bypass_domain ](#platformhttp_proxybypass_domain )
:material-plus: [platform.http_proxy.match_domain ](#platformhttp_proxymatch_domain )
2023-12-20 12:00:00 +00:00
!!! quote "Changes in sing-box 1.8.0"
:material-plus: [gso ](#gso )
:material-alert-decagram: [stack ](#stack )
2023-11-09 09:04:08 +00:00
!!! quote ""
2022-07-10 08:41:38 +00:00
2022-08-05 08:55:46 +00:00
Only supported on Linux, Windows and macOS.
2022-07-10 08:41:38 +00:00
### Structure
```json
{
2022-08-31 04:50:26 +00:00
"type": "tun",
"tag": "tun-in",
"interface_name": "tun0",
2024-06-07 07:55:21 +00:00
"address": [
"172.18.0.1/30",
"fdfe:dcba:9876::1/126"
],
2022-09-09 07:40:35 +00:00
"mtu": 9000,
2022-08-31 04:50:26 +00:00
"auto_route": true,
2024-06-22 06:11:49 +00:00
"iproute2_table_index": 2022,
"iproute2_rule_index": 9000,
2024-06-07 07:55:21 +00:00
"auto_redirect": false,
2024-06-22 06:11:49 +00:00
"auto_redirect_input_mark": "0x2023",
"auto_redirect_output_mark": "0x2024",
"strict_route": true,
2024-06-07 07:55:21 +00:00
"route_address": [
"0.0.0.0/1",
"128.0.0.0/1",
"::/1",
"8000::/1"
],
2024-11-22 09:41:19 +00:00
2024-06-07 07:55:21 +00:00
"route_exclude_address": [
"192.168.0.0/16",
"fc00::/7"
],
"route_address_set": [
"geoip-cloudflare"
],
"route_exclude_address_set": [
"geoip-cn"
],
2022-08-31 04:50:26 +00:00
"endpoint_independent_nat": false,
2023-12-20 11:55:14 +00:00
"udp_timeout": "5m",
2022-09-15 04:20:38 +00:00
"stack": "system",
2023-08-20 08:49:25 +00:00
"include_interface": [
"lan0"
],
"exclude_interface": [
"lan1"
],
2022-08-31 04:50:26 +00: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 07:19:13 +00:00
"platform": {
"http_proxy": {
"enabled": false,
"server": "127.0.0.1",
2024-02-18 16:19:33 +00:00
"server_port": 8080,
"bypass_domain": [],
"match_domain": []
2023-03-05 07:19:13 +00:00
}
},
2024-11-22 09:41:19 +00:00
// Deprecated
"gso": false,
"inet4_address": [
"172.19.0.1/30"
],
"inet6_address": [
"fdfe:dcba:9876::1/126"
],
"inet4_route_address": [
"0.0.0.0/1",
"128.0.0.0/1"
],
"inet6_route_address": [
"::/1",
"8000::/1"
],
"inet4_route_exclude_address": [
"192.168.0.0/16"
],
"inet6_route_exclude_address": [
"fc00::/7"
],
... // Listen Fields
2022-07-10 08:41:38 +00:00
}
```
2022-08-14 16:25:49 +00:00
!!! note ""
You can ignore the JSON Array [] tag when the content is only one item
2022-08-08 12:57:50 +00:00
!!! warning ""
2022-08-14 16:25:49 +00: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 12:57:50 +00:00
2022-08-31 04:50:26 +00:00
### Fields
2022-07-10 08:41:38 +00:00
2022-08-08 12:57:50 +00:00
#### interface_name
Virtual device name, automatically selected if empty.
2024-06-07 07:55:21 +00:00
#### address
!!! question "Since sing-box 1.10.0"
IPv4 and IPv6 prefix for the tun interface.
2022-07-10 08:41:38 +00:00
#### inet4_address
2024-06-07 07:55:21 +00:00
!!! failure "Deprecated in sing-box 1.10.0"
2024-11-22 09:41:19 +00:00
`inet4_address` is merged to `address` and will be removed in sing-box 1.12.0.
2022-07-10 08:41:38 +00:00
IPv4 prefix for the tun interface.
#### inet6_address
2024-06-07 07:55:21 +00:00
!!! failure "Deprecated in sing-box 1.10.0"
2024-11-22 09:41:19 +00:00
`inet6_address` is merged to `address` and will be removed in sing-box 1.12.0.
2024-06-07 07:55:21 +00:00
2022-07-10 08:41:38 +00:00
IPv6 prefix for the tun interface.
#### mtu
The maximum transmission unit.
2023-12-20 12:00:00 +00:00
#### gso
2024-11-22 09:41:19 +00:00
!!! failure "Deprecated in sing-box 1.11.0"
GSO has no advantages for transparent proxy scenarios, is deprecated and no longer works, and will be removed in sing-box 1.12.0.
2023-12-20 12:00:00 +00:00
!!! question "Since sing-box 1.8.0"
!!! quote ""
2024-06-22 06:11:49 +00:00
Only supported on Linux with `auto_route` enabled.
2023-12-20 12:00:00 +00:00
Enable generic segmentation offload.
2022-07-10 08:41:38 +00:00
#### auto_route
Set the default route to the Tun.
2023-11-09 09:04:08 +00:00
!!! quote ""
2022-07-10 08:41:38 +00:00
2022-07-15 03:51:51 +00:00
To avoid traffic loopback, set `route.auto_detect_interface` or `route.default_interface` or `outbound.bind_interface`
2022-07-10 08:41:38 +00:00
2022-09-09 07:40:35 +00:00
!!! note "Use with Android VPN"
By default, VPN takes precedence over tun. To make tun go through VPN, enable `route.override_android_vpn` .
2024-06-22 06:11:49 +00:00
#### iproute2_table_index
2022-08-26 15:52:17 +00:00
2024-06-22 06:11:49 +00:00
!!! question "Since sing-box 1.10.0"
2022-08-26 15:52:17 +00:00
2024-06-22 06:11:49 +00:00
Linux iproute2 table index generated by `auto_route` .
2022-11-06 02:15:13 +00:00
2024-06-22 06:11:49 +00:00
`2022` is used by default.
2022-08-26 15:52:17 +00:00
2024-06-22 06:11:49 +00:00
#### iproute2_rule_index
2022-08-26 15:52:17 +00:00
2024-06-22 06:11:49 +00:00
!!! question "Since sing-box 1.10.0"
2022-11-06 02:15:13 +00:00
2024-06-22 06:11:49 +00:00
Linux iproute2 rule start index generated by `auto_route` .
2022-11-06 02:15:13 +00:00
2024-06-22 06:11:49 +00:00
`9000` is used by default.
2022-11-06 02:15:13 +00:00
2024-06-07 07:55:21 +00:00
#### auto_redirect
!!! question "Since sing-box 1.10.0"
!!! quote ""
Only supported on Linux with `auto_route` enabled.
Automatically configure iptables/nftables to redirect connections.
*In Android*:
2024-10-13 05:20:49 +00:00
Only local IPv4 connections are forwarded. To share your VPN connection over hotspot or repeater,
2024-06-07 07:55:21 +00:00
use [VPNHotspot ](https://github.com/Mygod/VPNHotspot ).
*In Linux*:
2024-10-13 05:20:49 +00:00
`auto_route` with `auto_redirect` works as expected on routers **without intervention** .
2024-06-07 07:55:21 +00:00
2024-06-22 06:11:49 +00:00
#### auto_redirect_input_mark
!!! question "Since sing-box 1.10.0"
Connection input mark used by `route_address_set` and `route_exclude_address_set` .
`0x2023` is used by default.
#### auto_redirect_output_mark
!!! question "Since sing-box 1.10.0"
Connection output mark used by `route_address_set` and `route_exclude_address_set` .
`0x2024` is used by default.
#### strict_route
Enforce strict routing rules when `auto_route` is enabled:
*In Linux*:
* Let unsupported network unreachable
* Make ICMP traffic route to tun instead of upstream interfaces
* Route all connections to tun
It prevents IP address leaks and makes DNS hijacking work on Android.
*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.
2024-06-07 07:55:21 +00:00
#### route_address
!!! question "Since sing-box 1.10.0"
Use custom routes instead of default when `auto_route` is enabled.
2022-10-12 08:20:17 +00:00
#### inet4_route_address
2024-06-07 07:55:21 +00:00
!!! failure "Deprecated in sing-box 1.10.0"
2024-11-22 09:41:19 +00:00
`inet4_route_address` is deprecated and will be removed in sing-box 1.12.0, please use [route_address ](#route_address )
2024-06-22 06:11:49 +00:00
instead.
2024-06-07 07:55:21 +00:00
2022-10-12 08:20:17 +00:00
Use custom routes instead of default when `auto_route` is enabled.
#### inet6_route_address
2024-06-07 07:55:21 +00:00
!!! failure "Deprecated in sing-box 1.10.0"
2024-11-22 09:41:19 +00:00
`inet6_route_address` is deprecated and will be removed in sing-box 1.12.0, please use [route_address ](#route_address )
2024-06-22 06:11:49 +00:00
instead.
2024-06-07 07:55:21 +00:00
2022-10-12 08:20:17 +00:00
Use custom routes instead of default when `auto_route` is enabled.
2024-06-07 07:55:21 +00:00
#### route_exclude_address
!!! question "Since sing-box 1.10.0"
Exclude custom routes when `auto_route` is enabled.
2023-10-30 04:00:00 +00:00
#### inet4_route_exclude_address
2024-06-07 07:55:21 +00:00
!!! failure "Deprecated in sing-box 1.10.0"
2024-11-22 09:41:19 +00:00
`inet4_route_exclude_address` is deprecated and will be removed in sing-box 1.12.0, please
2024-06-22 06:11:49 +00:00
use [route_exclude_address ](#route_exclude_address ) instead.
2024-06-07 07:55:21 +00:00
2023-10-30 04:00:00 +00:00
Exclude custom routes when `auto_route` is enabled.
#### inet6_route_exclude_address
2024-06-07 07:55:21 +00:00
!!! failure "Deprecated in sing-box 1.10.0"
2024-11-22 09:41:19 +00:00
`inet6_route_exclude_address` is deprecated and will be removed in sing-box 1.12.0, please
2024-06-22 06:11:49 +00:00
use [route_exclude_address ](#route_exclude_address ) instead.
2024-06-07 07:55:21 +00:00
2023-10-30 04:00:00 +00:00
Exclude custom routes when `auto_route` is enabled.
2024-06-07 07:55:21 +00:00
#### route_address_set
!!! question "Since sing-box 1.10.0"
!!! quote ""
Only supported on Linux with nftables and requires `auto_route` and `auto_redirect` enabled.
Add the destination IP CIDR rules in the specified rule-sets to the firewall.
Unmatched traffic will bypass the sing-box routes.
Conflict with `route.default_mark` and `[dialOptions].routing_mark` .
#### route_exclude_address_set
!!! question "Since sing-box 1.10.0"
!!! quote ""
Only supported on Linux with nftables and requires `auto_route` and `auto_redirect` enabled.
Add the destination IP CIDR rules in the specified rule-sets to the firewall.
Matched traffic will bypass the sing-box routes.
Conflict with `route.default_mark` and `[dialOptions].routing_mark` .
2022-07-27 04:03:07 +00:00
#### endpoint_independent_nat
2022-09-09 07:40:35 +00:00
!!! info ""
This item is only available on the gvisor stack, other stacks are endpoint-independent NAT by default.
2022-08-05 08:55:46 +00:00
Enable endpoint-independent NAT.
2022-07-27 04:03:07 +00:00
Performance may degrade slightly, so it is not recommended to enable on when it is not needed.
#### udp_timeout
2024-11-22 04:59:26 +00:00
UDP NAT expiration time.
`5m` will be used by default.
2022-07-27 04:03:07 +00:00
2022-08-08 12:57:50 +00:00
#### stack
2023-12-20 12:00:00 +00:00
!!! quote "Changes in sing-box 1.8.0"
2022-08-08 12:57:50 +00:00
2023-12-20 12:00:00 +00:00
:material-delete-alert: The legacy LWIP stack has been deprecated and removed.
2022-08-08 12:57:50 +00:00
2023-12-20 12:00:00 +00: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 12:57:50 +00:00
2023-12-20 12:00:00 +00:00
Defaults to the `mixed` stack if the gVisor build tag is enabled, otherwise defaults to the `system` stack.
2022-08-08 12:57:50 +00:00
2023-08-20 08:49:25 +00:00
#### include_interface
2023-11-09 09:04:08 +00:00
!!! quote ""
2023-08-20 08:49:25 +00: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
2024-06-07 07:55:21 +00:00
!!! warning ""
When `strict_route` enabled, return traffic to excluded interfaces will not be automatically excluded, so add them as well (example: `br-lan` and `pppoe-wan` ).
2023-08-20 08:49:25 +00:00
Exclude interfaces in route.
Conflict with `include_interface` .
2022-08-14 16:25:49 +00:00
#### include_uid
2023-11-09 09:04:08 +00:00
!!! quote ""
2022-08-14 16:25:49 +00:00
2022-08-15 03:40:49 +00:00
UID rules are only supported on Linux and require auto_route.
2022-08-14 16:25:49 +00:00
Limit users in route. Not limited by default.
#### include_uid_range
Limit users in route, but in range.
2022-08-15 03:40:49 +00:00
#### exclude_uid
Exclude users in route.
#### exclude_uid_range
Exclude users in route, but in range.
2022-08-14 16:25:49 +00:00
#### include_android_user
2023-11-09 09:04:08 +00:00
!!! quote ""
2022-08-14 16:25:49 +00:00
2022-08-15 03:40:49 +00:00
Android user and package rules are only supported on Android and require auto_route.
2022-08-14 16:25:49 +00:00
Limit android users in route.
2023-12-20 12:00:00 +00:00
| Common user | ID |
|--------------|----|
| Main | 0 |
| Work Profile | 10 |
2022-08-14 16:25:49 +00:00
2022-08-15 03:40:49 +00:00
#### include_package
2022-08-14 16:25:49 +00:00
2022-08-15 03:40:49 +00:00
Limit android packages in route.
2022-08-14 16:25:49 +00:00
2022-08-15 03:40:49 +00:00
#### exclude_package
2022-08-14 16:25:49 +00:00
2022-08-15 03:40:49 +00:00
Exclude android packages in route.
2022-08-14 16:25:49 +00:00
2023-03-05 07:19:13 +00:00
#### platform
Platform-specific settings, provided by client applications.
#### platform.http_proxy
System HTTP proxy settings.
2024-02-18 16:19:33 +00:00
#### platform.http_proxy.enabled
Enable system HTTP proxy.
#### platform.http_proxy.server
==Required==
HTTP proxy server address.
#### platform.http_proxy.server_port
==Required==
HTTP proxy server port.
#### platform.http_proxy.bypass_domain
!!! note ""
On Apple platforms, `bypass_domain` items matches hostname **suffixes** .
Hostnames that bypass the HTTP proxy.
#### platform.http_proxy.match_domain
!!! quote ""
Only supported in graphical clients on Apple platforms.
Hostnames that use the HTTP proxy.
2022-07-10 08:41:38 +00:00
### Listen Fields
2023-12-14 14:23:52 +00:00
See [Listen Fields ](/configuration/shared/listen/ ) for details.