2022-07-10 16:41:38 +08:00
|
|
|
!!! error ""
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
"inbounds": [
|
|
|
|
{
|
|
|
|
"type": "tun",
|
|
|
|
"tag": "tun-in",
|
2022-08-08 20:57:50 +08:00
|
|
|
|
|
|
|
"interface_name": "tun0",
|
2022-07-10 16:41:38 +08:00
|
|
|
"inet4_address": "172.19.0.1/30",
|
|
|
|
"inet6_address": "fdfe:dcba:9876::1/128",
|
|
|
|
"mtu": 1500,
|
|
|
|
"auto_route": true,
|
2022-07-27 12:03:07 +08:00
|
|
|
"endpoint_independent_nat": false,
|
|
|
|
"udp_timeout": 300,
|
2022-08-08 20:57:50 +08:00
|
|
|
"stack": "gvisor",
|
2022-08-15 00:25:49 +08:00
|
|
|
"include_uid": [
|
|
|
|
0
|
|
|
|
],
|
|
|
|
"include_uid_range": [
|
|
|
|
[
|
|
|
|
1000,
|
|
|
|
99999
|
|
|
|
]
|
|
|
|
],
|
|
|
|
"exclude_uid": [
|
|
|
|
1000
|
|
|
|
],
|
|
|
|
"exclude_uid_range": [
|
|
|
|
1000,
|
|
|
|
99999
|
|
|
|
],
|
2022-08-15 11:40:49 +08:00
|
|
|
"include_android_user": [
|
|
|
|
0,
|
|
|
|
10
|
|
|
|
],
|
|
|
|
"include_package": [
|
|
|
|
"com.android.chrome"
|
|
|
|
],
|
|
|
|
"exclude_package": [
|
|
|
|
"com.android.captiveportallogin"
|
|
|
|
],
|
2022-08-01 17:02:13 +08:00
|
|
|
|
2022-07-10 16:41:38 +08:00
|
|
|
"sniff": true,
|
|
|
|
"sniff_override_destination": false,
|
|
|
|
"domain_strategy": "prefer_ipv4"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
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-07-10 16:41:38 +08:00
|
|
|
### Tun Fields
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
#### auto_route
|
|
|
|
|
|
|
|
Set the default route to the Tun.
|
|
|
|
|
|
|
|
!!! error ""
|
|
|
|
|
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-07-27 12:03:07 +08:00
|
|
|
#### endpoint_independent_nat
|
|
|
|
|
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
|
|
|
|
|
|
|
|
TCP/IP stack.
|
|
|
|
|
|
|
|
| Stack | Upstream | Status |
|
|
|
|
|------------------|-----------------------------------------------------------------------|-------------------|
|
|
|
|
| gVisor (default) | [google/gvisor](https://github.com/google/gvisor) | recommended |
|
|
|
|
| LWIP | [eycorsican/go-tun2socks](https://github.com/eycorsican/go-tun2socks) | upstream archived |
|
|
|
|
|
|
|
|
!!! warning ""
|
|
|
|
|
|
|
|
The LWIP stack is not included by default, see [Installation](/#Installation).
|
|
|
|
|
2022-08-15 00:25:49 +08:00
|
|
|
#### include_uid
|
|
|
|
|
|
|
|
!!! error ""
|
|
|
|
|
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
|
|
|
|
|
2022-08-15 11:40:49 +08:00
|
|
|
!!! error ""
|
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.
|
|
|
|
|
|
|
|
| Common user | ID |
|
|
|
|
|--------------|-----|
|
|
|
|
| Main | 0 |
|
|
|
|
| Work Profile | 10 |
|
|
|
|
|
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
|
|
|
|
2022-07-10 16:41:38 +08:00
|
|
|
### Listen Fields
|
|
|
|
|
|
|
|
#### sniff
|
|
|
|
|
|
|
|
Enable sniffing.
|
|
|
|
|
2022-07-17 15:11:26 +08:00
|
|
|
See [Sniff](/configuration/route/sniff/) for details.
|
2022-07-10 16:41:38 +08:00
|
|
|
|
|
|
|
#### sniff_override_destination
|
|
|
|
|
|
|
|
Override the connection destination address with the sniffed domain.
|
|
|
|
|
|
|
|
If the domain name is invalid (like tor), this will not work.
|
|
|
|
|
|
|
|
#### domain_strategy
|
|
|
|
|
|
|
|
One of `prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`.
|
|
|
|
|
|
|
|
If set, the requested domain name will be resolved to IP before routing.
|
|
|
|
|
|
|
|
If `sniff_override_destination` is in effect, its value will be taken as a fallback.
|