sing-box/docs/configuration/shared/dial.md
2024-11-24 15:12:18 +08:00

174 lines
4.5 KiB
Markdown

---
icon: material/new-box
---
!!! quote "Changes in sing-box 1.11.0"
:material-plus: [network_strategy](#network_strategy)
:material-alert: [fallback_delay](#fallback_delay)
:material-alert: [network_type](#network_type)
:material-alert: [fallback_network_type](#fallback_network_type)
### Structure
```json
{
"detour": "upstream-out",
"bind_interface": "en0",
"inet4_bind_address": "0.0.0.0",
"inet6_bind_address": "::",
"routing_mark": 1234,
"reuse_addr": false,
"connect_timeout": "5s",
"tcp_fast_open": false,
"tcp_multi_path": false,
"udp_fragment": false,
"domain_strategy": "prefer_ipv6",
"network_strategy": "default",
"network_type": [],
"fallback_network_type": [],
"fallback_delay": "300ms"
}
```
!!! note ""
You can ignore the JSON Array [] tag when the content is only one item
### Fields
#### detour
The tag of the upstream outbound.
If enabled, all other fields will be ignored.
#### bind_interface
The network interface to bind to.
#### inet4_bind_address
The IPv4 address to bind to.
#### inet6_bind_address
The IPv6 address to bind to.
#### routing_mark
!!! quote ""
Only supported on Linux.
Set netfilter routing mark.
#### reuse_addr
Reuse listener address.
#### tcp_fast_open
Enable TCP Fast Open.
#### tcp_multi_path
!!! warning ""
Go 1.21 required.
Enable TCP Multi Path.
#### udp_fragment
Enable UDP fragmentation.
#### connect_timeout
Connect timeout, in golang's Duration format.
A duration string is a possibly signed sequence of
decimal numbers, each with optional fraction and a unit suffix,
such as "300ms", "-1.5h" or "2h45m".
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
#### domain_strategy
Available values: `prefer_ipv4`, `prefer_ipv6`, `ipv4_only`, `ipv6_only`.
If set, the requested domain name will be resolved to IP before connect.
| Outbound | Effected domains | Fallback Value |
|----------|--------------------------|-------------------------------------------|
| `direct` | Domain in request | Take `inbound.domain_strategy` if not set |
| others | Domain in server address | / |
#### network_strategy
!!! question "Since sing-box 1.11.0"
!!! quote ""
Only supported in graphical clients on Android and Apple platforms with `auto_detect_interface` enabled.
Strategy for selecting network interfaces.
Available values:
- `default` (default): Connect to default network or networks specified in `network_type` sequentially.
- `hybrid`: Connect to all networks or networks specified in `network_type` concurrently.
- `fallback`: Connect to default network or preferred networks specified in `network_type` concurrently, and try fallback networks when unavailable or timeout.
For fallback, when preferred interfaces fails or times out,
it will enter a 15s fast fallback state (Connect to all preferred and fallback networks concurrently),
and exit immediately if preferred networks recover.
Conflicts with `bind_interface`, `inet4_bind_address` and `inet6_bind_address`.
#### network_type
!!! question "Since sing-box 1.11.0"
!!! quote ""
Only supported in graphical clients on Android and Apple platforms with `auto_detect_interface` enabled.
Network types to use when using `default` or `hybrid` network strategy or
preferred network types to use when using `fallback` network strategy.
Available values: `wifi`, `cellular`, `ethernet`, `other`.
Device's default network is used by default.
#### fallback_network_type
!!! question "Since sing-box 1.11.0"
!!! quote ""
Only supported in graphical clients on Android and Apple platforms with `auto_detect_interface` enabled.
Fallback network types when preferred networks are unavailable or timeout when using `fallback` network strategy.
All other networks expect preferred are used by default.
#### fallback_delay
!!! question "Since sing-box 1.11.0"
!!! quote ""
Only supported in graphical clients on Android and Apple platforms with `auto_detect_interface` enabled.
The length of time to wait before spawning a RFC 6555 Fast Fallback connection.
For `domain_strategy`, is the amount of time to wait for connection to succeed before assuming
that IPv4/IPv6 is misconfigured and falling back to other type of addresses.
For `network_strategy`, is the amount of time to wait for connection to succeed before falling
back to other interfaces.
Only take effect when `domain_strategy` or `network_strategy` is set.
`300ms` is used by default.