Is it possible to set a static IP address for Hyper-V's default switch adapter? Every time I reboot my PC the address has changed.

  • 2
    No, the default switch isn't configurable. I believe this still works in the newer versions of Win 10: petri.com/using-nat-virtual-switch-hyper-v
    – essjae
    Feb 18, 2020 at 18:57
  • Can you set a static address in Control Panel > Network Connections > Change adapter settings via right-clicking the vEthernet switch?
    – harrymc
    Mar 26, 2020 at 9:01
  • @harrymc yes I can set a static address, but it will be automatically overwritten to some random address after system reboot
    – Vladimir
    Mar 26, 2020 at 12:26

3 Answers 3


You can set a static address in Control Panel > Network Connections > Change adapter settings by right-clicking the vEthernet switch, but Windows will reset it to a random address after the reboot, and that action cannot be disabled.

A solution could be to reset it always to the same value by using the netsh command or its PowerShell alternatives. Netsh needs to be run as Administrator.

The command syntax is:

netsh interface ip set address [name=]InterfaceName [source=]{dhcp | static [addr=]IPAddress[mask=]SubnetMask [gateway=]{none | DefaultGateway [[gwmetric=]GatewayMetric]}}

An example command to set the switch to static IP of, mask and gateway none is:

netsh interface ip set address name="vEthernet (Default Switch)" static none

If necessary, you could set a script containing the command to run when Windows is started or on user logon.

Another solution would be to create a new switch, whose IP address will stay, unlike the default switch.

  • should be avoided since it's the standard IP of cable modems' WebUI.
    – JW0914
    Mar 26, 2020 at 13:36
  • @JW0914: It's just the first thing that came into my mind.
    – harrymc
    Mar 26, 2020 at 14:10
  • @harrymc I've posted a similar question here: superuser.com/q/1541599/678751 Can you please elaborate on your suggestion of "creating a new virtual switch" w/ static IP?
    – Wlad
    Apr 13, 2020 at 17:55
  • Default switch IP changed while using this script , but my host is not getting IP , later i tried configured a static IP for host , but still unable to ping gateway
    – Arun
    Aug 17, 2020 at 4:57
  • Isn't the "random" address assigned because of the subnet settings? For example, if have a "static" IP of, and a subnet of, won't I get a random IP in the range - If I changed the subnet to will this reduce the random range?
    – Shiraz
    Oct 17, 2020 at 18:30

I'm aware that it may be a little off topic, but since we're setting this IP in order to e.g connect via SSH to our Hyper-V instance, then it's possible to assign static MAC address and then write some "self-discovery" script so we will dont have to use assign ip to vEthernet everytime

Assign static MAC:

Right click on Hyper-V instance -> Settings > NetworkCard > Advanced Functions -> Choose Static MAC and FILL MAC

enter image description here

In my case it is powershell script which extracts IP from arp discovery basing on that static MAC and then connects to it via SSH

$str = ((arp -a | findstr /i 00-15-5D-01-83-0B)[0]); 
$ip = $str.Split(" ")[2].Trim()
ssh root@$ip



Displays and modifies the IP-to-Physical address translation tables used by
address resolution protocol (ARP).

ARP -s inet_addr eth_addr [if_addr]
ARP -d inet_addr [if_addr]
ARP -a [inet_addr] [-N if_addr] [-v]

  -a            Displays current ARP entries by interrogating the current
                protocol data.  If inet_addr is specified, the IP and Physical
                addresses for only the specified computer are displayed.  If
                more than one network

arp -a | findstr /i 00-15-5D-01-83-0B

/i = ignore case

Returns:          00-15-5d-01-83-0b     dynamic        00-15-5d-01-83-0b     static

[0] Index

Picks:          00-15-5d-01-83-0b     dynamic

$str.Split(" ")[2].Trim()


then ssh connects to it

  • 1
    Nice! You have a small typo, though - last result should be ""
    – Shiraz
    Oct 17, 2020 at 18:39


I found an alternative solution as neither changing the IP of the HyperV default switch via netsh nor creating an alternative switch worked for me. Instead of directly changing the IP of the Hyper-V adapter we can restrict the possibilities for the algorithm granting the IP addreses to the switch by adding loopback interfaces that block IP ranges. Loopback interfaces can be introduced using hdwwiz.exe > Next > "..manually select from a list" > Network Adapters > Manufacturer Microsoft > Microsoft KM-TEST Loopback Adapters The IP address and subnet mask for the loopback adapter can be set by "view network connections", right click the newly created interface > Properties/Internet Protocol Version4 /Properties

We can exploit that the subnet mask of the Hyper V default switch seems to be constantly at So within the 192.168.x range it always uses one of,, ... as IP addresses. We can introduce e.g. a loopback interface with IP and subnet mask, that will block all IPs from to Now introduce another one with IP and subnet mask, that will block all IPs from to Another one could be IP with subnet mask, blocking to If you know also block via a loopback interface using IP and subnet mask the only possible IP address the Hyper V adapter can have is while there's still plenty of IP addresses available in the 192.168 range. Maybe its necessary to block the 172.16.x range in the same manner. On the other hand it might also be necessary for you to be less retsrictive in the 192.168.0.x range if there are devices relying on these to be available. There seems to be the possibility to introduce loopback interfaces via Powershell scripts but haven't tried that so far.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .