Forum Discussion
Hyper-V Default switch IP address range change. Ver 1809 Build 17763.1
Hyper-V default virtual switch is exactly made for the type of the environment you work at.
sometimes you connect to WIFI network and sometimes you connect using Ethernet cable.
each of those networks can have different set of IP addresses and subnets.
now if the default virtual switch were to create persistent routes instead of temporary ones (as it does now), it would have created problems for you because you'd have to jump in CMD each time the networks changed and set the correct routing table.
right now default Hyper-v virtual switch takes care of it automatically and it's for quick VM set up, casual VM works.
but if you want to set up servers in Hyper-V like i do, you should use external Hyper-v virtual switch. it has more functions and it gives the guest VM a static IP because it bounds it to a Real physical network adapter. that's exactly what server admins Need. usually servers use more than 1 physical network adapter. so using the external virtual switch, they can properly and separately assign each of them to a specific external virtual switch and utilize them perfectly in the guest OSes (servers). servers do need static IP addresses.
but if you just want to install a Windows 10 pro or home and do casual works then the default switch should suffice.
With VMware, I could configure my virtual NAT network subnet...I had it set to 192.168.5.X and the host and guest IP addresses on the subnet where static. So no matter where I happened to be working, my VM's were isolated on a NAT network with static IP addresses (which is important for the type of work I do)
With the Hyper-V Default Switch changing the subnet on every reboot, I'm having to log in the to my main VM (Windows Server 2016) and tell it that the "new network" that it is now connected to is a private network.
- LisendraMay 11, 2020Copper Contributor
southernprogrammer Thanks, gived myself permission to tweak a litlle you script to update all my vmdomains's ip also, work like a charm.
I also think the behavior of the default adapter is not logical, and i personaly see it as a bug, i hope it get fixed since i am migrating from VmWare to Hypre-V, streamlining my setup accross multiple device is better without scripts...
- HotCakeXFeb 27, 2020MVPThank you! i'll save it in my notes
- southernprogrammerFeb 27, 2020Copper Contributor
HotCakeX I'm talking about accessing a url that is hosted inside the guest.
If doing development you could do remote debugging on your host while having your environment on your guest.
- HotCakeXFeb 27, 2020MVP
Thanks, but Hyper-V VMs with enhanced session allow drag and drop between guest and host.
or is the script for a specific situation only?
- southernprogrammerFeb 27, 2020Copper Contributor
If you just need to access resources on your guest from the host, you could just have a powershell script that you can run on the host after launching the VM.
Replace 'BryanDev' with the name of your VM and replace "weirdalvm.3-gis.com" with your desired url you want to access the resource with.
Run as administrator
$result = get-vm -Name BryanDev | Select -ExpandProperty Networkadapters | Select IPAddresses | ft -hidetableheaders | Out-String $result = $result.Split(",")[0].Trim().Replace("{", "").Replace("}", "") function setHostEntries([hashtable] $entries) { $hostsFile = "$env:windir\System32\drivers\etc\hosts" $newLines = @() $c = Get-Content -Path $hostsFile foreach ($line in $c) { $bits = [regex]::Split($line, "\s+") if ($bits.count -eq 2) { $match = $NULL ForEach($entry in $entries.GetEnumerator()) { if($bits[1] -eq $entry.Key) { $newLines += ($entry.Value + ' ' + $entry.Key) Write-Host Replacing HOSTS entry for $entry.Key $match = $entry.Key break } } if($match -eq $NULL) { $newLines += $line } else { $entries.Remove($match) } } else { $newLines += $line } } foreach($entry in $entries.GetEnumerator()) { Write-Host Adding HOSTS entry for $entry.Key $newLines += $entry.Value + ' ' + $entry.Key } Write-Host Saving $hostsFile Clear-Content $hostsFile foreach ($line in $newLines) { $line | Out-File -encoding ASCII -append $hostsFile } } $entries = @{ 'weirdalvm.3-gis.com' = $result }; setHostEntries($entries)
- HotCakeXFeb 04, 2020MVPI think the best thing that should be done is to send feedbacks using any way, preferably Feedback hub, then share it with others who have the same problem to upvote it so that Microsoft will change that behavior on their end in future Windows 10 releases.
- GeoIT1150Feb 04, 2020Copper Contributor
HotCakeX
Very informative thread for this newb. Like many, I'd consider the behavior of the default switch a bug and not an enhancement.
1) Installed automatically (not optional).
2) Can't be removed.3) Can't be modified.
4) No persistent state except unconfigured.
5) Defaults to "Public" on a Domain machine and reconfiguration of state doesn't stick.
VBox and VMWare user attempting to learn Hyper-V and decipher the lack of logic in the above configuration.
Because it's "Public" or doesn't allow the option of a network type selection the Default Switch kills PowerShell WinRM and MS Admin Center on my domain, even when all VMs are using a second manually configured external switch and there is nothing using it - it's still in the registry in the default default configuration after reboot and PowerShell DSC is useless with the Default Switch registering.
I've read the arguments that it's "for amateurs" etc and there to make networking easy. My experience is exactly the opposite, that it's inexplicably configured to keep professionals from accomplishing their work. It breaks workflows that would otherwise be successful and that is a substantive meaning of a 'bug' in the software.
I've temporarily gone back to VMWare, which works flawlessly managing my virtual lab because default switch just doesn't work in my situation.
If someone can, please help me find workarounds to the 5 points above I'd greatly appreciate both your time and the knowledge. Very frustrating to have a simple configuration be this difficult to get working.
FYI - problems listed above are on 1909.
Thanks - HotCakeXJan 01, 2020MVPSneeze what?
- Barafu_Albino_CheetahJan 01, 2020Copper Contributor
- HotCakeXJan 01, 2020MVPWell I have the best AV, Kaspersky Internet security, with bunch of virtual switches including the default switch, everything is working perfectly.
you should contact your AV website and tell them this problem of yours.
my suggestion is to use an AV that is the best and doesn't have these problems.
https://www.youtube.com/channel/UCKGe7fZ_S788Jaspxg-_5Sg
https://www.youtube.com/watch?v=UDkllzL1gqo - Barafu_Albino_CheetahDec 31, 2019Copper Contributor
Using anything will not make Default Switch to disappear. It confuses my AV even when no virtual machines are running.
- HotCakeXDec 30, 2019MVPHi,
Try using External virtual adapter instead of the default switch if you can 🙂 - Barafu_Albino_CheetahDec 30, 2019Copper Contributor
I have another silly problem with this default switch. Since it changes its parameters all the time, my antivirus every time thinks it is a new network, and asks me what to do with it. It causes distractions, but the worst part is that it blocks all network on boot until I answer, causing network disks to not mount, which causes unrelated apps to not load properly and so on.
I am trying to figure it out with AV support, but I doubt they will resolve it soon, so I will have to use less optimal antivirus on my PC.
- HotCakeXDec 08, 2019MVPThanks for the useful info, btw i also got the Killer e2200 GbE NIC
anyway, yeah Hyper-V has it's own issues. I recently got bored and switched to VMware workstation pro 15.5 (latest ver) and I had so many problems configuring it.
I had to turn off Windows defender application guard, Windows Sandbox, Core isolation in Windows defender and literally lots of compromise in order to only install it.
after that I had problem with Windows 10 Enterprise x64 IoT version when i tried installing VMware tools on it, i was getting error that prevented me to install it.
so i eventually uninstalled it, turned on all of those security features again and continued using Hyper-V. i know it's not perfect but the alternative is a lot worse, at least for me.
I just hope Microsoft hear us and apply the changes we are asking to the way Hyper-V handles virtual network adapters. - LuxZgDec 08, 2019Copper Contributor
HotCakeX Here I had another chance on completely unrelated PC (different hardware, different location, different networking settings and environment, different users, not in domain, etc.) Same set of initial errors.
Trying to create external switch in GUI:
"Error applying Virtual Switch Properties changes
Adding ports to the switch 'External Switch' failed
The operation was passed a parameter that was not valid."Trying via PowerShell command ("New-VMSwitch -Name "External VirtualSwitch" -NetAdapterName "Killer e2200 GbE NIC" -AllowManagementOS $True"):
"New-VMSwitch : Failed while adding virtual Ethernet switch connections.
External Ethernet adapter 'Killer e2200 Gigabit Ethernet Controller #2' is already bound to the Microsoft Virtual Switch protocol."So I tried "easy" solution first, and in NIC Properties unchecked option:
"Hyper-V Extensible Virtual Switch"
(And rebooted PC)Luckily, on this PC when I tried to create external switch in GUI after reboot everything went ok. Didn't have to use the "nuke" option this time.
But still, quite annoying. And (at least in my case) on PCs that I regularly use I have all of them throwing this or that error. I love MS, but sometimes I hate it as well...
Cheers!
- HotCakeXDec 02, 2019MVPGood to know you found a solution, even though it's not that pleasant.
i agree default switch should be optional, not everyone want to use the quick VM creation of Hyper-V. - LuxZgDec 02, 2019Copper Contributor
HotCakeX It seems you are right, I'm sorry... But it seems that Microsoft still has a related bug, as I had (and have) the same issue on multiple PCs, and looking at Microsoft forums, I'm not alone.
There are several errors when trying to create External adapter, in my case, always on newer Win10 with Default Switch present (Windows 10 version 1709 or newer), so I (maybe mistakenly?) believe these to be related.
First error:
"the operation was passed an invalid parameter"
Complementary error (from Powershell's New-VMSwitch commandlet):
"Adapter is already bound to the Microsoft Virtual Switch protocol"
Proposed solutions:
https://social.technet.microsoft.com/Forums/azure/en-US/3272e5cc-e3d7-44a9-8da8-1a50a80afdf0/external-ethernet-adapter-is-already-bound-to-the-microsoft-virtual-switch-protocol?forum=winserverhyperv
Network and Sharing (Win7)/Network (Win 10) Change adapter settings/options Right-click Local Area Connection Go to Properties Scroll to the bottom of the list Uncheck "Hyper-V Extensible Virtual Switch" option
Alternative:
The nuclear option that works with Windows Core is using netcfg to wipe out all your networking settings and re-initialize the network card drivers. #WARNING! DANGER! THIS WILL DELETE ALL YOUR NETWORKING SETTINGS! netcfg -d
Second error, after I did uncheck Hyper-V from my physical NIC and rebooted:Tried to create External switch via PowerShell again
New-VMSwitch -Name "External VirtualSwitch" -NetAdapterName "Ethernet" -AllowManagementOS $True
Error:
"bind failed: {Access Denied} A process has requested access to an object, but has not been granted those access rights"
Proposed solutions:
https://social.technet.microsoft.com/Forums/windowsserver/en-US/84f413dc-2da0-44c0-928d-70b7a6c0404b/hyperv-virtual-switch-manager-cannot-create-an-external-switch?forum=winserverhyperv
Hi, I solved this by: In PowerShell type: netcfg -d This WILL DELETE all network adapters AND network SETTINGS! Physical adapters will NOT be LOST. Then i restored my network settings and created new External Virtual Switches.
So since both errors proposed "netcfg -d" I did that, rebooted, naturally now I have two Default Switches that I will just need to ignore, but now I can create External Switch without errors (both in GUI and PoSh), and use them as usual (pre-Win10/1709 times).
I do still stand by the fact that a) Default Switch should be OPTIONAL (can be setup as default behavior, but should have option to be removed) and b) that Microsoft somehow at the same/similar time introduced related bugs that provoke issues with creation of External switches.
I'm kinda happy now that I have my External switch running again, and will just have to live with the unneeded default switches lingering there in the background forever. Maybe you didn't have issues for a mix of reasons (maybe you did not upgrade all the way from initial Win10, or maybe you have other inactive adapters that are poluted by this bug but you don't use them so never noticed, or - you're just lucky).
Hopefully the links to two threads and the copied proposed solutions will help someone somewhere when they pop onto this thread through web search, if it helps just one more person I'll be happy.
Cheers!
- HotCakeXNov 28, 2019MVPDon't worry, I didn't forget anything.
I have 1 active network adapter and I connect that 1 network adapter to an external virtual network adapter and use it on my VM. no other adapter has connection. default switch never shows any error or prevent from creating an external network adapter and connect it to your only physical network adapter that has Internet.
if you don't want your IP to be reset every time, use the External virtual network adapter. - LuxZgNov 28, 2019Copper Contributor
Guy, kudos for dragging this conversation for so long... And I see each has their own set of arguments.
But what HotCakeX keeps forgetting is to tell the whole truth about his setup, and whole truth (and main issues) with DefaultSwitch.
Yes, DefaultSwitch is all fine for my granny to put a VM on her Win10 and put it online. But what is not ok is:
- that DefaultSwitch permanently grabs one ethernet connection for it's own purposes
- this connection may well be only one, for example, on workstation PC which isn't on WiFi, and doesn't have 2 LAN adapters
- cannot be removed
- prevents you from setting up second virtual switch / adapter on same interface as it is already binded to DefaultSwitch
- no workaround as DefaultSwitch keeps recreating itself on each reboot (so if you remove it, it will be there next reboot, if you disable it, it will be re-enabled, etc)
All is good, I have several clusters I can use to put VMs on them, with all dedicated connections, and all. But sometimes I just want/need to use a small VM on my PC, and I want it to KEEP the IP addresses same through reboots. There is simply NO REASON for it to be recreated every time, my local networks don't change, if 172.18.123.15 isn't conflicting on one reboot, it's not gonna conflict on next reboot. Yet - Win10 will still recreate it if I reboot, and with new IP range. There is also NO REASON for DefaultSwitch to be unremovable. We had Hyper-V before Default Switch, and on client PCs, and it worked just fine. Sure, make DefaultSwitch default config, my grandma really likes showing CentOS on her VMs from time to time, but give the option for REAL USERS (aka developers, sysadmins, etc) to remove/disable the DefaultSwitch garbage and use Hyper-V same way we've used it for years on our PCs. Instead, we have to keep Googling and hoping something will change with time. Or just endure the bad state of things, and use "real servers" just so we can have a small VM for whatever purposes we need it.
Btw, those that want to evaluate software sometimes want to make a small proof of concept on their workstation, without it requiring 2 more teams to allow you to a) put these VMs on their clusters b) create temporary networks for you to test something for a week or two.
Let me go back to the main thing that hurts a lot of people... HotCakeX you said you have your whole setup with home router and cheap 20$ WiFi adapter... yet you are forgetting to tell people that you also have second built-in adapter that you have in same PC/laptop. One that DefaultSwitch grabbed and "polluted" forever, and then you are using a 20$ adapter as your external adapter. That's paying 20$ for Microsoft's decision to make DefaultSwitch UNREMOVABLE.
Anyway, thanks for again confirming that MS still didn't fix this properly (and will probably stay broken as is), I'll revisit this in a year or so again, just to check if I can finally get back to the functionality I had with Windows 7, without buying new adapters, setting up new test WiFi environments, laying down new cables or buying new switches, just so my workstation could have a VM with ... predictable IP.
- mlmathewsNov 22, 2019Copper Contributor
GlaucomaPredator I have not found a way to permanently delete the Default Switch. I've been just ignoring it for now.
- GlaucomaPredatorNov 21, 2019Copper Contributor
mlmathews The problem is not being able to destroy the old switch. How did you manage that?
- HotCakeXOct 18, 2019MVPGood points
- mlmathewsOct 18, 2019Copper Contributor
I don't have time to list everything I've noticed, but I'll give you a couple of networking examples.
In VMware both the NAT and host-only networks have a virtual DHCP server that's configurable.
Another example is in VMware a bridged virtual adapter can be set to automatically select a physical adapter to bridge...so if you are developing on a laptop it will automatically switch between wifi and ethernet.
- HotCakeXOct 18, 2019MVPCould you name some of those missing capabilities that you're talking about?
for me the Only capabilities that Hyper-V is missing is tabbed VM session viewing, when working with multiple VMs at the same time. but that's the nature of it because of RDP and there are programs that have tabbed RDP session feature. - mlmathewsOct 17, 2019Copper ContributorIn my case, the only reason I'm trying to use Hyper-V now is that it's required if you want to user Windows containers / Docker Desktop on Windows 10. I'd much prefer to still be using VMware Workstation, but unfortunately VMware and Hyper-V can't co-exist (yet). So I've bitten bullet and moved to Hyper-V. I'm honestly really surprised how far behind Hyper-V is in capabilities and flexibility compared to VMware Workstation given how long Hyper-V has been around.