Skip to content

Commit

Permalink
Updates NATNetwork gateway IP check to be more specific to avoid diff…
Browse files Browse the repository at this point in the history
…erent adapters having an IP address collision.
  • Loading branch information
masq committed Jan 6, 2021
1 parent cdf2097 commit b619569
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions HyperV/hyperv-create-nat-switch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ If ("$NATSwitchName" -in (Get-VMSwitch | Select-Object -ExpandProperty Name) -eq
}

# Check that our Hyper-V host has the proper gateway address for the NAT Network.
# TODO make sure that this is set for the proper NATSwitch
If ("$NATHostIP" -in (Get-NetIPAddress | Select-Object -ExpandProperty IPAddress) -eq $FALSE) {
If (@(Get-NetIPAddress | Where-Object {$_.IPAddress -eq "$NATHostIP" -and $_.InterfaceAlias -eq "$NATSwitchNameAlias"}).Count -eq 1) {
"Registering new IP address $NATHostIP on Windows Hyper-V host..."

New-NetIPAddress -IPAddress $NATHostIP -PrefixLength $NATNetPrefixLength -InterfaceAlias $NATSwitchNameAlias
Expand Down

0 comments on commit b619569

Please sign in to comment.