Introduction to TUN Mode
What must TUN mode be?
The TUN device is a virtual network device. For the operating system, it is just like a physical network card (such as Wi-Fi or Ethernet card).
When we turn on the TUN Mode of Clash:
- Clash will create a virtual network card (usually named
clashorutun). - It modifies the system routing table to direct all traffic (or specific traffic) to this virtual network card.
- The traffic arriving at this virtual network card is taken over by the Clash core.
- Clash processes these data packets according to your rules (routing, proxying, blocking).
Why use TUN mode?
Usually, when we use System Proxy (HTTP/Socks5 Proxy), only software that "respects" system proxy settings will go through the proxy (such as browsers).
However, many softwares do not go through the system proxy by default, such as:
- Most command line tools (Terminal, CMD, PowerShell).
- Many games (they usually use UDP protocols or custom protocols).
- Some UWP applications (Windows unique app format).
- Virtual machines or other low-level network applications.
TUN mode solves this problem. Because it works at the network layer (Layer 3), it captures traffic directly from the network card level. Therefore, almost all software traffic will be forced to be processed by Clash, achieving true "Global Proxy" (or rule-based global takeover).
Prerequisites for use
To use TUN mode, you usually need:
- Administrator privileges: Creating network cards and modifying routing tables requires system permissions (Run as Administrator / Sudo).
- Service Mode (Service Mode): Modern Clash clients (such as Clash Verge Rev) recommend installing "Service Mode" to manage TUN devices in the background to ensure stability.
Common Problems
- DNS Pollution: In TUN mode, DNS resolution is heavily relied upon. Please make sure fake-ip is configured correctly or high-quality DNS servers are used.
- Conflict: It may conflict with other VPN software, game accelerators, or virtual machine network bridges. It is recommended to close other similar software when using it.
