Forum Discussion
Bala Sundaram
Sep 24, 2018Brass Contributor
Hyper-V Default switch IP address range change. Ver 1809 Build 17763.1
Can one confirm IP address range changed to 192.168.X.Y Subnet 255.255.255.240 from 172.X.X.X Also changes the subnet randomly on every Hyper-V services startup. 192.168.X.Y . X can change from 5...
GlaucomaPredator
Nov 19, 2019Copper Contributor
Bala Sundaram put the following in a PowerShell script and add to task scheduler, then run at logon. Change the #staticIP to desired IP.
An alternative is to put the script in local group policy using a .bat file to kick it off.
"powershell.exe -ExecutionPolicy Bypass -File "script.ps1""
#Sets a static IP on the HyperV default switch (Windows 10).
Set-ExecutionPolicy Bypass -Scope Process -Force
#wait for network to come up
while (-Not (Test-Connection -ComputerName 1.0.0.1 -Quiet))
{}
$staticIP = "172.18.79.1"
$hyperVnet = Get-NetIPAddress -InterfaceAlias "vEthernet (Default Switch)" | select InterfaceAlias,InterfaceIndex,AddressFamily,IPAddress,PrefixLength | where {$_.AddressFamily -match "IPv4"}
#Remove old IP address, otherwise there will be two IP addresses
Remove-NetIPAddress -IPAddress $hyperVnet.IPAddress -Confirm:$false
New-NetIPAddress -InterfaceIndex $hyperVnet.InterfaceIndex -IPAddress $staticIP -PrefixLength $hyperVnet.PrefixLength