tun2socks: The Universal TUN-to-Proxy Bridge

tun2socks: The Universal TUN-to-Proxy Bridge

tun2socks is a lightweight, high-performance tool that creates a virtual network interface (TUN device) on your system to transparently redirect all network traffic through a specified proxy server. By leveraging the gVisor TCP/IP stack (a user-space network stack originally developed by Google for sandboxing), it handles packet processing efficiently without requiring kernel-level modifications or root privileges in many configurations.

What it does:

  1. Transparent Proxying: It captures all IP packets from your device (regardless of which application sends them) and forwards them through a proxy (like SOCKS5, HTTP, Shadowsocks, or SSH). This means you don’t need to configure each app individually; everything goes through the tunnel automatically.
  2. Protocol Agnosticism: It supports multiple proxy backends, allowing you to use it with various privacy or bypass tools (e.g., routing traffic through a Shadowsocks server for censorship circumvention or an SSH tunnel for secure remote access).
  3. Cross-Platform & Lightweight: Written in Go, it’s easy to deploy on Linux, macOS, Windows, Android, and iOS. It’s often used in mobile VPN apps (like Clash or Sing-box) and desktop routing setups because it’s faster and more stable than older solutions like redsocks.

In simple terms: It acts as a universal "bridge" between your device’s network traffic and any proxy server, making it look like your traffic is coming from the proxy’s location while keeping the setup simple and efficient.

Features

  • Universal Proxying: Transparently routes all network traffic from any application through a proxy.
  • Multi-Protocol: Supports HTTP/SOCKS/Shadowsocks/SSH/Relay proxies with optional authentication.
  • Cross-Platform: Runs on Linux/macOS/Windows/FreeBSD/OpenBSD with platform-specific optimizations.
  • Gateway Mode: Acts as a Layer 3 gateway to route traffic from other devices on the same network.
  • Full IPv6 Compatibility: Natively supports IPv6; seamlessly tunnels IPv4 over IPv6 and vice versa.
  • User-Space Networking: Leverages the gVisor network stack for enhanced performance and flexibility.

License

MIT License

Resources & Downloads

GitHub - xjasonlyu/tun2socks: tun2socks - powered by gVisor TCP/IP stack
tun2socks - powered by gVisor TCP/IP stack. Contribute to xjasonlyu/tun2socks development by creating an account on GitHub.