How It Works 8 min read

TUN mode vs. system proxy: traffic coverage, DNS, and when to use each

Compare how system proxies and TUN adapters handle traffic, why some apps bypass system proxy settings, and how fake IP works.

Traffic coverage: apps using proxy settings vs. traffic routed through a virtual adapter

A system proxy is a setting that applications can use. In Windows 11, for example, open Settings → Network & internet → Proxy, then check the proxy address and port under Manual proxy setup. When a client enables the system proxy, it usually points this setting to its local proxy listening port. Browsers that honor the setting connect to the local proxy first, and the core handles the request from there. Apps with their own proxy configuration follow their own settings instead.

TUN provides another way in. With mihomo, for example, the core receives IP traffic routed by the operating system through a virtual network adapter. This can bring traffic into the core even when an app doesn't use the system proxy settings. The actual coverage depends on the active routes and exclusions. Another VPN, an adapter bound to an app, or a separately configured subnet route can all change where packets go.

Comparison System proxy TUN mode
Traffic entry point App connects to the local proxy port System routes packets through the virtual adapter
Common reasons traffic bypasses it Command-line tools use their own proxy settings; apps connect directly to servers Destination subnet is excluded; another VPN controls the route to the destination
UDP apps A standard HTTP system proxy does not capture UDP packets sent directly by apps Can receive UDP traffic routed through the virtual adapter; proxying it also requires UDP support from the outbound protocol and node

DNS handling: system proxy, DNS hijacking, and fake IP

A system proxy does not take over DNS for the entire device

When a browser accesses HTTPS through an HTTP proxy, it typically sends a CONNECT request containing the destination domain and port, such as CONNECT example.com:443. The proxy can match rules using the domain in the request; which end resolves it depends on the outbound method selected by the core. Other apps' DNS requests are not automatically sent to the same proxy port just because the system proxy is enabled.

TUN DNS hijacking applies only to matching traffic

mihomo's tun.dns-hijack sends matching DNS requests that enter TUN to the built-in DNS resolver. When checking the configuration, first confirm that the app's queries actually pass through the virtual adapter, then check which protocols and ports the hijack settings cover. Standard DNS usually uses UDP port 53, though it can also use TCP port 53. If a browser's secure DNS sends queries over HTTPS on port 443, a hijack rule matching port 53 will not treat it as a standard DNS request. Even when that HTTPS connection enters TUN, the core cannot read the query inside the encrypted request.

Fake IP preserves domain names through address mapping

  1. An app looks up example.com. When the request reaches mihomo's built-in DNS resolver, if fake-ip mode is enabled and the domain isn't filtered, the core returns a mapped address, such as 198.18.0.2.
  2. The app connects to that address. If the connection then enters the same core, the core can look up example.com in the mapping and continue choosing an outbound based on the domain rules.
  3. The outbound uses the real destination; the actual DNS resolution depends on the selected outbound and DNS configuration. The example address is not the website's public IP or a proxy node.

fake-ip is a DNS enhanced-mode, not another name for TUN. TUN also works with redir-host, which returns real addresses. If only an internal domain fails with fake IP, first check that the computer is using the correct internal DNS. Then consider excluding only that domain with fake-ip-filter. After making a change, have the app query again; its old cache may still point to the previous address.

Choosing a mode: decide based on the apps you use—you don't need both

  • For browsers and desktop apps that honor the system proxy: Start with the system proxy. It avoids changing the virtual adapter or routes and makes it easier to identify which app connection is having trouble. A working webpage only confirms that this particular route works.
  • If just one command-line tool bypasses the proxy: Check whether it supports --proxy or proxy environment variables. If you can configure it in the command, there's no need to change routing for the entire device just for one tool.
  • If several apps connect directly, or you need to handle UDP: Try TUN. First make sure the client can create a virtual adapter and apply routes, then check whether the target connection reaches the core. For voice or gaming apps, note the connection protocol and outbound: a node that proxies web traffic may not forward UDP.
  • If you're connected to a company VPN or regularly use a printer or NAS: Preserve the existing routes where possible. When testing TUN, try a regular webpage and an internal service that was reachable before. If an internal domain fails, compare it with direct access to a known internal IP to distinguish a routing issue from a name resolution issue.

For troubleshooting, enable only one traffic entry method at a time. If both switches are on, the browser may still enter through the local proxy port; a working webpage doesn't confirm that the virtual adapter is handling traffic. To test TUN by itself, also clear the test app's own proxy settings and start a new connection so you don't reuse an existing session.

Verify traffic capture: compare connection logs with two commands

On Windows 11, you can use curl.exe in PowerShell for comparison. These examples assume the client's HTTP or mixed port listens on 127.0.0.1:7890. If the client shows a different port, use that value instead. Don't enter a SOCKS-only port here.

curl.exe -v --noproxy localhost --proxy http://127.0.0.1:7890 https://example.com/
curl.exe -v --noproxy "*" https://example.com/
  1. Turn off TUN and run the first command. The command explicitly uses the local proxy and sets the proxy bypass list to localhost, so the request to example.com still goes through the proxy. Check whether the output shows an attempt to connect to 127.0.0.1:7890, then look for the domain in the client's connections or logs. If the local port refuses the connection, first check the listening port and core status.
  2. Turn off the system proxy, enable TUN by itself, and run the second command. --noproxy "*" prevents curl from using an application-layer proxy, but it doesn't stop the operating system from routing packets through the virtual adapter. Check the connection logs from the same time for the domain or destination IP, then verify the rule and outbound. A successful response without a matching inbound record isn't enough to confirm that TUN is working.
  3. Turn TUN off and run the second command again. Use this result as a baseline. If the website still opens, that only shows that the current network has a working route. If enabling TUN produces a matching inbound record in the core, you can link the difference to the traffic entry method. For short-lived web requests, check the logs rather than relying only on the current connections list.

No internet after enabling TUN: check traffic entry, DNS, and outbound

  1. No matching connection record: Check the client logs for errors creating the virtual adapter or applying routes, then see whether another VPN is controlling the same route. On Windows, run route print to inspect the interfaces and routing table. Don't just check for a new default route—also look for more specific routes to the destination subnet.
  2. The app reports a DNS lookup failure: Run nslookup example.com to see the system's default resolver response. This command doesn't test the browser's secure DNS path. If it succeeds but the browser still fails, check the browser's DNS settings. With fake IP, getting a mapped address isn't itself an error; next, confirm whether the app's connection to that address reaches the core.
  3. A connection record exists, but the request times out: Check the matched rule and final outbound. If traffic that should use a proxy group matches DIRECT, review the rule order. If it uses the expected proxy group, compare it with another known-working outbound. If only UDP fails, check UDP forwarding separately instead of repeatedly changing DNS.

Change one setting at a time, then retest with the same domain and command. Note the inbound, matched rule, and final outbound to distinguish between traffic not reaching the core, incorrect domain resolution, and an outbound connection failure.

Download Clash