Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAT Routing Error #30

Closed
crack00r opened this issue Apr 2, 2022 · 11 comments
Closed

NAT Routing Error #30

crack00r opened this issue Apr 2, 2022 · 11 comments
Labels
bug Something isn't working windows-issue This issue may be related to Windows, outside the scope of WS4W
Milestone

Comments

@crack00r
Copy link

crack00r commented Apr 2, 2022

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.Exception: New-NetNat : Ung�ltige Klasse
In Zeile:1 Zeichen:1

  • New-NetNat -Name wg_server_nat -InternalIPInterfaceAddressPrefix 10.2 ...
  •   + CategoryInfo          : MetadataError: (MSFT_NetNat:root/StandardCimv2/MSFT_NetNat) [New-NetNat], CimException
      + FullyQualifiedErrorId : HRESULT 0x80041010,New-NetNat
    
    
     at WireGuardServerForWindows.Models.NewNetNatPrerequisite.Resolve(String serverDataPath) in C:\Users\micah\source\repos\WireGuardServerForWindows\WireGuardServerForWindows\Models\NewNetNatPrerequisite.cs:line 115
     at WireGuardServerForWindows.Models.NewNetNatPrerequisite.Resolve() in C:\Users\micah\source\repos\WireGuardServerForWindows\WireGuardServerForWindows\Models\NewNetNatPrerequisite.cs:line 68
     --- End of inner exception stack trace ---
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
     at GalaSoft.MvvmLight.Helpers.WeakAction.Execute()
     at GalaSoft.MvvmLight.Command.RelayCommand.Execute(Object parameter)
     at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
     at System.Windows.Controls.Primitives.ButtonBase.OnClick()
     at System.Windows.Controls.Button.OnClick()
     at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
     at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
     at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
     at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
     at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
     at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
     at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
     at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
     at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
     at System.Windows.Input.InputManager.ProcessStagingArea()
     at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
     at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
     at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
     at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
     at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
     at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
     at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
    
    

System.Exception: New-NetNat : Ung�ltige Klasse
In Zeile:1 Zeichen:1

  • New-NetNat -Name wg_server_nat -InternalIPInterfaceAddressPrefix 10.2 ...
  •   + CategoryInfo          : MetadataError: (MSFT_NetNat:root/StandardCimv2/MSFT_NetNat) [New-NetNat], CimException
      + FullyQualifiedErrorId : HRESULT 0x80041010,New-NetNat
    
    
     at WireGuardServerForWindows.Models.NewNetNatPrerequisite.Resolve(String serverDataPath) in C:\Users\micah\source\repos\WireGuardServerForWindows\WireGuardServerForWindows\Models\NewNetNatPrerequisite.cs:line 115
     at WireGuardServerForWindows.Models.NewNetNatPrerequisite.Resolve() in C:\Users\micah\source\repos\WireGuardServerForWindows\WireGuardServerForWindows\Models\NewNetNatPrerequisite.cs:line 68
    
    
@micahmo
Copy link
Owner

micahmo commented Apr 3, 2022

Hey @crack00r, can you send the exact version of Windows you're running? From the Start menu or Run box, type winver and screenshot the window. It should look something like this.

image

Thanks!

@micahmo micahmo added bug Something isn't working windows-issue This issue may be related to Windows, outside the scope of WS4W awaiting-feedback Need additional info from the submitter labels Apr 3, 2022
@micahmo
Copy link
Owner

micahmo commented Apr 3, 2022

@crack00r I would still like to hear what version of Windows you're running, but I think I know what's going on here. The NAT routing features requires either...

  • Hyper-V to be enabled (which requires Pro)
  • Or Windows to be updated to 21H2

Of course Internet Connection Sharing can always be used if NAT cannot.

I've documented this limitation here.

I will keep the issue open to track an enhancement, which should do the following.

  • On a Windows installation capable of (but not currently) running Hyper-V, automatically enable it.
  • On a Windows installation incapable of running Hyper-V, do not show the NAT option.

@crack00r
Copy link
Author

crack00r commented Apr 3, 2022

sure, here you go

With the Connection Sharing it works perfect!

image

@crack00r
Copy link
Author

crack00r commented Apr 3, 2022

image

@micahmo
Copy link
Owner

micahmo commented Apr 4, 2022

Thanks for confirming! This aligns with my guess.

  1. You have version 21H1, so the NAT routing feature won't work without Hyper-V
  2. And you have Home, which means you can't enable Hyper-V anyway

I'm glad to hear that ICS works. And if you did want to use NAT instead (it has some benefits described in #18), you could update to 21H2.

As mentioned, I will keep this issue open, because the NAT button should not have been available in your scenario.

@micahmo
Copy link
Owner

micahmo commented Apr 5, 2022

Upon further investigation (with Windows 10 Pro 21H2), it appears that Hyper-V must be enabled in order to use NAT Routing. @kenvix, you said in #18 that it didn't. Can you explain how you got New-NetNat to work without first enabling Hyper-V?

For now, I've updated the documentation to reflect this.
https://github.com/micahmo/WireGuardServerForWindows#inability-to-enable-nat

@okastl
Copy link

okastl commented Apr 6, 2022

Upon further investigation (with Windows 10 Pro 21H2), it appears that Hyper-V must be enabled in order to use NAT Routing. @kenvix, you said in #18 that it didn't. Can you explain how you got New-NetNat to work without first enabling Hyper-V?

I am not kenvix, but I installed WireGuard Server for Windows on Windows 10 pro 21H2 Build 19044.1620 yesterday without problems. And no, Hyper-V is not enabled. At least I believe it isn't: In Windows Features "Hyper-V" is unticked.
I didn't do anything special, it just worked.

After some testing on the Win Pro machine, I have installed WireGuard Server for Windows on Windows Server 2019 which has an old Windows 10 under the hood: Version 1809, Build 17763.2686. Everything works surprisingly well.
EDIT: Windows Server 2019 has the server role "Hyper-V" disabled.

@micahmo
Copy link
Owner

micahmo commented Apr 7, 2022

Hmm, interesting. Now I wonder if my problem could've been related to the fact that I was using VMs to test this without nested virtualization enabled. I will have to do some more investigation.

@okastl
Copy link

okastl commented Apr 7, 2022

Hmm, interesting. Now I wonder if my problem could've been related to the fact that I was using VMs to test this without nested virtualization enabled. I will have to do some more investigation.

Now I'm going to confuse you even more... I just tried WireGuardServerForWindows on Windows 10 Pro N Version 21H2 Build 19044.1620 and enabling NAT failed!
I installed Hyper V and enabling NAT worked. Out of curiosity I uninstalled Hyper V and enabling NAT failed again. Very weird.

@micahmo
Copy link
Owner

micahmo commented Apr 7, 2022

I'm getting the impression that I won't be able to add a simple version check to gate this feature. 😊

It seems like I will need some sort of graceful handling of this error that does the following...

  1. Try to enable NAT Rounting.
  2. If it fails, try to enable Hyper-V.
  3. If that fails, direct users to Internet Connection Sharing instead.

@micahmo micahmo removed the awaiting-feedback Need additional info from the submitter label Apr 8, 2022
@micahmo micahmo added this to the v1.7.2 milestone Apr 9, 2022
@micahmo
Copy link
Owner

micahmo commented Apr 9, 2022

Hey all, I just pushed v1.7.2 which should help to address this issue. As we collectively discovered, there's not a great way to know upfront whether NAT Routing will work or not, so the application just tries to enable it (with the option to try to enable Hyper-V as well); otherwise, it directs you to use ICS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows-issue This issue may be related to Windows, outside the scope of WS4W
Projects
None yet
Development

No branches or pull requests

3 participants