File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -457,8 +457,17 @@ function Get_MgmtSubnet {
457
457
$addr = (Get-NetIPAddress `
458
458
- InterfaceAlias ${net_adapter}.ifAlias `
459
459
- AddressFamily IPv4).IPAddress
460
- $mask = (Get-WmiObject Win32_NetworkAdapterConfiguration |
461
- Where-Object InterfaceIndex -eq $ (${net_adapter}.ifIndex )).IPSubnet[0 ]
460
+ # Get the adapter's mask from the registry rather than WMI or some other
461
+ # approach: this is compatible with Windows' forthcoming LWVNICs (lightweight
462
+ # VNICs).
463
+ # https://github.com/kubernetes-sigs/sig-windows-tools/pull/16/commits/c5b5c67d5da6c23ad870cb16146eaa58131caf29
464
+ $adapter_registry = Get-Item `
465
+ - Path (" HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\" +
466
+ " Parameters\Interfaces\$ ( $net_adapter.InterfaceGuid ) " )
467
+ # In this command the value name is 'DhcpSubnetMask' for current network
468
+ # interfaces but could be different for "LWVNIC" interfaces.
469
+ $mask = ($adapter_registry.GetValueNames () -like " *SubnetMask" |
470
+ % { $adapter_registry.GetValue ($_ ) })
462
471
$mgmt_subnet = `
463
472
(ConvertTo_DecimalIP ${addr} ) -band (ConvertTo_DecimalIP ${mask} )
464
473
$mgmt_subnet = ConvertTo_DottedDecimalIP ${mgmt_subnet}
You can’t perform that action at this time.
0 commit comments