Configuration Featured Clash Beginner Guide Clash vs VPN Proxy Basics

Clash TUN for Developers: Route Git and CLI Traffic Reliably

November 24, 2026 Updated November 24, 2026 Approx. 12 min read

Why Developers Use TUN Mode

A browser can work perfectly through Clash while git, SSH, package managers, and other command-line tools still fail. The reason is that a browser may use the operating system’s HTTP or SOCKS proxy settings, while many terminal programs do not. They open network connections directly and never consult the proxy settings configured in a browser or desktop app.

TUN mode addresses this difference by creating a virtual network interface and routing selected device traffic through the Clash core. Instead of asking each application to understand proxy settings, the operating system sends eligible network traffic to the tunnel. This can make command-line tools work without adding proxy-specific options to every command.

This guide uses Mihomo, the core commonly bundled with Clash Verge Rev and other current Clash clients. Labels and setup flows vary between clients and operating systems, so treat the examples as a practical checklist rather than a promise that every interface has identical buttons. Use a configuration and proxy service you are authorized to use, and follow any organization network policies that apply to your device.

The Goal

Route developer traffic predictably, verify that Git and SSH are using the intended path, and identify whether a failure comes from TUN permissions, DNS, routing rules, or the remote service.

1Understand What TUN Does—and Does Not Do

TUN mode operates below the application’s proxy interface. The Clash core receives network packets through a virtual adapter, evaluates them against its routing rules, and sends them either directly or through a selected proxy policy. That is why a terminal application that ignores system proxy variables may still be routed by TUN.

TUN is not the same as turning on a browser proxy, and it does not automatically mean that every connection uses a remote node. In Rule mode, the final route depends on the matching rules and their order. A domain can be sent to a proxy group, connected directly, or rejected. In Global mode, traffic is generally directed through the selected proxy policy, subject to the client and core configuration. Choose the mode that matches your needs instead of assuming TUN itself selects a route.

Also distinguish routing from application configuration. TUN can capture a connection, but a command may still fail because its destination is unreachable, its credentials are invalid, DNS returns an unusable address, or the remote host blocks the connection. A successful browser test alone does not prove that the terminal is using the expected route.

Pro Tip: Change One Layer at a Time

When testing, keep the active profile and proxy node fixed. First confirm that TUN is enabled, then inspect the route, and only afterward adjust DNS or application settings. Changing several layers together makes the cause of a failure much harder to identify.

System Proxy vs. TUN

A system proxy typically sets HTTP or SOCKS proxy details for applications that support those settings. It is lightweight and often sufficient for browsers and desktop applications. TUN creates a virtual interface and can handle connections from applications that do not read those proxy settings. The two features may be enabled together in some clients, but they serve different purposes; using both does not automatically improve connectivity.

For a developer workflow, begin with the smallest setup that works. If Git and your other terminal tools already honor configured proxy variables, you may not need TUN. If they bypass those settings, TUN is a reasonable option, provided your operating system and client can create and manage the virtual interface.

2Enable TUN Safely in Your Clash Client

Before switching TUN on, update the client and core from a trusted distribution source, select the profile you intend to use, and confirm that at least one proxy group has a working choice. Keep a copy of the current configuration or know how to revert the change. A tunnel that starts successfully but has no usable route can make ordinary network troubleshooting confusing.

In Clash Verge Rev, the TUN control is commonly found in the settings area, though wording and location may differ by release. Enable TUN, approve the operating-system permission prompt if one appears, and allow the client to create its virtual adapter. On other Mihomo-based clients, look for the TUN or virtual-interface option. Avoid editing unrelated profile settings just to expose the toggle.

Platform Permissions and Common Prompts

  • Windows: The client may request administrator approval to create or configure a virtual network adapter. Approve the prompt only for the client you intended to launch. If the adapter cannot be created, check the client’s status and Windows security prompts before repeatedly reinstalling it.
  • macOS: macOS may request permission to add a VPN or network extension. Review the system prompt and approve the extension for the expected application. A missing or blocked extension can prevent TUN from starting even when the client window reports that the option is enabled.
  • Linux: TUN setup depends on access to the TUN device and network configuration permissions. The exact permission model varies by distribution and installation method. Prefer the client’s documented permission setup over running the entire desktop application as root.

After enabling the feature, check the client’s status or logs for a successful TUN initialization message. Then verify that the virtual interface exists using the operating system’s network settings. The interface name is not universal, so do not use a specific name as the only success criterion. If the client reports a permission error, stop there and resolve that error before changing routing rules.

Do Not Elevate Everything

Running a GUI client or a shell as administrator or root can create security and file-permission problems. Use the client’s documented TUN permission flow, and grant only the operating-system privileges needed to manage the tunnel.

Review the Core Configuration

If you manage a Mihomo YAML profile directly, TUN settings are typically placed under a top-level tun key. Exact supported options depend on the core version and client integration, so use the documentation for the version you run. A minimal example to discuss the main controls is:

tun: enable: true stack: mixed auto-route: true strict-route: false

Do not paste this block blindly into a profile that already has a tun section. Merge settings carefully and avoid duplicate top-level keys. The stack mode and route behavior may need to differ by platform. If your client manages TUN settings through its interface, prefer that method so it can apply its platform-specific defaults.

3Route Git, SSH, and Developer Tools Predictably

Once the tunnel is running, decide how developer connections should be routed. In Rule mode, inspect the active profile’s rules and the selected policy group. A common arrangement is to route code-hosting domains through a proxy group while leaving private network ranges and local development services direct. There is no universally correct rule: a company Git server may need a direct route through a corporate network, while a public service may need a different path.

Rules are evaluated in order. A broad rule placed above a more specific one may capture traffic before the intended rule is reached. If your profile already contains managed rule providers, avoid editing generated rules without understanding how updates are applied. Use the client’s supported override or merge mechanism where available, then confirm the actual matched rule in the connection or log view.

# Illustrative examples only: adapt the target domains and policy name - DOMAIN-SUFFIX,code.example,Developer - DOMAIN-SUFFIX,git.example,Developer - IP-CIDR,10.0.0.0/8,DIRECT,no-resolve - MATCH,YourDefaultPolicy

Developer and YourDefaultPolicy are illustrative policy names, not built-in groups. Replace them with names that exist in your profile. The private address rule is only appropriate if those destinations should be reached directly on your network. Do not add private-range rules indiscriminately on a device that uses overlapping networks or a required corporate tunnel.

Check Git and SSH Separately

Git operations over HTTPS usually connect to a service hostname and port 443. SSH remotes commonly connect to port 22, although hosting providers and organizations may use a different hostname or port. TUN can route both kinds of connections, but each may match a different rule. For a useful test, note the repository’s remote format and inspect the destination shown in Clash when you run a single, low-impact Git operation.

Check the configured remote before changing proxy settings:

git remote -v git ls-remote origin

git remote -v shows whether the remote uses HTTPS or SSH. git ls-remote origin tests whether Git can contact the remote and read its references without cloning the repository. If the first command works but the second fails, inspect the client’s connection log for the destination, matched rule, and selected policy. Avoid sharing logs publicly until you have removed credentials, tokens, private hostnames, and other sensitive details.

For SSH, test the connection to the actual host used by your remote, and remember that authentication errors are different from network errors. A timeout or connection refusal points toward reachability, port, or route issues; a key or account denial means the server was reached but did not accept the authentication. Do not weaken SSH host-key verification to make a connection succeed.

DNS and Package Managers

DNS can affect the route before an application connects. If a hostname resolves differently on the local network and through the configured DNS path, the client may show a destination that does not match the rule you expected. Check that DNS is enabled and configured according to the profile’s design, then compare the resolved hostname with the connection log. Avoid adding public DNS servers at random: DNS behavior should match your privacy requirements and any network policy.

Package managers may contact several domains for metadata, downloads, registries, and redirects. A successful request to the main registry does not prove that every file host is reachable. Use the package manager’s own diagnostic output and the Clash connection list to identify the failing hostname, then adjust only the rule that is actually needed.

4Verify the Route from the Terminal

Use a repeatable sequence instead of testing everything at once. First confirm that the selected proxy node works in the client. Next enable TUN and verify that the client reports a healthy tunnel. Then test name resolution and a simple connection to the intended destination. Finally, test Git or SSH. If a step fails, the previous successful step narrows the likely cause.

A Practical Diagnostic Sequence
  1. Confirm the profile is active and the proxy group has a selected, reachable node.
  2. Enable TUN and check the client log for initialization or permission errors.
  3. Open the connection view, run one terminal request, and confirm that a new connection appears.
  4. Check the destination, matched rule, and policy shown for that connection.
  5. Repeat the test using the actual Git remote or SSH host, then compare the result with the simpler connection test.

On macOS or Linux, commands such as curl -I https://example.com can provide a basic HTTPS connectivity check, while getent hosts example.com is available on many Linux systems for checking name resolution. On Windows, PowerShell’s Test-NetConnection can help test a host and port. These commands are diagnostic aids, not proof that a particular application used a particular route; confirm the connection in the Clash client as well.

Environment variables such as HTTP_PROXY, HTTPS_PROXY, and ALL_PROXY are a separate mechanism. Some command-line tools honor them, some do not, and their syntax and support vary. When TUN is active, avoid setting proxy variables unnecessarily during initial testing, since the application may then use an explicit proxy on top of the system tunnel. If you already rely on these variables, record their values and test with a clean shell before concluding that TUN is broken.

Pro Tip: Read the Connection Log

The most useful evidence is often the connection entry created at the moment of failure. It can show whether the request reached the core, which rule matched, and which policy was selected. A missing entry suggests a capture or application-path issue; an entry with an unexpected route points toward rule order or policy selection.

5Troubleshoot Common TUN Problems

When a command fails, separate the symptoms before changing configuration. Is the tunnel not starting, is the connection missing from the client, is DNS failing, or is the remote rejecting the request? These are different failure classes and often require different fixes.

Symptom Likely cause First check
TUN will not start Permission prompt was denied, virtual interface setup failed, or another network tool conflicts Review the client log and operating-system permission status
Browser works, terminal does not TUN is off, the application is not captured, or a system proxy is being mistaken for TUN Look for the terminal connection in Clash’s connection view
Connection appears but uses the wrong route A broader rule matched first, or the selected policy is not the intended one Inspect the matched rule and policy; review rule order
Hostname fails but an IP test behaves differently DNS configuration, resolution, or a hostname-specific rule may be involved Check the resolved address and the client’s DNS and connection logs
SSH reaches the server but authentication fails SSH key, account, host key, or server-side access issue Verify the remote URL and SSH authentication without disabling host-key checks
Some downloads fail after metadata loads A redirected file host or secondary domain follows a different route Identify the failing destination in the client log before changing rules

If TUN starts but ordinary connectivity stops, turn it off from the client and restore the previous known-good profile or routing mode. Check whether another VPN, firewall, endpoint security tool, or network extension is also managing routes. Multiple network filters can compete, and repeatedly toggling settings without recording the result can make the problem harder to reverse.

If only one repository fails, confirm that its hostname and port are correct and that the corresponding policy group has a usable selection. If many unrelated destinations fail, investigate the tunnel, DNS, and default rule before adding service-specific rules. Keep a short change log: record the setting changed, the test performed, and the observed result. This makes it easier to remove an ineffective override later.

For managed work devices, consult your organization’s network administrator before changing routes or adding exclusions. Split routing can be useful, but it must not bypass required security controls or expose internal traffic to an unintended proxy. Once the workflow is stable, test both the destinations that should use the proxy and the internal or local destinations that should remain direct.

Download Clash →