mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-26 13:06:56 +00:00
Add netns and unshare support
This commit is contained in:
@@ -7,7 +7,8 @@ icon: material/new-box
|
||||
:material-plus: [include_mac_address](#include_mac_address)
|
||||
:material-plus: [exclude_mac_address](#exclude_mac_address)
|
||||
:material-plus: [dns_mode](#dns_mode)
|
||||
:material-plus: [dns_address](#dns_address)
|
||||
:material-plus: [dns_address](#dns_address)
|
||||
:material-plus: [netns](#netns)
|
||||
|
||||
!!! quote "Changes in sing-box 1.13.3"
|
||||
|
||||
@@ -197,6 +198,22 @@ icon: material/new-box
|
||||
|
||||
Virtual device name, automatically selected if empty.
|
||||
|
||||
#### netns
|
||||
|
||||
!!! question "Since sing-box 1.14.0"
|
||||
|
||||
!!! quote ""
|
||||
|
||||
Only supported on Linux.
|
||||
|
||||
Create the tun interface in the specified network namespace, name, path, or the tag of a
|
||||
[network namespace](/configuration/network-namespace/).
|
||||
|
||||
When set, `auto_route` and `auto_redirect` operate inside the namespace, and no root privilege is
|
||||
required if the namespace is owned by the current user.
|
||||
|
||||
Conflict with `platform`.
|
||||
|
||||
#### address
|
||||
|
||||
!!! question "Since sing-box 1.10.0"
|
||||
|
||||
@@ -7,7 +7,8 @@ icon: material/new-box
|
||||
:material-plus: [include_mac_address](#include_mac_address)
|
||||
:material-plus: [exclude_mac_address](#exclude_mac_address)
|
||||
:material-plus: [dns_mode](#dns_mode)
|
||||
:material-plus: [dns_address](#dns_address)
|
||||
:material-plus: [dns_address](#dns_address)
|
||||
:material-plus: [netns](#netns)
|
||||
|
||||
!!! quote "sing-box 1.13.3 中的更改"
|
||||
|
||||
@@ -199,6 +200,20 @@ icon: material/new-box
|
||||
|
||||
虚拟设备名称,默认自动选择。
|
||||
|
||||
#### netns
|
||||
|
||||
!!! question "自 sing-box 1.14.0 起"
|
||||
|
||||
!!! quote ""
|
||||
|
||||
仅支持 Linux。
|
||||
|
||||
在指定的网络命名空间中创建 tun 接口,可以是名称、路径,或[网络命名空间](/zh/configuration/network-namespace/)的标签。
|
||||
|
||||
设置后,`auto_route` 和 `auto_redirect` 在该命名空间内生效;若命名空间归当前用户所有,则无需 root 权限。
|
||||
|
||||
与 `platform` 冲突。
|
||||
|
||||
#### address
|
||||
|
||||
!!! question "自 sing-box 1.10.0 起"
|
||||
|
||||
@@ -11,6 +11,7 @@ sing-box uses JSON for configuration files.
|
||||
"certificate": {},
|
||||
"certificate_providers": [],
|
||||
"http_clients": [],
|
||||
"network_namespaces": [],
|
||||
"endpoints": [],
|
||||
"inbounds": [],
|
||||
"outbounds": [],
|
||||
@@ -30,6 +31,7 @@ sing-box uses JSON for configuration files.
|
||||
| `certificate` | [Certificate](./certificate/) |
|
||||
| `certificate_providers` | [Certificate Provider](./shared/certificate-provider/) |
|
||||
| `http_clients` | [HTTP Client](./shared/http-client/) |
|
||||
| `network_namespaces` | [Network Namespace](./network-namespace/) |
|
||||
| `endpoints` | [Endpoint](./endpoint/) |
|
||||
| `inbounds` | [Inbound](./inbound/) |
|
||||
| `outbounds` | [Outbound](./outbound/) |
|
||||
|
||||
@@ -11,6 +11,7 @@ sing-box 使用 JSON 作为配置文件格式。
|
||||
"certificate": {},
|
||||
"certificate_providers": [],
|
||||
"http_clients": [],
|
||||
"network_namespaces": [],
|
||||
"endpoints": [],
|
||||
"inbounds": [],
|
||||
"outbounds": [],
|
||||
@@ -30,6 +31,7 @@ sing-box 使用 JSON 作为配置文件格式。
|
||||
| `certificate` | [证书](./certificate/) |
|
||||
| `certificate_providers` | [证书提供者](./shared/certificate-provider/) |
|
||||
| `http_clients` | [HTTP 客户端](./shared/http-client/) |
|
||||
| `network_namespaces` | [网络命名空间](./network-namespace/) |
|
||||
| `endpoints` | [端点](./endpoint/) |
|
||||
| `inbounds` | [入站](./inbound/) |
|
||||
| `outbounds` | [出站](./outbound/) |
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "Since sing-box 1.14.0"
|
||||
|
||||
# Default
|
||||
|
||||
Attach to an existing network namespace.
|
||||
|
||||
### Structure
|
||||
|
||||
```json
|
||||
{
|
||||
"network_namespaces": [
|
||||
{
|
||||
"type": "default", // optional
|
||||
"tag": "",
|
||||
"path": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Fields
|
||||
|
||||
#### path
|
||||
|
||||
==Required==
|
||||
|
||||
Name or path of the network namespace, for example `sing` or `/run/netns/sing`.
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "自 sing-box 1.14.0 起"
|
||||
|
||||
# Default
|
||||
|
||||
附加到已存在的网络命名空间。
|
||||
|
||||
### 结构
|
||||
|
||||
```json
|
||||
{
|
||||
"network_namespaces": [
|
||||
{
|
||||
"type": "default", // 可选
|
||||
"tag": "",
|
||||
"path": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 字段
|
||||
|
||||
#### path
|
||||
|
||||
==必填==
|
||||
|
||||
网络命名空间的名称或路径,例如 `sing` 或 `/run/netns/sing`。
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "Since sing-box 1.14.0"
|
||||
|
||||
!!! quote ""
|
||||
|
||||
Only supported on Linux.
|
||||
|
||||
# Network Namespace
|
||||
|
||||
Network namespaces let inbounds and outbounds run inside a separate Linux network namespace,
|
||||
referenced by tag from the [tun](/configuration/inbound/tun/#netns),
|
||||
[Listen Fields](/configuration/shared/listen/#netns) and [Dial Fields](/configuration/shared/dial/#netns).
|
||||
|
||||
### Structure
|
||||
|
||||
```json
|
||||
{
|
||||
"network_namespaces": [
|
||||
{
|
||||
"type": "",
|
||||
"tag": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### type
|
||||
|
||||
The type of the network namespace, `default` is used by default.
|
||||
|
||||
| Type | Format |
|
||||
|-----------|------------------------|
|
||||
| `default` | [Default](./default/) |
|
||||
| `unshare` | [Unshare](./unshare/) |
|
||||
|
||||
#### tag
|
||||
|
||||
==Required==
|
||||
|
||||
The tag of the network namespace.
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "自 sing-box 1.14.0 起"
|
||||
|
||||
!!! quote ""
|
||||
|
||||
仅支持 Linux。
|
||||
|
||||
# 网络命名空间
|
||||
|
||||
网络命名空间使入站和出站可以运行在独立的 Linux 网络命名空间中,
|
||||
通过标签从 [tun](/zh/configuration/inbound/tun/#netns)、
|
||||
[监听字段](/zh/configuration/shared/listen/#netns) 和 [拨号字段](/zh/configuration/shared/dial/#netns) 引用。
|
||||
|
||||
### 结构
|
||||
|
||||
```json
|
||||
{
|
||||
"network_namespaces": [
|
||||
{
|
||||
"type": "",
|
||||
"tag": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### type
|
||||
|
||||
网络命名空间的类型,默认使用 `default`。
|
||||
|
||||
| 类型 | 格式 |
|
||||
|-----------|------------------------|
|
||||
| `default` | [Default](./default/) |
|
||||
| `unshare` | [Unshare](./unshare/) |
|
||||
|
||||
#### tag
|
||||
|
||||
==必填==
|
||||
|
||||
网络命名空间的标签。
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "Since sing-box 1.14.0"
|
||||
|
||||
# Unshare
|
||||
|
||||
Create a new network namespace, without root privilege.
|
||||
|
||||
!!! info ""
|
||||
|
||||
Rootless operation requires the kernel to allow unprivileged user namespace creation.
|
||||
|
||||
### Structure
|
||||
|
||||
```json
|
||||
{
|
||||
"network_namespaces": [
|
||||
{
|
||||
"type": "unshare",
|
||||
"tag": "",
|
||||
"pid_file": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Fields
|
||||
|
||||
#### pid_file
|
||||
|
||||
If set, the PID of the process holding the namespace open is written to this path.
|
||||
|
||||
The namespace can be entered with `nsenter -t <pid> -n` when sing-box is run as root,
|
||||
or `nsenter -t <pid> -U --preserve-credentials -n` otherwise.
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "自 sing-box 1.14.0 起"
|
||||
|
||||
# Unshare
|
||||
|
||||
创建一个新的网络命名空间,无需 root 权限。
|
||||
|
||||
!!! info ""
|
||||
|
||||
无 root 运行需要内核允许非特权用户创建 user namespace。
|
||||
|
||||
### 结构
|
||||
|
||||
```json
|
||||
{
|
||||
"network_namespaces": [
|
||||
{
|
||||
"type": "unshare",
|
||||
"tag": "",
|
||||
"pid_file": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 字段
|
||||
|
||||
#### pid_file
|
||||
|
||||
如果设置,持有该命名空间的进程 PID 将写入此路径。
|
||||
|
||||
当 sing-box 以 root 运行时,可通过 `nsenter -t <pid> -n` 进入该命名空间,
|
||||
否则使用 `nsenter -t <pid> -U --preserve-credentials -n`。
|
||||
@@ -4,7 +4,8 @@ icon: material/new-box
|
||||
|
||||
!!! quote "Changes in sing-box 1.14.0"
|
||||
|
||||
:material-alert: [domain_resolver](#domain_resolver)
|
||||
:material-alert: [domain_resolver](#domain_resolver)
|
||||
:material-alert: [netns](#netns)
|
||||
|
||||
!!! quote "Changes in sing-box 1.13.0"
|
||||
|
||||
@@ -118,6 +119,9 @@ Reuse listener address.
|
||||
|
||||
Set network namespace, name or path.
|
||||
|
||||
Since sing-box 1.14.0, the tag of a [network namespace](/configuration/network-namespace/) can also be used.
|
||||
Referencing an `unshare` network namespace should be avoided, since its only route out is the tun interface managed by sing-box itself.
|
||||
|
||||
#### connect_timeout
|
||||
|
||||
Connect timeout, in golang's Duration format.
|
||||
|
||||
@@ -4,7 +4,8 @@ icon: material/new-box
|
||||
|
||||
!!! quote "sing-box 1.14.0 中的更改"
|
||||
|
||||
:material-alert: [domain_resolver](#domain_resolver)
|
||||
:material-alert: [domain_resolver](#domain_resolver)
|
||||
:material-alert: [netns](#netns)
|
||||
|
||||
!!! quote "sing-box 1.13.0 中的更改"
|
||||
|
||||
@@ -118,6 +119,9 @@ icon: material/new-box
|
||||
|
||||
设置网络命名空间,名称或路径。
|
||||
|
||||
自 sing-box 1.14.0 起,也可以使用[网络命名空间](/zh/configuration/network-namespace/)的标签。
|
||||
应避免引用 `unshare` 类型的网络命名空间,因为其唯一出口是由 sing-box 自身管理的 tun 接口。
|
||||
|
||||
#### connect_timeout
|
||||
|
||||
连接超时,采用 golang 的 Duration 格式。
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! quote "Changes in sing-box 1.14.0"
|
||||
|
||||
:material-alert: [netns](#netns)
|
||||
|
||||
!!! quote "Changes in sing-box 1.13.0"
|
||||
|
||||
:material-plus: [disable_tcp_keep_alive](#disable_tcp_keep_alive)
|
||||
@@ -97,6 +101,8 @@ Reuse listener address.
|
||||
|
||||
Set network namespace, name or path.
|
||||
|
||||
Since sing-box 1.14.0, the tag of a [network namespace](/configuration/network-namespace/) can also be used.
|
||||
|
||||
#### tcp_fast_open
|
||||
|
||||
Enable TCP Fast Open.
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! quote "sing-box 1.14.0 中的更改"
|
||||
|
||||
:material-alert: [netns](#netns)
|
||||
|
||||
!!! quote "sing-box 1.13.0 中的更改"
|
||||
|
||||
:material-plus: [disable_tcp_keep_alive](#disable_tcp_keep_alive)
|
||||
@@ -97,6 +101,8 @@ icon: material/new-box
|
||||
|
||||
设置网络命名空间,名称或路径。
|
||||
|
||||
自 sing-box 1.14.0 起,也可以使用[网络命名空间](/zh/configuration/network-namespace/)的标签。
|
||||
|
||||
#### tcp_fast_open
|
||||
|
||||
启用 TCP Fast Open。
|
||||
|
||||
Reference in New Issue
Block a user