· Advanced · About 8 min read

How to Enable TUN Mode in v2rayN: Virtual Network Adapter Setup and Traffic Routing

Learn how TUN virtual adapters differ from system proxies, which apps need TUN, and how to configure permissions, DNS, and routing on Windows, macOS, and Linux.

At a glance

If your node works but an app ignores the system proxy, try TUN. First disable the system proxy, then enable the virtual adapter. Finally, test the target app, DNS resolution, and LAN access separately. If something fails, determine whether the adapter failed to start or the outbound connection failed before changing settings.

TUN Virtual Adapters vs. System Proxies

A system proxy is a setting that apps can read. Browsers and desktop apps that support it send requests to a local proxy port; apps that connect directly do not change their network path just because a system proxy is enabled. TUN works at the IP layer: the operating system routes matching packets to a virtual adapter, where the client reads them and applies rules to send them direct, through a proxy, or block them.

App connectionSystem routingVirtual adapterRule matchingOutbound selection

Apps that connect directly and offer no proxy options usually need a network-level capture method such as TUN. Common examples include command-line tools that ignore proxy environment variables and apps that use UDP. Capturing UDP packets does not guarantee they can be forwarded: the selected outbound, remote service, and network path must all support that traffic.

“Route all traffic” describes coverage, not where traffic goes. Packets received by the same virtual adapter can be sent direct or through a proxy, depending on the rules. Packets not routed to the adapter are not covered. Check IPv4 and IPv6 separately.

Decide whether to enable TUN based on the app

If only your browser needs a proxy and the system proxy works, keep your current setup. If the browser works but the target app still connects directly, disable the system proxy and test TUN with that app alone.

How to Enable TUN in v2rayN

  1. Verify the node first. Leave TUN off, select and activate a node, then use a browser that is already configured to visit a site you know works. If this baseline test fails, troubleshoot the node, network, and local listener first. A virtual adapter cannot fix a failed outbound connection.
  2. Temporarily clear the system proxy. Use the client’s “Clear system proxy” option, and check whether the test app has its own proxy settings. Terminal tools may also read http_proxy, https_proxy, or ALL_PROXY. For a clean test, make sure these settings do not send requests back to the local listening port.
  3. Enable “TUN”. Find the toggle at the bottom of the main window. To adjust individual options, look under “Settings” → “Parameter settings” for TUN-related settings; labels and layouts vary between builds. Keep the defaults for your first test, and don’t change routing, the network stack, and DNS all at once.
  4. Start fresh connections. Close existing connections in the test app and try again. Check the client logs for permission, adapter creation, or route installation errors. Test the target app, a commonly used domain, and a LAN service that was previously reachable. Don’t rely on whether a browser page loads as your only test.

Change only one variable at a time. If the system proxy and TUN are both enabled, a working webpage does not tell you whether the request went through the virtual adapter. If the local listener is at 127.0.0.1:10808, that is just an example port: connecting to it explicitly from a terminal tests the local proxy, not TUN. Check parameter settings for the actual port.

Check Permissions on Windows, macOS, and Linux

If you already use a corporate VPN or another virtual adapter, check your organization’s device management requirements before running a comparison test. Both tools may change the default route or DNS. Even if both show as running, that does not tell you which path is actually in use. Don’t disable security protections or change managed settings just to test.

DNS Settings and LAN Routing Tests

If only domain requests fail after enabling TUN, check the DNS resolution path first. The system resolver, an app’s encrypted DNS, and the client configuration may use different paths. Public DNS resolvers may not know your internal domains, so switching to public DNS is not a general fix for LAN issues.

Test a Public Domain

Test domain
example.com
Check the system
nslookup example.com
What to compare
Resolution status and DNS server before and after enabling TUN

Even if the system lookup succeeds, test the app itself; browsers may use a separate resolver.

Test LAN Access

Example address
192.168.1.1; use your actual gateway
What to test
A local service confirmed reachable before enabling TUN
Expected route
Direct, according to your local network requirements

If the address is reachable but an internal domain fails, check the internal DNS resolver and search domain first.

A DNS lookup returning an address does not guarantee that a connection to the destination will succeed. If resolution works but the connection still times out, revisit traffic routing settings and check which outbound matched and the order of the rules. Compare with a service known to support access by IP address. Don’t mistake certificate errors from opening an HTTPS site by raw IP for a network failure.

No Internet, No Effect, or TUN Won’t Turn Off

No connection right after enabling TUN? Check this first

Turn TUN off and confirm that the connection recovers. Then enable it once more and note the first error in the logs. If the adapter was not created, check the device and permissions. If it was created but the node’s outbound connection times out, check whether traffic to the node’s address is being routed back into the virtual adapter. Don’t change the node and DNS at the same time.

Why does my terminal app fail when the browser works?

Make sure the browser isn’t still using a separate proxy, then open a new terminal session and check its proxy environment variables and the tool’s own proxy settings. Start a new connection with the target command and check whether the logs show the destination and outbound. If not, check whether TUN includes routes for that destination’s address family.

What if the network still doesn’t work after turning off TUN?

Exit the client normally and check whether the system proxy still points to a local port that is no longer listening. Compare the routes and DNS settings with the notes you made before starting. If an app is holding an old connection, restart it and test again. If managed network settings haven’t been restored, save the logs and contact your administrator; don’t reset network adapters blindly.

Why do real-time connections time out when websites load?

A website loading successfully does not prove that UDP traffic works. First confirm which transport the target app uses, then check whether its traffic matches the expected rule and whether the selected outbound supports UDP. Don’t use ordinary webpage load times to judge a real-time connection.

Download and Install the Client