多虚拟网卡环境下 wintun 设备安装失败的修复
最近折腾了一些异地组网的东西。主要是节点小宝和EasyTier。
用起来都不复杂,并且节点小宝的穿透成功率达到了灵异级,我怀疑是用了用户间P2P或者有一些跟运营商相关的PY,否则实在没法解释其性能,但即使是这样也没啥不好的。实在敏感的数据用虚拟机隔离加HTTPS也就是了。
相对而言,EasyTier的穿透成功率中规中矩,在家庭网络环境下还是以中继为主。好处是这东西有自组织P2P,可以把多个便宜的VPS并联起来用。
更正,上面一句是刚装好时写的,刚才回去看,发现 EasyTier 中原本几个显示
relay
的节点,现在都变成了p2p
,也是神奇。
正题是,由于频繁装卸虚拟网卡,有时候还有蓝屏断电等因素,有时候会导致wintun相关设备安装失败,在节点小宝的日志中,会看到类似open netif failed
的错误,外观表现为不保存但无法联网。如果是 EasyTier,则表现为直接报错,rust tun error Failed to create adapter
一类的。
这种问题,如果查不到资料是相当绝望的,因为 TUN 相关知识实在是太过冷门,一般人不需要接触。 从 EasyTier 的日志出发,最终检索到了几个相关帖子:
Please open regedit and delete HKEY_CLASSES_ROOT\CLSID{3d09c1ca-2bcc-40b7-b9bb-3f3ec143a87b} then try to disable and enable the Tailscale Tunnel under device manager. This would fix the tailscale "Creating adapter timedout". I'm using Windows 11. The problem was caused by a VMware Workstation bug, probably an unclean uninstall.
The issue was due to wintun drivers not being removed after uninstallation. To resolve the issue, the following was done.
Export the list of drivers in the table form to a text file using the command: dism /online /get-drivers /format:table > c:\drivers.txt
Find wintun or wireguard from the list, and note the "Published Name", oemNN.inf
Remove the driver using the command: pnputil.exe /d oemNN.inf
也就是,首先用 dism /online /get-drivers /format:table > c:\drivers.txt
导出驱动列表,然后找到Published Name
名为wintun
或者 wireguard
的项目,看他后面的一个名为oemNN.inf
的标号,NN
是一个整数,我这边是oem48.inf
,然后用 pnputil.exe /d oem48.inf
卸载。 之后,节点小宝和 EasyTier 都立马神奇地恢复了。
从最终的解决来看,这个是 tun 设备安装后没有正确卸载的问题。的确是外行难以想到的问题,因为这东西在软件关闭之后,设备管理器是看不到的,隐藏设备都没有一个。一般而言驱动程序残留也就残留了,不会影响下一次的安装。但 wintun 他就是这么特殊。
此外还有一个隐藏知识,就是这几家在 Windows 下用的应该都是 wintun,这个东西技术含量很高并且可能有内核签名、权限相关的东西,不用不行。