Windows 10 hyper v virtual switch

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.

This article will explore how to configure and use Private Virtual Switch in Microsoft Hyper-V virtualization software running on Windows 10 or Windows 11 operating system to restrict the connection of specific virtual machines to locations you do not want them to access.

Configuring Private Virtual Switch in Hyper-V

The main reason for creating a Private Virtual Switch on Hyper-V is to prevent a virtual machine from accessing our physical network and computer. After making the private network, we must add the created network adapter to the virtual machine. After adding the adapter, virtual machines can no longer access the physical network.

However, this may change in some cases. For example, suppose you will install Pfsense with a Hyper-V in the test environment. In that case, you can complete the Pfsense installation by adding an Internal Virtual Switch to the LAN and an External Virtual Switch to the WAN.

In the following articles, we will install Pfsense with Hyper-V. In our previous articles, we have examined other types of virtual networks;

  • External Virtual Switch
  • Internal Virtual Switch

You can also watch the video tutorial on the topics mentioned above on our YouTube channel;

  • How to Create External Virtual Switch in Hyper-V
  • How to Configure Internal Virtual Switch in Hyper-V

Likewise, we continue to discuss network types; this time, we will discuss the Private Virtual Network/Switch configuration.

How to Add Private Virtual Network

After adding a Custom Virtual Network adapter on Hyper-V, we will add the created network adapter to the virtual machines. We will then examine how these virtual machines can communicate with each other.

And then, we’re going to test whether our physical machine can access the network card. Follow the steps below to configure Private Switch.

Step 1

First, run the Hyper-V Manager virtualization program. If this is your first installation, you can check out our article on Hyper-V Setup.

Hyper-V Manager

Step 2

For example, check the Windows 10 virtual machine network adapter settings installed on Hyper-V. You can see from the image below that no Virtual Switch has been added to the Windows 10 virtual machine.

Adding a Network Card to a Windows 10 Virtual Machine

Step 3

To add a network adapter to your virtual machine, create a new Virtual Switch from the Virtual Switch Manager settings. This initial step is crucial to establishing a virtual machine’s network connection.

Click the Virtual Switch Manager from the Actions panel.

Virtual Network Administrator

Step 4

Select Private from the VS Manager window and click the Create VS button.

Creating Virtual Switch

Step 5

Type a name to create the private network and click OK to continue.

Private Network

Step 6

To connect the Hyper-V network adapter you created to your virtual machine, right-click on the VM and select the correct option.

Windows 10 Settings

Step 7

In the Windows 10 VM settings, click the network card on the left panel, select the Switch you created from the Network Adapter section, and click OK.

New Virtual Switch

Step 8

To test the Private Network configuration, configure two virtual machines and test the connection between them. For example, as in the image below, you can use a Windows 7 virtual machine.

Add the Private Switch to the second virtual machine.

Network Adapter Configuration

Step 9

Configure the Windows 7 TCP/IP configuration as follows. You can create the IP block here for the desired range. You do not have to fill in the default gateway address because the virtual machine cannot communicate with the physical network or device!

Windows 7 Virtual Machine TCP/IP Settings

Step 10

Configure the IP configuration of the Windows 10 machine as follows.

Windows 10 Virtual Machine TCP/IP Settings

Step 11

Pinging from Windows 10 virtual machine to Windows 7 virtual machine is successful!

Ping from Windows 10 to Windows 7

Step 12

Pinging from the Windows 7 machine to the Windows 10 system was successful!

Ping from Windows 7 to Windows 10

Step 13

We did not configure any adapters for Hyper-V in the network settings of our physical computer. If we had added the internal Switch here, a vEthernet network adapter would have been created, as in the image below.

Windows Network Connections

How to Configure VLAN in Hyper-V

VLAN creation and configuration are effortless. After creating a Private Virtual Switch on Virtual Switch Manager, we must define a VLAN ID for this network adapter. For example, a Windows 7 virtual machine member of VLAN 2 cannot communicate with VLAN 3.

In Hyper-V, let’s look at assigning virtual machines to a VLAN and testing connectivity.

Step 1

Re-open the Windows 10 machine network card settings based on all the above settings. In the Virtual Machine Network Adapter window, select the VLAN ID this time, specify the VLAN Number in the box just below it, and click OK.

Hyper-V VLAN Configuration

Step 2

Open the CMD command prompt on the Windows 7 virtual machine and ping the Windows 10 VM to test the connection. The Destination host unreachable error message is reported in the image below.

Ping 192.168.10.10

Step 3

Pinging from the Windows 10 virtual machine to the Windows 7 virtual machine will also fail as follows.

Ping 192.168.10.7

Step 4

We made Windows 10 VM a member of VLAN 2. This time, start pinging continuously on the Windows 7 virtual machine at the CMD command prompt.

When you start continuously pinging, turn on the Windows 7 network adapter settings on Hyper-V. Then activate the VLAN ID option, type 2 as the VLAN Number, and click OK to close the window.

As you can see in the image below, Ping will succeed as soon as the Windows 7 virtual machine is assigned to VLAN 2.

VLAN ID Activation

Video

To create a Hyper-V Private Network on Windows 10, watch the video below and subscribe to our YouTube channel to support us!

Conclusion

This article examined how to configure a Custom Virtual Switch from Hyper-V virtual network types. Thanks for following us!

4

In Hyper-v you can connect Hyper-v machines to Internet with two methods that I’m going to explain all step by step. This article is for those, who know the basic of Server Virtualization with Hyper-v. If you don’t know about Hyper-v Virtualization software, I recommend you to read the previews articles of Hyper-V installation and configuration posts.

  • Install Hyper-V: Hyper-v Beginner: A Practical Guide to Virtualization. This post shows you how to install Hyper-v on Windows client 8.1, 10 and Windows Server 2012 and Windows Server 2016.
  • Configure the necessary Hyper-V settings: Essential Hyper-V Configuration. Explain the configuration of Hyper-v for beginner to create a virtualization testing Lab.

Hyper-v Virtual Switches

The virtual switch is a logical switch which connects virtual machines. Currently, Hyper-v has three different types of virtual switch which I told the preview article also.

  • External: Switch is used to connect the virtual machines to external network and Internet. The virtual machines (Guest) and Host will be on the same network.
  • Internal: Switch is used to create network connection between guest machines and the host.
  • Private: The private switch is used to create network connection between virtual machines only.

Connect Hyper-v Machines to Internet Using External vSwitch

1. Create an external virtual switch in Hyper-v and then link it to the physical host network card. To create a virtual switch, open Hyper-v Manager then clicks Action and click Virtual Switches Manager.

Create Hyper-v External Virtual Switch – Technig

2. From Virtual Switch Manager, select External virtual switch and click Create Virtual Switch.

How to Connect Hyper-v Machines to Internet in Windows 10  – External NIC

3. Type a name for this virtual switch and select the exact physical network card which currently connects your host to the internet then click OK to apply the changes.

4. Now, to connect a virtual machine to the internet just select this external virtual switch as network adapter of the virtual machine.  Let’s test it on a Windows 10 Pro.

Connect Hyper-v Machines to Internet in Windows 10

5. Run a virtual machine then click File and click Settings then select Network Adapter from Virtual Machine Settings. From right side select the external virtual switch as the virtual switch to connect hyper-v machines to internet.

Connect Windows 10 Virtual Machines to Internet – Technig

The virtual machine is successfully connected to the internet through the external virtual switch.

Connect Hyper-v Machines to Internet Using ICS

The second method is using Internet Connection Sharing (ICS). ICS is another best practice to connect Hyper-v Machines to the internet. But in this method, you must share the original internet connection for virtual machines. So with ICS, you can connect your all private network machines to the internet. Let’s do it.

Configure Hyper-v Internal Virtual Switch in Windows 10 – Technig

The process is the same as creating an external virtual switch. Open the Virtual Switch Manager and create a new one. Only select Internal instead of external the click OK to create the Internal virtual switch.

Enable ICS to Host Machine

1. Type “ncpa.cpl” to Windows Run and press enter to go to network connections of your host machine. Then right-click the Ethernet connection which is connected to the internet then click Properties.

Configure Hyper-v Internet Connection Sharing – Technig

2. On the Ethernet Properties page click Sharing tab then tick the checkbox of Allow other network users to connect through this computer’s internet connection then click OK to apply the changes.

3. Now for your virtual machines, you should choose Internal vSwitch as a virtual switch to connect them to the internet.

How to Configure Internet Connection Sharing on Windows 10 – Technig

Yes, it works fine.

In the environment where your internet connection is a Wi-Fi connection, you can use the second method ICS to connect Hyper-v machines to the internet.

Connect Hyper-V Virtual Machine to Internet – Video

OK, that’s all. Hope you enjoy this Virtualization related article to Hyper-v beginner guide.  If you have any questions, please ask us in the comment box. We will help you fix the problems fast and easy.

A couple of months ago, I wrote a blog post about how you can create a new Hyper-V NAT Switch. Now, this worked fine in some early Windows 10 builds, but Microsoft removed the parameter for the NAT Switch in some Windows 10 Insider builds. You can find more about the Hyper-V Virtual Switches on Microsoft Docs. In the latest versions in the Windows 10 client operating system, Microsoft already includes a “Default Virtual Switch”, which allows you to use Hyper-V NAT Networking, without doing any configuration changes.

If you want to create an additional VM Switch which uses NAT on Windows 10, or you want to use the Hyper-V NAT VM Switch on Windows Server, you can follow this guide. The NAT VM Switch is especially heady if you use Nested Virtualization.

Requirements:

  • Windows 10 and Windows Server 2016 build 14295 or later
  • Enabled Hyper-V role
  • PowerShell, since this setting is not available in the UI right now

Set up a Hyper-V NAT Switch

Create a new Hyper-V Virtual Switch

New-VMSwitch –SwitchName “NATSwitch” –SwitchType Internal

Configure the NAT Gateway IP Address

This configures the Virtual Network Adapter which was created while creating the Internal Virtual Hyper-V Switch.

New-NetIPAddress –IPAddress 172.21.21.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NATSwitch)"

Now you can configure the NAT rule

New-NetNat –Name MyNATnetwork –InternalIPInterfaceAddressPrefix 172.21.21.0/24

After that, you have finally created your NAT network, and you can now use that network to connect your virtual machines and use IP addresses from 172.21.21.2-172.21.21.254.

Create a new NAT forwarding

To forward specific ports from the Host to the guest VMs, you can use the following commands.

This example creates a mapping between port 80 of the host to port 80 of a Virtual Machine with an IP address of 172.21.21.2.

Add-NetNatStaticMapping -NatName "VMSwitchNat" -Protocol TCP -ExternalIPAddress 0.0.0.0 -InternalIPAddress 172.21.21.2 -InternalPort 80 -ExternalPort 80

This example creates a mapping between port 82 of the Virtual Machine host to port 80 of a Virtual Machine with an IP address of 172.21.21.3.

Add-NetNatStaticMapping -NatName "VMSwitchNat" -Protocol TCP -ExternalIPAddress 0.0.0.0 -InternalIPAddress 172.16.0.3 -InternalPort 80 -ExternalPort 82

This also works with Windows and Hyper-V Containers. I hope this gives you a good overview of NAT Networking and the Hyper-V NAT Switch. If you have any questions, feel free to leave a comment.

Tags: Container, Containers, Hyper-V, Hyper-V NAT Switch, Hyper-V Virtual Switch, Microsoft, NAT, NAT Switch, PowerShell, Virtual Switch, Windows, Windows 10, Windows Server, Windows Server 2016 Last modified: July 22, 2019

About the Author / Thomas Maurer

Thomas works as a Principal Program Manager & Chief Evangelist Azure Hybrid at Microsoft (Cloud + AI). He engages with the community and customers around the world to share his knowledge and collect feedback to improve the Azure hybrid cloud and edge platform. Prior to joining the Azure engineering team (Cloud + AI), Thomas was a Lead Architect and Microsoft MVP, to help architect, implement and promote Microsoft cloud technology.

If you want to know more about Thomas, check out his blog: www.thomasmaurer.ch and Twitter: www.twitter.com/thomasmaurer

Вы тут: Главная Windows Нюансы виртуальных коммутаторов Hyper-V и приоритета сетевых интерфейсов

Однажды я заметил, что с ноутбука очень долго загружались фотографии в Google Photos. Я посмотрел торренты, и они тоже раздавались со скоростью значительно ниже ожидаемой. Зайдя в SpeedTest, я увидел такую картину:

Нюансы виртуальных коммутаторов Hyper-V

Я начал разбираться…

[+] Сегодня в программе

Первый этап диагностики

Мой ноутбук был подключен по Wi-Fi к двухдиапазонному маршрутизатору ASUS RT-N66U. Низкая скорость наблюдалась на обеих частотах, однако в других ПК и телефоне все было нормально. С подключением к проводной сети при отключенном Wi-Fi все тоже было в порядке.

Нюансы виртуальных коммутаторов Hyper-V

Все пути вели к беспроводному адаптеру Intel Centrino Advanced-N 6205 в ноутбуке. Он был не новый, и свежие драйверы к нему давно не выпускали. У меня была установлена последняя версия с WU. Поэтому я с легким сердцем удалил адаптер из диспетчера устройств, добавил снова, и все наладилось.

Повод для рассказа появился, когда спустя какое-то время проблема повторилась. Я воткнул кабель Ethernet, но скорость исходящего соединения осталась низкой. Отключился от Wi-Fi – скорость поднялась к ожидаемым 90+ Мбит/с.

Получается, при подключении одновременно к Ethernet и Wi-Fi система использовала беспроводное соединение с возродившейся проблемой.

На каждом заборе написано, что в Windows проводное подключение имеет приоритет над беспроводным. Другими словами, если вы одновременно подключены к Ethernet и Wi-Fi, в Интернет вы будет ходить по проводу.

У меня все было наоборот, и тут стоит достать из коробки еще один фрагмент пазла, который я держал в уме, но пока не пытался пристроить в картину.

Виртуальные коммутаторы

У меня виртуальные машины крутятся на Hyper-V, а в сеть ходят через созданный виртуальный коммутатор. Поскольку ноутбук почти всегда был подключен только к Wi-Fi, виртуальный коммутатор я создавал на основе адаптера беспроводной сети. Появившийся позже в 1709 «коммутатор по умолчанию» я не использовал.

Нюансы виртуальных коммутаторов Hyper-V

Когда я удалил беспроводной адаптер из диспетчера устройств, мой виртуальный коммутатор исчез, но я заметил это не сразу, а только спустя некоторое время при следующем включении ВМ – в ней не было сети.

Я создал виртуальный коммутатор заново, но измерить скорость исходящих подключений в тот момент мне в голову не пришло. Лишь напоровшись на проблему снова, я назначил Hyper-V главным подозреваемым.

Дело в том, что хост использует виртуальный сетевой адаптер vEthernet для подключения к сети. Даже если виртуальный коммутатор Hyper-V основан на беспроводном адаптере, подключение к vEthernet считается проводным.

Это не вполне очевидно, хотя название адаптера намекает :)

Приоритет маршрутов

При этом у меня подключение по vEthernet преобладало над обычным проводным подключением Ethernet. Сам я приоритеты не менял, но на всякий случай убедился в этом.

Приоритет маршрута определяется метрикой, и в дополнительных параметрах IPv4 сетевого адаптера можно посмотреть, задается ли она автоматически (и указать значение, если нужно).  Но давайте перейдем в командную строку.

Настройка приоритетa для сетевых интерфейсов

Из вывода всех команд я убрал лишнее, чтобы сфокусироваться на проблеме, а английский – язык моей ОС.

Команда ipconfig /all выводит список сетевых адаптеров и их IP-адреса.

ipconfig /all                                                                                   

Ethernet adapter Ethernet:
   Description . . . . . . . . . . . : Intel(R) 82579LM Gigabit Network Connection
   IPv4 Address. . . . . . . . . . . : 192.168.1.149(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0

Ethernet adapter vEthernet (Wi-Fi):
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
   IPv4 Address. . . . . . . . . . . : 192.168.1.211(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0

Ethernet adapter vEthernet (Default Switch):
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   IPv4 Address. . . . . . . . . . . : 192.168.70.17(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.240

Сводку по сетевым интерфейсам выдает команда netstat -rn | more.

netstat -rn | more                                                                              ===========================================================================
Interface List
  4...3c 97 0e ce b8 41 ......Intel(R) 82579LM Gigabit Network Connection
 32...a4 4e 31 94 9a 28 ......Hyper-V Virtual Ethernet Adapter
 22...a4 4e 31 94 9a 29 ......Microsoft Wi-Fi Direct Virtual Adapter #4
 10...a6 4e 31 94 9a 28 ......Microsoft Wi-Fi Direct Virtual Adapter #5
  9...3c 77 e6 ed 0d 46 ......Bluetooth Device (Personal Area Network)
  1...........................Software Loopback Interface 1
 64...00 15 5d 18 c5 02 ......Hyper-V Virtual Ethernet Adapter #2
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      192.168.1.1    192.168.1.211     10
          0.0.0.0          0.0.0.0      192.168.1.1    192.168.1.149     20
===========================================================================

В первом блоке можно определить приоритет сетевого интерфейса по номеру слева – чем меньше номер, тем выше приоритет. Значение метрики для интерфейса отображается во втором блоке – таблице маршрутов IPv4.

В результатах команд видно, что маршрут через виртуальный адаптер 192.168.1.211 преобладает над проводным 192.168.1.149.

Раз уж я был в консоли с правами администратора, то задал метрики для каждого интерфейса на месте. Сначала вывел их список, чтобы получить имена:

netsh interface show interface                                                                  
Admin State    State          Type             Interface Name
-------------------------------------------------------------------------
Enabled        Connected      Dedicated        Wi-Fi
Enabled        Connected      Dedicated        Local Area Connection* 3
Enabled        Connected      Dedicated        vEthernet (Wi-Fi)
Enabled        Connected      Dedicated        Network Bridge
Enabled        Connected      Dedicated        Ethernet
Enabled        Connected      Dedicated        vEthernet (Default Switch)

Затем указал метрики, поменяв значения местами:

netsh interface IP set interface interface="Ethernet" metric=10
netsh interface IP set interface interface="vEthernet (Wi-Fi)" metric=20

Теперь, подключив одновременно Ethernet и Wi-Fi, я убедился в высокой скорости исходящего соединения. Проводное соединение получило приоритет, но проблему низкой скорости по Wi-Fi это не решало, конечно.

Второй этап диагностики

В настройках Hyper-V я удалил попавший под подозрение коммутатор, что убрало связь между адаптером Wi-Fi и виртуальным адаптером Hyper-V. Без лишней прокладки адаптер беспроводной сети работал как положено – скорость исходящего соединения пришла в норму.

Я пообщался с Денисом Дягилевым, и он, в принципе, задал верное направление диагностики – параметры Virtual Machine Queue (VMQ). Однако такой настройки в настройках адаптера у меня не нашлось.

Решение

Первой мыслью было занести баг в Feedback Hub, но сначала положено искать, чтобы не плодить дубликатов. По запросу hyper- v switch нашлось описание моей проблемы, а заодно и обходной путь – отключение параметра Large Send Offload Version 2 (IPv4) в параметрах виртуального адаптера Hyper-V.

Нюансы виртуальных коммутаторов Hyper-V

Эти же сведения можно посмотреть в PowerShell:

Get-NetAdapterAdvancedProperty -Name vEthernet* | ? DisplayName -like 'Large Send Offload*' | ft -wrap

Name                      DisplayName                    DisplayValue                   RegistryKeyword RegistryValue
----                      -----------                    ------------                   --------------- -------------
vEthernet (Wi-Fi)    Large Send Offload Version 2   Enabled                        *LsoV2IPv4      {1}
                          (IPv4)
vEthernet (Wi-Fi)    Large Send Offload Version 2   Enabled                        *LsoV2IPv6      {1}
                          (IPv6)

и поменять значение, не покидая консоль:

Get-NetAdapterAdvancedProperty -Name vEthernet* | ? DisplayName -like 'Large Send Offload*v4*' | 
Set-NetAdapterAdvancedProperty -DisplayValue "Disabled"

Изменив настройки адаптера, я заново создал виртуальный коммутатор и проверил скорость – все наладилось.

Нюансы виртуальных коммутаторов Hyper-V

Конец квеста!

Заключение

Эта история произошла в 2018 году. Регрессия возникла в Windows 10 1809. Поскольку основная система у меня была в кольце Release Preview (RP), я напоролся на проблему еще до того, как сборку отозвали. Дефект устранили в декабре 2018 года накопительным обновлением KB4469342, первом после перевыпуска 1809. Мне в RP оно пришло чуть раньше, я протестировал и отписался в комментариях к статье о белках-истеричках.

Я писал материал по горячим следам, но Денис Дягилев подал идею протестировать пользу параметра Large Send Offload в практических сценариях. Времени на это я так и не нашел. А когда Microsoft устранила проблему, публикация вроде бы стала неактуальной. И я замариновал статью в черновиках – почти на 5 лет 🤷‍♂️

Однако за эти годы вопросы приоритета сетевых интерфейсов и особенно параметра Large Send Offload обсуждалась в чате неоднократно. И каждый раз я сетовал, что не выпустил статью в свет. На прошлой неделе тема LSO вновь всплыла 🍑🔥 со вполне современным сетевым адаптером, что окончательно убедило меня выложить материал в блог.

Бонус: о приоритете сетевых интерфейсов (когда метрики не помогают)

Иногда желаемого результата не удается достичь, меняя метрики маршрутов. Все равно LAN имеет приоритет над Mobile broadband, а Bluetooth PAN над WWAN (внезапно). В таких случаях должна помочь групповая политика, о которой я написал в канале.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Windows open ssh server
  • Не работают наушники на ноутбуке windows 10 bluetooth
  • Как установить принтер hp laserjet 1160 на windows 10
  • Canon i sensys mf4320d драйвер для windows 10
  • Что нужно для работы windows