question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New-NetNat support check not working as intended

See original GitHub issue

First off let me thank you for making this application. I only found it yesterday but managed to get a WireGuard server running in under an hour.

Now onto the issue at hand.

In commit eb22d730ab70ae5638a010128a70841d5e4464fe a support check for New-NetNat was introduced. This support check fails on my machine even though New-NetNat is supported. Running the support check in powershell yields the following output:

PS C:\WINDOWS\system32> Get-Help New-NetNat -Parameter InternalIPInterfaceAddressPrefix
Get-Help : Kein Parameter entspricht dem Kriterium "InternalIPInterfaceAddressPrefix".
In Zeile:1 Zeichen:1
+ Get-Help New-NetNat -Parameter InternalIPInterfaceAddressPrefix
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (System.Manageme...CommandHelpInfo:ProviderCommandHelpInfo) [Get-Help],
    PSArgumentException
    + FullyQualifiedErrorId : NoParmsFound,Microsoft.PowerShell.Commands.GetHelpCommand

Get-Help fails to find information about the InternalIPInterfaceAddressPrefix parameter and gives an exit code other than 0. Running the commands to manually set up NAT routing works fine however and no errors occur. After rewriting the support check and letting it do the setup everything worked fine aswell. I have pushed my changes to https://github.com/Dola-Shuvi/WgServerforWindows/commit/41413db1a86a4dbde74a3cba317c761da64b4f8e for you to take a look at.

My Windows version is 22H2 (Build 19045.2130) and I installed everything except the Hyper-V-Hypervisor and the GUI manager in the add/remove Windows features menu.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Dola-Shuvicommented, Oct 31, 2022

Looks good to me. The fallback works as expected and should make the support check much more robust.

1reaction
micahmocommented, Oct 31, 2022

I found this small query (Get-Command New-NetNat).Parameters['InternalIPInterfaceAddressPrefix'] over on StackOverflow

Ooh this is great, nice find! Relying on Get-Help was probably always a bad idea. 😄

Unfortunately, that command returns 0 whether or not the parameter exists, but this seems to do the trick.

if ((Get-Command New-NetNat).Parameters.ContainsKey('InternalIPInterfaceAddressPrefix')) { exit 0 } else { exit 1 }

Would you be willing to test it for me before I make a new release? I’ve pushed the change to fix/62. I can also generate a build for you, but it sounds like you know how to do that. 😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

Couldn't make NAT Switch on Hyper-V without erros
Hi All,. I'm trying to make a NATed switch on my Hyper-V (running on Windows 10 w/ anniv. update installed), but could not...
Read more >
Docker on Windows Insider build 17025 · Issue #1255
Hello there, have tried reinstalling both stable and edge versions. Last thing I have done is docker factory reset. Expected behavior ...
Read more >
Set up a NAT network
Configure the NAT network using New-NetNat. In order to configure the gateway, you'll need to provide information about the network and NAT ...
Read more >
Set up a Hyper-V Virtual Switch using a NAT Network
A couple of months ago, I wrote a blog post about how you can create a new Hyper-V NAT Switch. Now, this worked...
Read more >
Force Remove-NetNat - powershell
Is there a way to run the command remove-netnat without the need of confirmation? I can't find any switch allowing me to force...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found