Tun on host doesn't work when namespace is used
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 38.1k
- Forks
- 4.6k
- Avg merge
- 19d 15h
- Merged PRs (30d)
- 1
Description
Operating system
Linux
System version
NixOS 26.11
Installation type
Original sing-box Command Line
If you are using a graphical client, please provide the version of the client.
No response
Version
sing-box version 1.14.1
Environment: go1.26.7 linux/amd64
Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale,with_ccm,with_ocm,with_cloudflared,with_usbip,with_openvpn,with_openconnect,badlinkname,tfogo_checklinkname0,with_naive_outbound
CGO: enabled
Description
The config:
{
"inbounds": [
{
"address": [
"172.19.0.1/30"
],
"strict_route": false,
"tag": "tun-in",
"type": "tun"
}
],
"network_namespaces": [
{
"type": "unshare",
"tag": "proxy",
"pid_file": "proxy.pid"
}
]
}
Get error
FATAL[0000] start service: start inbound/tun[tun-in]: configure tun interface: open tun: TUNSETIFF: operation not permitted
It works with a tun on host with on namespace or a tun in the namespace. But if there is a namespace then it can't setup the tun on host. It seems when it setup the namespace it loses all the caps.
Reproduction
Use
{
"inbounds": [
{
"address": [
"172.19.0.1/30"
],
"strict_route": false,
"tag": "tun-in",
"type": "tun"
}
],
"network_namespaces": [
{
"type": "unshare",
"tag": "proxy",
"pid_file": "proxy.pid"
}
]
}
without root.
Logs
Supporter
- I am a sponsor
Integrity requirements
- I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
- I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
- I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the minimal configuration with a tun inbound and an unshare network_namespaces entry on Linux without root. Trace how the host TUN interface is configured after namespace setup, comparing it with the working host-only and namespace-only cases; done means the host TUN initializes successfully while the namespace still behaves as configured.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, linux
- Domain
- networking, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100