wintun interface sometimes can't start after wireguard-windows service dies

Eric Romano gelstudios at gmail.com
Mon Jun 14 20:03:26 UTC 2021


Hey All,

I ran into some unexpected behavior with a script that calls
"/installtunnelservice" waits a bit, then calls
"/uninstalltunnelservice". This happens in a loop with some
connectivity checks in between.

When the tunnel service itself ("wireguard.exe /tunnelservice ...") is
killed, I noticed a log message that mentions "leftover residue" on
the next service startup or next "/installtunnelservice" call.

Most of the time, the client is still able to connect following the
wintun residue message.

snippet 1 >
2021-06-14 09:21:50.966: [TUN] [testClient] Starting WireGuard/0.3.14
(Windows 10.0.19042; amd64)
2021-06-14 09:21:50.966: [TUN] [testClient] Watching network interfaces
2021-06-14 09:21:50.970: [TUN] [testClient] Resolving DNS names
2021-06-14 09:21:50.970: [TUN] [testClient] Creating Wintun interface
2021-06-14 09:21:51.408: [TUN] [testClient] [Wintun] CreateAdapter:
Creating adapter
2021-06-14 09:21:51.408: [TUN] [testClient] [Wintun] CreateAdapter:
Requested GUID {01351A57-32EF-4644-C335-5A44C0808EC6} has leftover
residue
2021-06-14 09:21:51.768: [TUN] [testClient] [Wintun] SelectDriver:
Using existing driver 0.11
2021-06-14 09:21:53.679: [TUN] [testClient] Using Wintun/0.11
... (normal behavior resumes)

But on two different machines I've seen this error: "system cannot
find the file specified", after which the tunnel device does not come
up. At that point I attempted to uninstall the tunnel service, as well
as uninstall+reinstall wireguard, with no success. A reboot was the
only apparent way to recover from this state.

snippet 2 >
2021-06-14 13:23:49.668: [TUN] [testClient] Starting WireGuard/0.3.14
(Windows 10.0.19042; amd64)
2021-06-14 13:23:49.677: [TUN] [testClient] Watching network interfaces
2021-06-14 13:23:49.686: [TUN] [testClient] Resolving DNS names
2021-06-14 13:23:49.686: [TUN] [testClient] Creating Wintun interface
2021-06-14 13:23:49.954: [TUN] [testClient] [Wintun] CreateAdapter:
Creating adapter
2021-06-14 13:23:50.087: [TUN] [testClient] [Wintun] SelectDriver:
Using existing driver 0.11
2021-06-14 13:23:50.939: [TUN] [testClient] [Wintun] CreateAdapter:
Failed to setup adapter (code: 0x0, status: 0xc00002f0): The operation
completed successfully. (Code 0x00000000)
2021-06-14 13:23:51.045: [TUN] [testClient] Unable to create Wintun
interface: Error creating interface: The system cannot find the file
specified.
2021-06-14 13:23:51.056: [TUN] [testClient] Shutting down
... dead from here onward

Similar behavior with a different log message, unfortunately I don't
know what was different about this test run. The same version of
wireguard was in use.

snippet 3 >
2021-06-10 18:42:22.044051: [TUN] [testClient] Starting
WireGuard/0.3.14 (Windows 10.0.19042; amd64)
2021-06-10 18:42:22.044051: [TUN] [testClient] Watching network interfaces
2021-06-10 18:42:22.575650: [TUN] [testClient] Resolving DNS names
2021-06-10 18:42:22.575717: [TUN] [testClient] Creating Wintun interface
2021-06-10 18:42:27.920185: [TUN] [testClient] [Wintun] RegistryQuery:
Querying registry value
\REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0011\NetCfgInstanceId
failed: The system cannot find the file specified. (Code 0x00000002)
2021-06-10 18:42:27.920185: [TUN] [testClient] [Wintun]
GetNetCfgInstanceIdFromHKEY: Failed to get
\REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0011\NetCfgInstanceId
2021-06-10 18:42:27.920185: [TUN] [testClient] [Wintun]
GetNetCfgInstanceIdFromHKEY: Failed to get
\REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0011\NetCfgInstanceId
2021-06-10 18:42:27.921506: [TUN] [testClient] [Wintun] CreateAdapter:
Creating adapter
2021-06-10 18:42:27.921506: [TUN] [testClient] [Wintun] CreateAdapter:
Requested GUID is already in use:
{928C5167-D802-9148-233E-28D4D15E1550}: Cannot create a file when that
file already exists. (Code 0x000000B7)
2021-06-10 18:42:28.506458: [TUN] [testClient] Unable to create Wintun
interface: Error creating interface: Cannot create a file when that
file already exists.
2021-06-10 18:42:28.506524: [TUN] [testClient] Shutting down
... dead from here onward

I acknowledge that killing the service PID is not the right way to
stop wireguard, but it does seem to clean up pretty well (routes, etc)
so I did not expect it to stay "broken".

Please let me know if there's something I can do to get more info
about any of the above errors.

Thanks,

-Eric


More information about the WireGuard mailing list