Change Hyper-V (Default Switch) IP address range

Gloria Gu 3,896 Reputation points
2020-07-16T08:01:38.047+00:00

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

Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,735 questions
{count} votes

Accepted answer
  1. Xiaowei He 9,906 Reputation points
    2020-07-16T08:16:15.167+00:00

    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,

    2 people found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2020-10-28T18:03:15.993+00:00

    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

    2 people found this answer helpful.

  2. Brian 11 Reputation points
    2021-10-07T14:53:50.96+00:00

    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 :)

    2 people found this answer helpful.
    0 comments No comments

  3. Marcus Büttemeyer 391 Reputation points
    2021-08-04T18:50:12.077+00:00

    @Xiaowei He 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 person found this answer helpful.

  4. PT 6 Reputation points
    2022-01-14T16:23:03.193+00:00

    Added confirm false at the end of your first line, this made startup work for me so it does not have to ask you everytime, just runs. Thanks again for this!

    Get-NetIPAddress -InterfaceIndex (Get-NetAdapter -Name 'vEthernet (Default Switch)').ifIndex | Remove-NetIPAddress -confirm:$false
    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")

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.