Skip to Content

A Practical Guide to Hyper-V Virtual Switch Configuration

The hyper-v is the Microsoft version of the hypervisor for windows machines. Many users who are comfortable with the VMware and the VirtualBox start using the hyper-v they get confused about how the networking is set up in the hyper-v world.

So in this blog, I want to dedicate some time and write about the different types of virtual switches available in the hyper-v and how you can use each network in different scenarios.

Read also,
How to Configure Different Network Types in VMware Workstations?
How to Configure VirtualBox Network Settings ?
How to FIx VMware Bridged Network Not Working in Windows?
How to Connect KVM VM to Host Network?

What is a virtual switch in hyper-v?

A virtual switch will enable ethernet frame switching between the VM’s virtually in the virtualization world. So in hyper-v, it is the same concept, you create VM’s in the hyper-v hypervisor and connect those VM’s to the virtual switch using the virtual adapter, and VM’s can communicate with each other.

Different types of Hyper-V switches.

There are, however, different switches that can be used in different scenarios. Those are

  1. Default switch.
  2. External Switch.
  3. Internal Switch.
  4. And Private switch.

Let’s look at each of them in detail with examples, so I hope by the end of this article you will get some idea of what switch can be used in what scenarios.

1. Default Switch.

The default switch is enabled by default when you enable the hyper-v on a windows environment. In the default switch, the VM’s will get NATed IP from the host machine. With the help of that NAT IP, it can go out to the internet. But the host machine or the devices in your local area network cannot talk to the VM’s that are in the default switch. Let’s take a look at that in action.

I have already enabled the hyper-v on my windows 11 machine. As you can see, it created a default switch with the IP address 172.18.215.33/28

I just spun up a Windows 11 and Ubuntu VM in the hyper-v and will connect the switch to those VM’s, and let us see how it will work.

To change the network configuration on hyper-v virtual machine.

  • Right-click on the VM and click on settings.
  • Choose the network adapter in the pop up, and choose the default switch in the Virtual switch drop-down.

After I made the changes, I went ahead checked the IP configuration. As you can see, the windows 11 virtual machine got the IP  172.18.215.45 and the Ubuntu VM got 172.18.215.39 address from the same default switch subnet.

From My host machine, when I tried to ping, I can reach the IP address of the default switch, which is 172.18.215.33 but not the VM (172.18.215.45).

When I try to ping the internet from the VM, it is working fine.

I can also talk to my local area network devices.

Also the VM to VM communication works fine as well.

Where do you use the default switch?

A default switch will be ideal when you want your VM to talk to the internet, the host machine, and the local area network. Though your VM can initiate the communication to the local area network, the same is not true in reverse. The devices in the local area network cannot talk to the VM.

In the default switch, the VM can talk to;

  • Host Machine.
  • Internet
  • LAN Devices.
  • Other VM’s in the same default switch.

And

  • LAN devices and Host machines can not directly initiate communication to the VM.

2. Hyper-V External Switch.

You can think of an external switch as a bridged network if you are coming from the Vmware, virtual box side. In an external switch, the VM’s will talk directly to your local area network. And your local area router’s DHCP service will assign an IP address to your hyper-v virtual machine. The VM will act like another host in the same local area network. The external network switch will be useful when you want your VM to talk directly to your local area network and talk to the internet directly.

Since the VM is part of your local area network, it can work as a different machine with the same network access as your host machine.

How do I create an external switch in hyper-v?

  • Open the Hyper-V.
  • On the right side, click on Virtual switch manager.
  • The virtual switch manager wizard will now open.
  • Click on the New Virtual network switch.
  • Choose External, and click on Create Virtual switch.
  • In the new virtual switch properties.
    1. Name the switch.
    2. Provide some description in notes.
    3. Choose External network:
    4. You need to ensure that you selected the physical interface that your host machine connected to the LAN. In my case it is my wireless adapter, hence I selected that.
      • If you are connected using wired, you will have to choose a wired network instead.
    5. VLAN ID –(Optional) For general usage, you don’t need to specify the VLAN, however if you want to carry VLAN tagging, you can do that here.

Test the External switch connection to the VM.

My LAN network has the IP address of 192.168.0.0/24 network, and when I connect any VM’s in the external switch, it should get an IP address from the same subnet. Let’s take a look at that.

With the same windows 11 and Ubuntu VM’s, I will switch the network from the default switch to the external switch created.

Right-click on the VM and click on Settings.

  • In the network adapter, choose the external switch.
  • Click on Apply and ok.

Verify the network.

Login to the VM and check the IP address.

As you can see I got the IP address from my local area network router.

And I can reach the internet just fine.

Windows 11 vm has got IP address – 192.168.0.3

Ubuntu VM has got an IP address – 192.168.0.2

I can also ping other devices in the same network. Also, if the VM’s are connected to the same external switch, I should be able to connect to that because it will treat as another host in the LAN segment.

When to use an external switch in hyper-v?

If you would like your VM to have the same network access as your host machine in the Local area network, an external network will be a great choice. Since the router and the devices in the local area network can talk to the VM directly without any involvement of NAT, we can also make the VM be available towards the internet by doing port forwarding on the router side.

In External Switch the VM can talk to;

  • The host machine.
  • Devices on the LAN segment.
  • Other VM’s in the external switch connected to the same LAN (wired/Wireless)
  • Internet.

3. Hyper-V internal network.

If you want your VM’s to talk to each other and the host machine, the internal network will be helpful, but it cannot get to the internet. If you want the internal host to connect to the internet, you will have to use a router or firewall as a VM and connect to the internal switch and the other side connected to  the external side.

Let’s take a look at the internal network configuration.

  • Open Hyper-V manager.
  • Click on Virtual switch manager on the right side.
  • The virtual switch manager window would pop up.
  • Click on New virtual network switch.
  • Choose Internal and click on Create a switch.
  • Name the VM.
    • Type internal Switch and click on Apply and ok.

The Internal switch is now created.

Test the connectivity in the internal network.

Unlike external and the default switch, where you get the IP address automatically from your DHCP service. In the internal network, you will have to create the IP address manually. You can also keep a DHCP server in the internal network and start handing out IP addresses as well. We will check that out as well.

Configure the IP address statically.

We created an internal switch, and it does not have any IP address assigned to it. Hence your windows 11 VM will get an APIPA IP address. And no IP on the Ubuntu side.

Let’s configure the static IP address on the internal switch on your HOST machine.

On your host machine, Goto àStartàRunàType ‘ncpa.cpl’

  • Right click on the internal switch adapter and click on properties.
  • Choose internet protocol version 4, and click on Properties.
  • Enter the IP address of your choice.

I am choosing the 10.100.1.0/24 subnet.

Basically, your host machine has the IP address 10.100.1.1 on the internal network.

Assign the internal network to the hyper-v VM’s.

Right-click on the VM and click on settings. Under the network adapter, choose the internal network that we just created.

Just like how we configured the IP address on the host machine, you may also configure the IP address on the virtual machine.

As you can see, I configured 10.100.1.10 from the same subnet 10.100.1.0/24 on windows 11 VM.

And 10.100.1.12 on the Ubuntu.

Lets try to ping the host IP address, as you can see we can reach the host IP address just fine.

Also the windows 11 VM, But you cannot reach the internet.

Test with DHCP server in an internal switch.

I have spun up another VM that acts as a DHCP server and is connected to the internal switch.

I have configured both the windows 11 and Ubuntu VM as DHCP clients.

As soon as the DHCP server came up, both got the IP address from the DHCP server.

In Internal switch the VM can talk to;

  • The host machine.
  • Other VM’s.

Cannot talk to;

  • Internet.
  • Local area network.

4. Hyper-v Private network.

As the name suggests the private network is kind of like an isolated network where the VM’s in the hyper-v can communicate with the other VM’s in the same private network, but not to the HOST machine, and neither toward the internet. It is very appropriate for a testing environment.

It will be useful, when you want to simulate, for example a firewall network, where the WAN side of the firewall can connect to the external network and the LAN side can connect to the private network. To get to the internet in the private network has to go via the firewall. But by default Private switch VM’s cant talk to anything but to each other.

How to create a private switch in hyper-v?

  • Open Hyper-V Manager.
  • Click on Virtual switch manager on the right side.
  • The virtual switch manager window would pop up.
  • Click on New virtual network switch.
  • Choose Private and click on Create a switch.
  • Name the VM.
  • Choose a private network and click on Apply.

Switch the VM to a private network and test the connectivity.

Just like before switch the virtual network switch from external to the private switch in hyper-v.

Test the private network in Hyper-v.

I moved windows 11 and the Ubuntu machine to the private network.

On both the VM’s I disabled the network adapter and enabled back.

Similar to the internal networks both of them don’t have an IP address assigned to it. Because there is no DHCP service, the only difference between the internal and the private network is that in an internal network, not only you can communicate with the VM’s, but you can also communicate with the host machine, whereas in a private switch you can communicate with the VM’s. However, you cannot communicate with the host.

Test the private connectivity with the static IP.

  1. On the host machine, if you try to change the IP, you can not because there is really no adapter. As you can see only, Default, External and Internal have the network adapters created on the host machine. There is no private adapter, which proves that there is no way you can make the VM to communicate with the host machine.
  • Windows 11 and the Ubuntu are are configured with the IP address from the same network, and there is no default gateway configured because there aren’t any.

Windows 11 IP configuration.

Ubuntu IP configuration.

And you can ping between them as well.

In Private switch the VM’s can talk to;

  • Other VM’s in the same internal switch.

Cannot talk to;

  • Hosts.
  • LAN.
  • Internet.

Conclusion.

In conclusion, Hyper-V virtual switches offer a powerful tool for optimizing your virtual network configuration. By understanding the different types of virtual switches and when to use them, you can create a more efficient and streamlined network. With the step-by-step instructions provided, you can confidently manage your virtual switches in Hyper-V and ensure your network is running smoothly.