TUN vs. System Proxy: How Traffic Flows

A system proxy provides a local proxy address to apps that support the setting. For example, when the system proxy points to 127.0.0.1:7890, apps that read and honor the setting connect to that port. Apps that open sockets directly and send data to destination addresses still use the system routing table. 7890 is just an example; check the current configuration for the actual listening port.

On desktop systems, TUN receives IP packets through a virtual layer 3 network interface. System routes determine which packets enter the interface, and the client’s core then forwards matching connections according to its rules and selected policies. On phones using VPN mode, which apps or destination addresses enter the tunnel also depends on the system interface and client configuration.

What TUN Captures
This depends on routes, address families, exclusions, and platform permissions. Check LAN access, IPv6, and traffic from existing VPNs separately.
Rule Mode vs. Global Mode
These modes determine how connections entering the core are routed. In rule mode, a connection can match DIRECT and connect straight to its destination even after entering TUN. You can keep rule mode enabled while using TUN.

When troubleshooting an app that appears to bypass the proxy, first check whether its connection reached the core, then see which rule it matched. These checks distinguish traffic capture from route selection.

How to Enable TUN on Windows, macOS, and Linux

Save your current configuration first, and note the original system proxy, TUN, and DNS settings. For desktop clients built on mihomo, check the core information page to confirm the core and version actually in use—don’t confuse the GUI version with the core version. For subscription configs, use the client’s local override feature where possible, so a subscription refresh won’t overwrite your changes. Keep the current policy group unchanged during initial testing, and change one relevant setting at a time.

  1. Windows: Close the app you’re testing. Go to Settings → Network & internet → Proxy and note the current system proxy settings. Then find the TUN mode or virtual adapter toggle in your client’s settings. If your version asks to install a service, authorize it before enabling TUN. In PowerShell, run Get-NetIPInterface to compare the interface list before and after. On managed devices, ask your administrator whether interface creation and route changes are allowed.
  2. macOS: Enable TUN in the client settings and follow the prompts to authorize its helper or approve the system request. If the client uses a network extension, check its status under System Settings → General → Login Items & Extensions on macOS versions that provide this option. Implementations that create an utun interface directly may not have a corresponding extension entry. Compare interfaces before and after with ifconfig. An existing utun may belong to another service, so its presence alone doesn’t confirm that traffic is being captured.
  3. Linux: Native mihomo typically needs access to /dev/net/tun, and processes that configure interfaces and routes also need the appropriate network management permissions. If you use a distribution service or a client-provided service mode, check the service logs first, then inspect interfaces and policy routing with ip link show and ip rule show. If you see a permissions error, check the service permissions and whether the runtime provides a TUN device. An interface inside a container doesn’t mean host traffic is routed through it.

VPN Traffic Capture on Android and iOS

  • Android: In a client that supports VPN mode, select a profile and connect, then approve the system VPN connection request. If only one app isn’t being captured, check the client’s per-app proxy list first: allowlists and exclusion lists work in opposite ways. Search for “VPN” in system settings and check the VPN status for the current user or work profile, especially the “Always-on VPN” setting used by older clients.
  • iOS: Connect using a client that supports the relevant protocol and configuration format, allow it to add a VPN configuration when prompted, then check the connection under Settings → General → VPN & Device Management → VPN. Traffic coverage depends on the client’s Network Extension implementation and system policies. Desktop fields such as tun.stack, auto-route, and DNS apply only if the mobile client explicitly supports them.

A VPN-connected status only confirms that the tunnel is established. To check whether an app uses a direct or proxy route, review the client’s connection details or use the app itself to access a test address whose result you can verify.

Configure stack, auto-route, and DNS hijacking

This desktop example uses fields from the mihomo 1.19 series. Merge it into the top-level tun section of your current configuration; don’t replace the entire subscription. If the client has a TUN toggle or an override layer, reload and check the effective running configuration. Avoid changing the same field in both places.

tun:
  enable: true
  stack: mixed
  auto-route: true
  auto-detect-interface: true
  dns-hijack:
    - 'any:53'
    - 'tcp://any:53'
mihomo TUN fields and checks
FieldPurposeWhat to check
stack mixed uses the system stack for TCP and gVisor for UDP. You can also choose system or gvisor. If only UDP apps are affected, first confirm that the proxy node and policy support UDP, then switch the stack and test again.
auto-route Routes matching the configured scope are directed into TUN by the core. After enabling it, test public internet access, LAN access, and IPv6 separately. Working traffic in one category doesn’t mean the others are covered.
auto-detect-interface Automatically detects the outbound interface. If Ethernet, Wi-Fi, and another VPN are in use, recheck the outbound route after switching networks.
dns-hijack Passes matching traditional DNS requests entering TUN to the core’s DNS module. The examples match both UDP and TCP on port 53. Check the existing dns.enable and upstream resolver settings, and preserve the current resolution policy for local domains.

Matching port 53 won’t convert DoH over HTTPS or DoT over TLS into regular DNS for the core to handle. Browser Secure DNS and Android Private DNS can change the resolution path. On Windows and macOS, queries sent to a LAN DNS server may also bypass TUN. If DNS fails in only one app, first check which resolver it actually uses, then decide whether to change dns-hijack.

Verify Traffic Capture, Troubleshoot, and Roll Back

Compare the same connection with TUN on and off

  1. On a desktop where you can test safely, temporarily disable the system proxy in the client and any proxy configured in the target app. Keep rule mode and the selected node unchanged. Quit and reopen the app to avoid reusing existing connections.
  2. Send a request with TUN off, then turn TUN on and send another request to the same address. Note the time and compare the destination, matched rule, and outbound route in the client’s Connections or Logs view. A TCP web request only verifies the corresponding TCP route. To troubleshoot UDP, use a real UDP operation in the target app.
  3. To confirm that your public egress has changed, check a verifiable result in the target app and match it to the connection log. If the egress IP is unchanged but the connection appears and matches DIRECT, TUN is likely capturing the traffic and the current rule is routing it directly.

Narrow down the cause by symptom

  • No connection appears after enabling TUN: First confirm that the new request was actually sent. Then check whether the interface was created, routes were installed, and the destination or app was excluded. If the issue occurs only over IPv6, check IPv6 capture separately.
  • Connection appears, but only domain names fail: Check that the DNS module is enabled, upstream resolvers are reachable, and local domains still use their original resolver. Don’t use direct access to a website’s HTTPS IP address to diagnose DNS; certificate validation and site identification can cause failures too.
  • LAN printers or office services become unreachable: Test the device address and hostname separately. If only the hostname fails, check LAN DNS or device discovery first. If the address is unreachable too, check routing. For a device address such as 192.168.1.50, confirm your actual LAN subnet before adding exclusions. Excluding all private addresses may affect other networks.

To restore network access, turn off TUN first, then remove routes and DNS overrides added during this test and restore the original system proxy settings. Reload the original configuration and reopen the app, then test public internet access and local services separately. If both work again, re-enable settings one at a time to identify which change caused the issue.