Forum Discussion
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 51 thru 180.
Although this is working on DHCP based IP assignment on guests, It is causing issues on static IP as it keeps changing after every boot
Regards,
Bala
- 19-kiloCopper Contributor
@@Bala Sundara
(Edit)
-This is not a solution but a workaround for people wanting to bypass Win 10's normal operation. If you are running important workloads, I suggest running Windows Server version of Hyper-v and not Windows 10. I was in a pinch and needed some workaround while I was in-between servers. Once those were up and running I migrated back off onto Win Server Hyper-v. Anyway, good luck out there.1. Strip off any static IPs you have on all hardware NICs
2. Run the following commands
Get-HNSNetwork | ? Name -Like "Default Switch" | Remove-HNSNetwork
New-VMSwitch -SwitchName "Default Switch" -SwitchType internal -Verbose3. Open Hyper-v Manager and open Virtual Switch Manager
4. Default switch is still there, but now setting are no longer greyed out and can be adjusted from internal to external; move to external and verify it's assigned the correct hardware NIC. Verify it has "Allow management operating system to share this network adapter" checked.
5. Watch the new NIC and bridge get created in Network and Sharing Center 'Change adapter settings'.
6. On the new Hyper-v NIC, adjust your IP settings to be static if you want.
I tried multiple reboots and VMs can still connect out while maintaining the static assignment on the Hyper-v NIC.
Hope it helps!
-Jake
- Big_AlCopper ContributorI am on Windows Pro 10 Version 1909.
I followed below link instructions to get around the issue with default switch static IP address in VM. The work around is create a new switch
https://anandthearchitect.com/2018/01/06/windows-10-how-to-setup-nat-network-for-hyper-v-guests/#:~:text=Windows%2010%3A%20How%20to%20setup%20NAT%20network%20for,Gateway.%205%20Step%204.1%3A%20Create%20NAT%20Network.%20 - mooh-poohCopper Contributor
IP changed due to dynamic MAC. New MAC means new DHCP lease.
- So manually set a static MAC address for your Virtual network adapter.
- __1373Copper ContributorMERY Chrismas
- To you as well!
- GlaucomaPredatorCopper 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
- sn00pCopper Contributor
I'm a Linux guy but have to use Windows10 now. Don't want to use VirtualBox or Vagrant as I have HyperV licensed. But I can't make it work sadly. Also additional hypervisor breaks a lot of things in windows10 which requires additional time to make workarounds.
Default vSwitch keeps changing IP address on reboot. There is no DHCP server included so no way to assign a static address to my VM.
Workarounds are not helpful too.
- tried adding new virtual switch and NAT it via PowerShell. It works until reboot only. There is no GUI for that? ok.
- ICS is not working after reboot too, I have to manually reenable it. Adding registry key is not working.- tried to add external linux vm to route all the traffic, still need ICS which is not working after reboot.
- tried third-party software, it's okay but requires additional payments.
All that bugs persists through ages, seriously? Very disappointed, want my money back.
- You can use the External vSwitch on Hyper-V VM instead of the default switch.
then inside your VM OS (guest), set a static IP address.
how? well your VM guest will get an IP address anyway, just copy it and make it static. easy
also how come your network doesn't have DHCP? you must be getting internet from somewhere. a router or DSL modem, they must have DHCP in them.
none of them you mentioned are bugs. you just have to know where to use what.- sn00pCopper Contributor
HotCakeX it's definitely bugs, network switch can't change IP address randomly if assigned statically. As simple as that. No other network software do this thing, but MS virtual switch.
Also that aged thing with ICS not working after reboot is a nasty bug too.
NAT is hardly working too, sometimes it's ok, sometimes it's not. Probably arp related, idk.
In conclusion there is no simple setup which allows you to use host internet inside hyperV VM.
Not to mention there are no shared folders so on.I can't use external networks because of this, I have to mount it as samba share (technology from 20 years ago okay). And how to work with VM if there is no external switch with dhcp like on a jet board? It's laptop with windows10, not a server inside infrastructure.
VirtualBox does this sharing in two simple clicks. But Windows10 core denies all other hypervisors with every update.
- I've been working a lot with Hyper-V and I gotta tell you that the default switch is NOT meant for static IP addressing. in any tutorial or YouTube video you watch you'll see than none of them choose the default switch for static IP addressing.
if you want static IP and never changes, you should make a new virtual network adapter and make it EXTERNAL, then connect it to your PHYSICAL network adapter (all done in Hyper-V switch manager), it will make a bridged connection in your host Windows. then inside your guest OS (VM) you can give a static IP to your OS and it will stay that way and never changes.
IMO default switch is for those who want a quick setup and get a VM up and running fast without any additional settings.- DanielNiccoliSteel Contributor
HotCakeX wrote:
I've been working a lot with Hyper-V and I gotta tell you that the default switch is NOT meant for static IP addressing. in any tutorial or YouTube video you watch you'll see than none of them choose the default switch for static IP addressing.
if you want static IP and never changes, you should make a new virtual network adapter and make it EXTERNAL, then connect it to your PHYSICAL network adapter (all done in Hyper-V switch manager), it will make a bridged connection in your host Windows. then inside your guest OS (VM) you can give a static IP to your OS and it will stay that way and never changes.
IMO default switch is for those who want a quick setup and get a VM up and running fast without any additional settings.
I've been working a lot with Hyper-V, too. The default network adapter is not meant to change IP address ranges with every reboot. Once an IP address is set, it should be immutable. Throwing around with workaround does not remove the issue at hand.Your described way to get a static IP is fine. However, this doesn't work when I have to test something that involves DHCP. Sure, I can install a NAT with 2 vNICs, one on one external switch and the other on a private switch, but that involves additional hours to setup correctly.
With the built-in network address translation of the Default Switch, this problem is already solved. And for testing purposes it would be perfectly fine, were it not for the non-intended behaviour that the address range randomly changes between reboots of the host computer.
- Deleted
Hi.
I'm totally new to Hyper-V but not quite new to networking and virtualization and this random selection of private subnets really baffles me. This looks more like a fallback function and no the main one. I can understand the following reasoning: If the Hyper-V user doesn't enter a proper subnet or the subnet they entered is invalid, generate a random one (things have to work one way or another, right?) The problem is that the main function doesn't seem to exist so we get this random mess.
As I said, I have worked a bit in networking so I looked for a simple way to know exactly which IP addresses were used after the host operating system reboots. What I do is open a Command Line Prompt (doesn't need to be Admin) and type: arp -a. (no dot at the end) I look for the interface that I know isn't mine as in the IP address wasn't configured by me. Once I get that, the pattern is as follows:
The interface IP address is the address of the Host (duh!) which is the gateway IP address for the VMs. In the Physical Address column the ff-ff-ff-ff-ff-ff MAC address corresponds to the broadcast IP address for the subnet the VMs use. The rest of the IP addresses in this subnet belong to the VMs. Like so:
Interface: 172.18.61.97 --- 0x1c
Internet Address Physical Address Type
172.18.61.108 00-15-5d-0a-0d-00 static
172.18.61.111 ff-ff-ff-ff-ff-ff staticI have one VM which apparently got the 172.18.61.108 IP address this time around. Maybe there's a way to automate such "inventory check" with a script or something else.
I hope some will find the above tip useful. 🙂
Cheers.
- sc-mleCopper Contributor
HotCakeX wrote:
if you want static IP and never changes, you should make a new virtual network adapter and make it EXTERNAL, then connect it to your PHYSICAL network adapter (all done in Hyper-V switch manager), it will make a bridged connection in your host Windows.While others in this thread have provided this information it was the concise nature of your post that provided the eureka moment for me.
Thank you.- You're welcome! 🙂
- DanielNiccoliSteel Contributor
So, is there a solution to this? I really would like my Default Switch to have a static IP configuration.
- dwx101Copper Contributor
Bala Sundaram Dont want to be that guy, but...172.x.x.x is a class B (16 bit)
Class C address is the one I believe your referring too as in 192.168.x.x
Basically -
Class A goes from 0 upto 127 - ex. 10.10.10.1
Class B goes from 128 upto 191 (hence the 172.16.x.x as i too have that anomaly in my vEthernet
Class C goes from 192 upto 223 - common ex. 192.168.1.1
then you get Class D and also E but these are reserved special purposes. Class D for multicast and E for experimental.
Class D goes from 224 upto 239
Class E goes from 240 upto 255
If you knew this then ignore this reply.
I hope you sorted out the issue. I dont see any resolution at the end of this thread. Let me know if you did.
All the best.
Danny
- Neo BeumBrass Contributor
This has been the case for quite some time - and is not isolated to 17763, and stretches to 10240.
(Though earlier issues weren't this exact problem)
The "Hyper-V Virtual Ethernet Adapter" that appears in device manager that appears as "vEthernet (Default Switch)" in Network and Sharing Centre is being deleted and reinstalled each time you shutdown and boot.
You can also check the registry to see the abundant keys that are created and never removed and just linger in HKLM\System\CurrentControl\Services\
If you're suffering from this issue - you should see a ton of {GUID} just under .NETFramework, and a whole bunch more in the VM services section... vmsmp, vmsp, vmsfsf, etc.
VMSMP\parameters\SwitchList contains the current 'Default Switch'
Those GUID under the .NETFramework Key, when expanded will have Tcpip keys for previous switches...
- Remon liCopper Contributor
Do you have any idea how to get this ip fixed ? Maybe we can run powershell script to change it after reboot ?
---------------------
Just tried to update IP on reboot with powershell script, it's ok to keep same IP , but the network doesn't
work for VMs.This is not way.
- Neo BeumBrass Contributor
I haven't actually played around with all of my VM's yet. However - 1903 has fixed one of the Hyper-V Default Switch problems:
The Default Switch would always be set as a public network - this can be disruptive to other connected networks - as I don't trust that the MS Engineers did a good job with how Domain/Private/Public interact.
With 1903 - the Default Switch is not assigned a Network Category. Which is how it should have been to begin with.
It is always going to be a private network - as VM's can only use it to interact with other VM's on the Host and to the Host itself.. an Internal Network. Like I said... I don't trust the engineers to have done the network categories correctly, until now. Took 4 years.
Anyhow, I'm in the middle of updating the VM's on my laptop to 1903 and see what I can do in the Guest Machine.
- kazuo_yamauchiBrass ContributorI confirmed that the pair of rules of reception of "DNS Server Forward Rule TCP - XXXXXXXXXXXXXXXX - 0" and "DNS Server Forward Rule UDP - XXXXXXXXXXXXXXXX - 0" increases forever with the influence that the Default Switch is recreated. The "XXXXXXXXXXXXXXXX" is GUID of port of Default Switch that was recreated. If we do not delete wasted rules, will one day overflow?
- Neo BeumBrass Contributor
Host (Right Screen): vEthernet (Main Internal) - 10.0.0.1
Guest (Left Screen)- Static IP. Gateway is Host's Main Internal Switch IP.
IP: 10.0.0.2
Subnet: 255.255.255.0
Gateway: 10.0.0.1
If you need Internet connectivity on the Guest - you need to bridge your Host Machine's Main Internal Switch to an Internet Connection... Highlight Both, Right Click and Bridge. Easiest way to do it.
(Main Internal) Static IP addresses persist through Reboot and Shutdown.
Guest Machines connecting to (Main Internal) will need a Static IP set and these also persist thought Reboot and Shutdown. You will need to host a DHCP server if you don't want to use static.
Nested VM ... you can go 3 deep with Hyper-V.
The Hyper-V Server that will host DHCP will need to spoof Mac-Address. If you don't you'll end up with the same set of IP addresses each time.
Here's better screenshot... NB-TECH and NB-G751JY will always connect to each other after reboot, and vEthernet (Default Switch) is never used.