nulldotblack / wintun

Rust bindings to the wintun c library: https://www.wintun.net/
MIT License
68 stars 17 forks source link

`set_network_addresses_tuple` doesn't work for IPv6 on Windows 11 #15

Open ReactorScram opened 8 months ago

ReactorScram commented 8 months ago

The netsh syntax appears to be wrong. I'm not sure if it worked on older versions of Windows? But on my Win11 dev system it doesn't work.

This does work: netsh interface ipv6 set address interface="My Wintun Tunnel" address=f000::f000

So I'm working around it here https://github.com/firezone/firezone/pull/3120/files#diff-d3087e924a318d4651ba5e2d08ebc753563e4cd3d2a0f6acccf2475936595551R86-R95

I'm not sure if the CREATE_NO_WINDOW flag helps or not - It worked for Powershell windows I was trying to hide.

TroyNeubauer commented 8 months ago

Thanks for flagging!

I won't have access to a Win11 machine for a few weeks so feel free to submit a PR if you need this fixed faster

TroyNeubauer commented 8 months ago

I wonder if these Win32 functions could help: https://learn.microsoft.com/en-us/windows/win32/iphlp/managing-ip-addresses-using-addipaddress-and-deleteipaddress

ReactorScram commented 8 months ago

No problem! For now I'm just shelling out to netsh directly instead of using the wintun function.

Yeah I've ended up using a lot of those IpHelper functions from the Windows crate in the Firezone client. (Edit: https://github.com/firezone/firezone/blob/3d8ed7f10ed596bb7fb3ca376888eb10a267bc50/rust/connlib/tunnel/src/device_channel/tun_windows.rs#L75-L99)

If anyone's reading this and doesn't want to shell out, ChatGPT recommends CreateUnicastIpAddressEntry for both IPv4 and IPv6 - https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/NetworkManagement/IpHelper/fn.CreateUnicastIpAddressEntry.html