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

Clearing gateway using powershell WMI does not function as expected #21481

Open
5 tasks done
elksson opened this issue Apr 16, 2024 · 0 comments
Open
5 tasks done

Clearing gateway using powershell WMI does not function as expected #21481

elksson opened this issue Apr 16, 2024 · 0 comments
Labels
Needs-Triage The issue is new and needs to be triaged by a work group.

Comments

@elksson
Copy link

elksson commented Apr 16, 2024

Prerequisites

Steps to reproduce

Using a powershell in admin mode, set the network adapter to static mode.
I used address 192.168.180.30, Mask 255.255.255.0 and gateway 192.168.180.2
however it does not matter what ip address, gateway or mask is used as long as its a valid ip, gateway, and netmask combination.

You will notice that the enable static function results in setting the ip address the static address as expected.
The set gateways function also sets the gateway as expected. You can observe this in the printed route table, and ipconfig /all information.

Per the wmi documentation setting the gateway to the same address used to call EnableStatic should result in the gateway being cleared. However as observed in the route print, and also ipconfig /all this actually results in the gateway being set to 0.0.0.0 which is not the expected behavior, it actually applies a "default route" instead of no route.

As note this issue is also observed using c++ however I am not sure how to report this to the windows team, or the WMI Team at microsoft.

$nic = Get-WmiObject Win32_NetworkAdapterConfiguration -filter "Index='3'"
$ip_address = Read-Host("What's the IP address? :")
$subnetMask = Read-Host("what's the subnet mask? :")
$gateway = Read-Host("what's the gateway? :")
$nic.EnableStatic($ip_address,$subnetmask)
$nic.SetGateways($gateway,1)
Start-Sleep -Seconds 5
route print
ipconfig /all
$nic.SetGateways($ip_address,1)
Start-Sleep -Seconds 5
route print
ipconfig /all

Expected behavior

The route should be cleared when SetGateways is called with the same IP address that was used to EnableStatic

Actual behavior

The route should default gateway is set to 0.0.0.0 when SetGateways is called which results in the incorrect routing table and a network that does not route traffic properly.

Error details

No response

Environment data

PS C:\WINDOWS\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.4170
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.4170
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visuals

No response

@elksson elksson added the Needs-Triage The issue is new and needs to be triaged by a work group. label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Triage The issue is new and needs to be triaged by a work group.
Projects
None yet
Development

No branches or pull requests

1 participant