Sep 24 2018 10:19 AM
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
Oct 05 2019 12:08 AM - edited Oct 05 2019 12:09 AM
"set the default network location for all known and uknown networks in Group Policy to private, no problem"
What happened with your previous statement "It's for easy networking and quick VM creation"? Editing group policies is not quick and easy.
"computers on a network using DHCP do NOT change their network locations when the DHCP server gives them a different IP address."
They do when the new IP address is in a different subnet.
And stop assuming that your way of working with Hyper-V is the only truth.
Oct 05 2019 12:09 AM - edited Oct 05 2019 12:17 AM
You don't wanna use other types of adapters so I said alright, if you want, here is the way.
if you use the group policy to change the network location for all known and unknown networks, meaning any future networks that appear will have the private location.
if you simply looked at my previous comments in the thread, you would know that it's not my way of thinking but many other people's. those links I mentioned are barely even 1%, there are lots of other proofs I can mention.
Oct 05 2019 12:15 AM
Oct 05 2019 02:41 AM
Oct 05 2019 03:01 AM
Oct 05 2019 03:18 AM
Oct 05 2019 03:33 AM
Oct 08 2019 09:33 AM - edited Oct 08 2019 09:39 AM
Thank you for replying; I appreciate it.
I am using Windows 10 Version 1903, build 18362.329.
I'm in no way married to the Default Switch and am perfectly content to create another switch for my purposes. I simply need to meet the conditions described in my previous post.
The second configuration you suggest looks to be exactly what I want, and in fact, it's exactly what's described in the following blog post that @mlmathews cited earlier in the thread:
https://www.petri.com/using-nat-virtual-switch-hyper-v
This configuration does in fact function exactly the way I'd like, so I'm happy!
That said, I concur with @mlmathews that the Default Switch poses an annoyance now, for one specific reason: when I provision a virtual machine with Vagrant, I'm prompted which switch to use, because I now have more than one, whereas when only one switch exists, Vagrant chooses the only switch automatically and without prompting.
I've tried disabling the Default Switch in the Device Manager (which, of course, also causes it to be disabled in Control Panel\Network and Internet\Network Connections), but Vagrant still sees it as long as it's available in Hyper-V's Virtual Switch Manager.
In any case, I can live with this minor annoyance, as well as the fact that the Virtual Switch, despite it's un-intuitive behavior, may be working exactly as Microsoft intends. Whether or not that behavior is ill-conceived, short-sighted, and completely out of lockstep with that seen in competing products is another discussion in which I have far less interest than "just getting it working". ;)
And if the information offered in https://mikefrobbins.com/2018/11/08/managing-the-hyper-v-default-switch-in-windows-10-version-1709-a... has not changed substantially since its publication, removing the Default Switch sounds to be more trouble than it's worth.
Thanks again for all the help, everyone!
Oct 08 2019 11:10 AM
Oct 16 2019 09:10 AM - edited Oct 16 2019 09:12 AM
I realize that many of us have differing use-cases; some of us are software developers using Vagrant who want internal IP addresses, some of us are systems admins using Windows Server who want external IP addresses, and some of us are adamant about using the Default Switch whereas some of us don't care what switch we use as long as its IP address doesn't change.
For those who share my specific use-case (i.e., using Vagrant and impartial to the Default Switch), I wrote a comprehensive How-To, which you may find helpful:
https://superuser.com/a/1379582/176764
Hopefully, Vagrant and Microsoft can work together to eliminate all the hoop-jumping!
Oct 16 2019 09:16 AM
Oct 17 2019 12:17 PM
Oct 18 2019 01:38 AM
Oct 18 2019 05:51 AM
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.
Oct 18 2019 07:29 AM
Nov 19 2019 10:17 AM - edited Nov 21 2019 08:41 AM
@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
Nov 21 2019 08:26 AM
@mlmathews The problem is not being able to destroy the old switch. How did you manage that?
Nov 21 2019 04:10 PM
@GlaucomaPredator I have not found a way to permanently delete the Default Switch. I've been just ignoring it for now.
Nov 28 2019 06:55 AM
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.
Nov 28 2019 11:13 AM