question

GloriaGu-MSFT avatar image
0 Votes"
GloriaGu-MSFT asked Brian-7065 edited

Change Hyper-V (Default Switch) IP address range

Hello,

Is it possible to change the IP address range used by the Hyper-V (Default Switch) that is 172.x.x.x to 192.168.x.x ?

This is for Hyper-V on windows 10 1809 to 1909

Thread source link: https://social.technet.microsoft.com/Forums/windowsserver/en-US/6b2a9042-c590-4b5d-aa4c-60eb3f7901e8/change-hyperv-default-switch-ip-address-range?forum=winserverhyperv

windows-10-hyperv
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

There is a somewhat easy set of solution to this:
Solution A: You can create another virtual switch that serves internal ip addresses to the VMs on your machine and the draw back is no internet connectivity and create a vm to be the DHCP server. If you two nic cards you can share the network with these internal VMs.

**Solution B:**Create a External that assigns to the external network and still route traffic via dhcp and dns on on a VM Server.

0 Votes 0 ·
XiaoweiHe-MSFT avatar image
0 Votes"
XiaoweiHe-MSFT answered JGregMackinnon-6742 commented

Hi LMichel,

We are unable to remove default Switch on windows 10 and unable to change the IP address range.

"The Hyper-V Default Switch will randomly use one these IP address ranges based on the host system IP address:
- Start IP: 192.168.0.0 – End IP: 192.168.255.255

  • Start IP: 172.17.0.0 – End IP: 172.31.255.255

The Default Switch has a built-in local collision detection mechanism to determine if IP address in these ranges is already assigned to a network interface on the Local Host system and will try to find a (/28 – 255.255.255.240) address space within one of these ranges that is not already allocated to any network interfaces.

The Default Switch on the Host system always assign the first IP address of the chosen range to the virtual Ethernet Adaptor on the Host, and use this address as the Default Gateway and DNS server provided to the hosted VMs connected to it.

You cannot remove or manage "DHCP" on the default switch."

Thanks for your time!

Best Regards,

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Xiaowei

Just to re-iterate Ethans point on this, it's causing issue with an AO VPN, It would be useful to have an option to set it to something that we can control. Is there anything we can do to request this feature?

Thanks

2 Votes 2 ·

That would be great idea as it generates a lot of conflicts on my machine especially with docker desktop when it uses the a sbunet of 192.168.0.0

1 Vote 1 ·

The problem is with a VPN client; sometime after the collision detection mechanism; addresses and routes are added that overlap with the network selection made by the hyper-v default switch. It would be MUCH more practical to allow users to exclude network ranges that are known to be incompatible with their environments; instead of making them play reboot roulette over and over again hoping that it magically picks a network segment that is "stable" and can allow them to both be connected to a VM and to a VPN at the same time.

In my case; if I could "pin" hyper-v default switch to 192.168.128.0 /17 it would solve my current challenges; however I'm a sure that others have different requirements.

Please don't assume you know more than your users about their networking needs. :)

1 Vote 1 ·

I agree that this (and similar issues with the WSL2 vms) must be resolved, and soon. This basic feature gap prevents everyone on my team from using Windows for the bulk of their developer work. I am tired of testing new workarounds to this problem that has hindered my work since the introduction of client hyper-v and more recently since the introduction of WSL2.

Many have proposed using a dummy nic or virtual switch to “claim” corporate private network ranges so that hyper-v will not use them. This is not a good workaround. It is cumbersome to users, and I find that it causes severe network performance degradation owing to routing problems.

Another alternative is to set up a router vm to handle traffic from an internal switch to an bridge adapter. This also is cumbersome.

A third choice would be to use a third party virtualization engine. Can’t do that either because new Windows 10 security features (credential guard) prevent VMware workstation from functioning.

After over 20 years of telling teammates, “No, you don’t need a Mac,” I have surrendered. On this team, for our development work, we now have to run Ubuntu or “get a Mac”. I hate this situation. Please correct this problem expeditiously!

0 Votes 0 ·
SalamELIAS-8667 avatar image
1 Vote"
SalamELIAS-8667 answered

I am not sure if this staement
will try to find a (/28 – 255.255.255.240)
is correct
In my envirenment, Default switch configured itself with the subnet

172.22.0.0 mask 225.225.240.0

its ip is
172.22.144.1

1st machine IP is
172.22.159.156 mask 255.255.240.0

broadcast ip
172.22.159.255

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MarcusBuettemeyer avatar image
0 Votes"
MarcusBuettemeyer answered BernardAric-9439 commented

@XiaoweiHe-MSFT I can confirm the above statement. I could live with a /28, but a /20 smack in the middle of my IP address plan (172.20.0.0/14 so far) is really annoying.
The reason people used the 172.16/12 address range was that few other system used that: SoHos were on 192.168/16, Enterprises were on 10/8, so 172.16/12 was the obvious choice.
I also understand that newer system try to avoid conflicts by using 172.16/12, like docker does. But at least your Unix peers a) use only a /16 and b) make it configurable and c) start near the beginning of the range, which I explicitly avoided, fearing that others might catch up. Took you long enough, though

That's just another bullet point on a presentation to my re-trainees: "I teach you Windows because it's everywhere and works quite well in most cases, BUT...."

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The entirity of the 'Default Switch' concept and the inability for the end-user to modify it is completely flawed. God help you if you have more than one NIC in the host...

0 Votes 0 ·
Brian-7065 avatar image
0 Votes"
Brian-7065 answered Brian-7065 edited

This is far from ideal solution, however it may be suitable for some given that I've found it a real headache of an issue.

Powershell will let you change the parameters of the Default Switch, however it'll get overwritten at next boot. Therefore one option is to put the Powershell script in the startup.

Warning Note!!! This script will remove all related IP's from the Adapter before applying the new settings, also please ensure your NIC is named exactly as listed here "vEthernet (Default Switch)" and you obviously want to change the addresses to those suited to your needs.

Get-NetIPAddress -InterfaceIndex (Get-NetAdapter -Name 'vEthernet (Default Switch)').ifIndex | Remove-NetIPAddress
New-NetIPAddress -InterfaceAlias 'vEthernet (Default Switch)' -IPAddress '10.0.0.1' -PrefixLength 24
Set-DnsClientServerAddress -InterfaceAlias 'vEthernet (Default Switch)' -ServerAddresses ("10.0.0.15","8.8.8.8")

These commands can be expanded upon to set other parameters as needed, also i'm using static IP's everywhere as I got sick of these random IP's so I haven't tested using this setup as a DHCP server.

Hopefully it's of use to someone :)

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.