Skip to content

fix: exclude wintun/tunnel virtual adapters from default interface detection on Windows - #15

Open
bohid02 wants to merge 1 commit into
MetaCubeX:metafrom
bohid02:meta
Open

fix: exclude wintun/tunnel virtual adapters from default interface detection on Windows#15
bohid02 wants to merge 1 commit into
MetaCubeX:metafrom
bohid02:meta

Conversation

@bohid02

@bohid02 bohid02 commented Jul 27, 2026

Copy link
Copy Markdown

Problem

On Windows, third-party applications (e.g., OPPO Connect, ZeroTier) can create wintun virtual adapters that register as IfType=6 (EthernetCSMACD) rather than IfType=53 (PropVirtual). The current checkUpdate() filter in monitor_windows.go only excludes IfTypePropVirtual and IfTypeSoftwareLoopback, so these third-party wintun adapters can be selected as the default outbound interface.

When this happens, mihomo's DIRECT outbound traffic is routed through the third-party wintun adapter instead of the physical NIC, causing traffic to loop back into the TUN and triggering reject loopback connection errors — resulting in complete network failure.

Root Cause

The wintun kernel driver (wintun.sys) registers all adapters as NDIS miniport with IfType=6 (Ethernet). The existing type-based filter cannot distinguish them from real physical adapters:

// current code - does not catch wintun devices
if ifrow.Type == winipcfg.IfTypePropVirtual || ifrow.Type == winipcfg.IfTypeSoftwareLoopback {
    continue
}

Fix

Add a Description-based filter to exclude adapters whose InterfaceDescription contains "Wintun" or "Tunnel". These are virtual tunnel adapters and should never be selected as the default outbound interface.

Reproduction

  1. Install any application that creates a wintun adapter (e.g., OPPO Connect creates ROOT\WINTUN\0000)
  2. Enable TUN mode with auto-route: true
  3. All network traffic fails with reject loopback connection errors
  4. Removing the third-party wintun device with pnputil /remove-device immediately resolves the issue

Verification

  • Tested on Windows 11 with OPPO Connect (O+Connect) installed
  • OPPO Connect's wintun device: ROOT\WINTUN\0000, Description = "Wintun Userspace Tunnel", IfType=6, InterfaceMetric=5
  • After applying this fix, the third-party wintun adapter is correctly excluded from default interface detection

Related

…tection on Windows

Third-party applications (e.g., OPPO Connect) create wintun adapters that
register as IfType=6 (EthernetCSMACD). These are not excluded by the current
type-based filter, causing them to be selected as the default outbound
interface when their metric is lower than the physical NIC.

This leads to DIRECT traffic being routed through the third-party wintun
adapter, looping back into the TUN, and triggering "reject loopback
connection" errors.

Fix by checking the interface Description for "Wintun" or "Tunnel" keywords
and excluding matching adapters from default interface selection.

Related: clash-verge-rev/clash-verge-rev#6712

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant