Which layer failed: device, route, or DNS
"TUN is on" only tells you the core asked the system for a tun device. It says nothing about whether the system then sends traffic into it. Three layers fail separately and produce three different symptoms.
- Device layer. No adapter appears at all. The core log shows a tun creation error, or nothing about tun. Nothing downstream can work.
- Route layer. The adapter exists but the default route still points at the physical card. Applications keep using the old path, so behaviour is unchanged — which looks like "TUN did nothing" rather than "TUN failed".
- DNS layer. Traffic is routed into the device, but name resolution happens outside it or is answered by the wrong resolver. Pages fail on the first request while a direct IP sometimes still loads.
Separate them with three commands before touching configuration. On Linux:
ip link show | grep -i -E "tun|utun|mihomo"
ip route show default
resolvectl status | head -20
On macOS, ifconfig | grep -A3 utun, netstat -rn | grep default, and scutil --dns | head -30. On Windows, Get-NetAdapter | Where-Object Status -eq "Up", route print 0.0.0.0, and nslookup example.com. Whichever layer is wrong first is the one to work on; the others are noise until it is right.
The three tun keys that decide capture
A working block in current mihomo looks like this. The values shown are the ones that make capture possible; anything missing changes behaviour silently.
tun:
enable: true
stack: system
auto-route: true
auto-detect-interface: true
dns-hijack:
- any:53
auto-route. When false, the device is created but no route is installed. This is the single most common reason "TUN is on" produces no change: the setting was meant for a router or a manual routing setup, and on a desktop it leaves the default route untouched. If your default route still points at the physical adapter, this is the first thing to check.
dns-hijack. Without it, DNS queries leave through the physical interface and are answered by whatever resolver the system had before. The proxy then sees a connection to an IP it never resolved, rules that match on domain do not fire, and some clients fail outright. any:53 catches plain DNS on port 53; DNS over HTTPS on 443 is a separate path and is not intercepted by this key.
stack. Selects which TCP/IP implementation handles the captured packets — system uses the host stack, gvisor a user-space one, mixed a combination. It does not decide whether traffic is captured, but it decides whether the captured traffic behaves correctly, which is why a stack change can turn "connected but nothing loads" into a working connection, or the reverse.
Check in this order; do not edit system files first
- Adapter present? If not, stop here. The problem is device creation — driver, permission, or an existing adapter with a conflicting name — not routing.
- Default route on the adapter? Compare the route table before and after enabling TUN. No change means
auto-routeis off or failed; the log usually records the failure. - DNS answered from inside? Query a name and watch which resolver answers. If the answer arrives from the pre-existing DNS server,
dns-hijackis missing or the system resolver is being bypassed. - Outbound connection in the log? With route and DNS correct, the core log should show a connection entry for your test request. No entry means the rule set rejected the traffic or the request never entered the device.
- Only then look at the node and the subscription. A node problem shows as a failed dial after a connection entry exists, which is a different line in the log.
One change per test. If you change the stack and the rule set in the same step, a working result tells you nothing about which one mattered, and the next occurrence starts from zero.
Why "connected but no internet" reads differently per stack
On system, the host stack processes packets the core writes back. Behaviour therefore depends on host firewall rules and on kernel features the platform actually provides. A host firewall that inspects forwarded traffic can silently drop the return path while the forward path works — the connection appears established and nothing comes back.
On gvisor, the user-space stack owns that processing. Host firewall inspection of the same traffic often does not apply, which is why gvisor fixes some cases and breaks others. UDP-heavy workloads, fragmented packets and applications that make assumptions about path MTU are the usual regressions.
The practical rule: if the symptom is "TCP connects, data does not return", try the other stack once and compare the same request. If the symptom is "nothing is captured at all", the stack is not your problem — go back to route and DNS.
Platform differences at the adapter step
Windows. TUN needs the wintun driver. If it is missing or blocked, device creation fails before any routing question exists. Check the adapter list for a device in an error state rather than assuming the core is at fault. Hyper-V, WSL and Docker virtual adapters also compete for the default route, so auto-detect-interface can pick one of them.
macOS. The utun device requires the process to run with the rights the installed helper provides. A core started from a terminal without those rights can create a device that never receives traffic. Confirm which process holds the tun device instead of assuming the GUI started it.
Linux. auto-route needs the ability to modify routes — root or CAP_NET_ADMIN — plus a working iproute2. A container without that capability fails at the route step while the device step succeeds, which produces exactly the "TUN on, no internet" symptom with no error in the client UI.
What to include when you report it
Reports that get answered contain the log line, not a description of the symptom. Include the first error line from the core log rather than the summary dialog; the full tun block as configured, with secrets removed; the platform and the way the core was started; and the before/after route and DNS output. A report that says only "TUN does not work" cannot be distinguished from a subscription problem, a firewall problem, or a driver problem.
Common questions
Does TUN mode replace the system proxy setting?
No. TUN captures at the packet layer; the system proxy tells applications to hand traffic to a local port. Running both gives you two capture paths competing, and the symptom becomes harder to read. Test one path at a time.
The adapter exists but ping still fails. Is the node down?
Not necessarily. ping is ICMP, and many protocols and rule sets treat it differently from TCP. Test a TCP request to a known host, then compare with the log. An adapter with no outbound connection entry points at routing or rules, not at the node.
Why does stack: gvisor sometimes fix it and sometimes break it?
gvisor implements TCP/IP in user space, so it avoids dependence on host stack behaviour that may be misbehaving. It also changes UDP and fragmentation handling, so workloads that worked on system can regress. Change one value and retest the same request.
Do I need to set interface by hand?
Only where auto-detect-interface picks the wrong card. With VPN, Hyper-V, WSL, Docker or a USB tether present, the detected default can change between starts. If the log shows egress through an unexpected adapter, pin it explicitly and compare.
Is editing the config while the core runs safe?
mihomo reads configuration at start and on an explicit reload. Editing the file without a reload changes nothing, and a partial write can leave an invalid file. Save, reload, then confirm in the log that the value was accepted.
Related
- Clash Verge Rev TUN mode not working: connected, no internet
- v2rayN: TUN mode on, whole machine offline
- nftables operation not supported on sing-box auto-redirect
- TUN is on, but was the adapter created
- System proxy vs TUN: which path did your traffic take
The TUN adapter exists but ping still fails. Is the node down?
Not necessarily. ping is ICMP, and many proxy protocols and rule sets drop ICMP or pass it differently from TCP. Test with a TCP request to a known host on a port the proxy is expected to carry, then compare with the log. An adapter with no matching outbound connection in the log points at routing or rules, not at the node.
Is editing the whole config while the core runs safe?
mihomo reads configuration at start and on an explicit reload. Editing the file without a reload changes nothing, and editing it while relying on a partial write can leave an invalid file. Save the change, reload, then confirm in the log that the new value was accepted before drawing a conclusion.