Заметки
После недавнего обновления (KB4041994) Windows 10 решила сделать мне хорошо и удалила более не поддерживаемую утилиту «Realtek Ethernet Diagnostic Utility».
Незадача в том, что утилита позволяла, пусть и коряво, сделать несколько VLAN на встроенной сетевой карте с чипом RTL8168. Итого образовалась ситуация: чип аппаратно умеет VLAN, а программно как-бы уже не умеет без вышеупомянутой утилиты.
Получилось решить обходным путём через подсистему Hyper-V (должно работать на Windows 10 Pro/Enterprise) путём выполнения следующих действий.
1. Установить компоненты Hyper-V, выполнив в PowerShell из-под администратора
После этого следует убедиться что выбран пункт «Hyper-V» и все его подпункты в разделе «Панель управления\Все элементы панели управления\Программы и компоненты — Включение и отключение компонентов Windows».
2. Перезагрузить ЭВМ.
3. Запустить «Пуск — Средства администрирования Windows — Диспетчер Hyper-V».
В диспетчере слева в списке выбрать свой компьютер по его имени, справа «Диспетчер виртуальных коммутаторов», посмотреть в нём список «Виртуальные коммутаторы». В списке должен быть «Коммутатор по умолчанию». Тут пришлось создать ещё один виртуальный коммутатор с именем VSwitch0 (имя не принципиально), так как на «Коммутатор по умолчанию» не взлетело. Получилось как на картинке.

где
<VLAN_NAME> — предпочитаемое имя VLAN в системе, например «eth0.1234» или «backup internet»;
<VLAN_ID> — идентификатор VLAN;
<MAC> — желаемый MAC-адрес виртуального адаптера вида «DE-AD-11-11-DE-AD»;
<VIRTUAL_SWITCH_NAME> — имя виртуального коммутатора из шага 3, в моём случае «VSwitch0».
VLAN Tagging Software for Windows 10 without Proset drivers

Adding a new VMswitch and network adapter using the Hyper V PowerShell cmdlets
If you are like me, you may interact with multiple network segments and VLANS configured for different purposes. However, what if you have a workstation that is not configured with an Intel ProSet card with enterprise software that allows tagging multiple VLANs? Is all hope lost if you have just a generic card that is not of the Proset or Broadcom enterprise variety that lacks the software for VLAN tagging? Let’s take a look at VLAN tagging software for Windows 10 and see how you can effectively do this without an Intel Proset or Broadcom card with the enterprise driver set.
Why do you need to tag multiple VLANs?
You may wonder, in Windows 10 you will most likely see under the advanced settings for the adapter configuration you have the ability to populate a VLAN ID. Isn’t this all that is needed? Yes, you can tag a single VLAN. This means that you can tag your traffic for a specific VLAN. For many Windows 10 users, this may suffice and be all you need.

Assigning a VLAN ID in Windows 10
However, if you are like me, you may have multiple VLAN segments associated with your home lab environment and need to have the ability to place your workstation into those multiple VLAN segments at a Layer 2 level. You may wonder – why wouldn’t you just rely on a Layer 3 route to take care of connectivity between segments? You can do that and arguably it is more efficient and less problematic to route traffic at layer 3 for most use cases.
However, as a case in point, what if you are running an installation of VMware Workstation and you have multiple VMs that you want to be placed in different segments of your network and acquire a DHCP address from those various segments? For that, you need to be able to tag multiple VLANs.

VLAN Tagging Software for Windows 10
In case you have a workstation running Windows 10 and need to be able to tag multiple VLANs, there is a way to do this without installing third-party software or a shady utility. You can do this by installing Hyper-V in Windows 10.
Even if you don’t plan on running any virtual machines on top of the Hyper-V platform, installing Hyper-V and the PowerShell cmdlets allows creating virtual network connections that CAN tag specific VLANs and tag multiple VLANs.
Run the optionalfeatures command to quickly get to the Windows Features. Be sure to install Hyper-V and Hyper-V module for Windows PowerShell.

Installing Hyper V in Windows 10
After installing Hyper-V, you will be prompted to reboot. After rebooting, you should be able to run the Hyper-V PowerShell cmdlets. Notice below, you can see the virtual switches installed by running the command:
With the Hyper-V platform installed, you can add virtual switches and adapters that will allow tagging specific VLANs. As you see below, you can’t add this to the Default Switch. Rather, you need to add a new Hyper-V virtual switch and pass this into the Set-VMNetworkAdapterVlan command.

Adding a new VMswitch and network adapter using the Hyper V PowerShell cmdlets
You can also use the Hyper-V Manager console and the Virtual Switch Manager to add a new virtual switch and then select to Enable virtual LAN identification for management operating system to define the VLAN tag for the virtual switch.

Adding a new External virtual switch using the Hyper V Manager console
A bit of irony here, but to go along with the example I gave above with VMware Workstation, you can create a bridged connection in the Virtual Network Editor that is bound to one of the Hyper-V virtual switches tagged with a specific VLAN. In this way, your VMs running in VMware Workstation can be placed on the specific VLAN segments they need to communicate with easily.
Also, you can easily remove the virtual network adapter setup for this purpose by using the command:

Removing the network adapter added for VLAN tagging
Adapter Precedence and routing
One little oddity I ran into when I added the new adapter via the Hyper-V virtual switch, I started having a few routing issues from my workstation. One thing I noticed, a subnet that I was able to ping before, was now unreachable. What gives? Adapter precedence. After a bit of troubleshooting, I figured out the traffic was now using a different adapter for the primary interface for communicating out.
You can tweak this behavior by setting interface precedence. In Windows 10, this is easily done using PowerShell. Before setting the precedence, you can get the information you need using the Get-NetIPInterface command. Using this cmdlet, you can see the ifIndex and the InterfaceMetric, both of which you will need to set the precedence.

Using the GetNetIPInterface command to list out interfaces
If like me, you lose connectivity after adding the Hyper-V virtual switch tagging a specific VLAN, there is a good chance the new adapter has become your primary interface and may be causing issues with your connectivity. Using the Set-NetIPInterface cmdlet allows easily setting the precedence of your adapters. Find the adapter you want to be the primary or the one that was primary before and use its InterfaceIndex to set the InterfaceMetric to a lower value than all the other adapters.
Wrapping Up
If you don’t have a fancy network adapter like an Intel ProSet or Broadcom card with the enterprise drivers and fully-featured capabilities such as VLAN tagging, you do have VLAN Tagging Software for Windows 10 with Hyper-V installed. Installing Hyper-V provides the virtual interfaces needed for Windows 10 to use these along with VLAN tagging. You can have multiple virtual adapters as a result of configuring these in Hyper-V using either PowerShell or the Hyper-V Manager that provides the multiple VLAN tagging capabilities missing in regular Windows 10 network adapter properties for VLAN tagging.
Настраиваем Windows для работы с VLAN
Если вы пытались работать с VLAN под Windows, особенно при попытке получить доступ к VLAN на физическом оборудовании из виртуальных машин под Hyper-V или VMware, у вас, скорее всего, ничего не получилось.
Всё дело в том, что раньше Windows не имел встроенного механизма работы с VLAN, но в последних версиях Windows Server он появился.
Драйвера сетевых адаптеров, по умолчанию, обрезают в пакетах все VLAN-тэги и внешние VLAN становиться недоступными.
В этой статье мы рассмотрим, как настроить windows 10 таким образом, чтобы адаптер не обрезал VLAN-тэги у пакетов, приходящих на заданный интерфейс.
В Windows 10 есть возможность указать VLAN в настройках адаптера, но это вариант, для отдельных случаев и нам он не подходит, если мы работаем с эмуляторами ЛВС, например, GNS3. У нас может быть сколько угодно виртуальных сетей с разными VLANID и каждый раз менять в настройках адаптера VLAN нам не подходит.
В Wireshark эта проблема давно известна, и они создали в своей wiki страницу , на которой описали варианты решения проблемы для нескольких производителей чипов для сетевых адаптеров.
Я использую адаптер — D-Link DUB-E100 USB2.0, и всё описанное ниже, помогло заставить работать VLAN в GNS3.
Настройка адаптера
Сперва нам нужно узнать GUID нашего адаптера, в моем случае это USB-адаптер, для этого запускаем PowerShell с правами админа и запускаем команду:
Смотрим ifIndex нужного устройства, у меня он равен 8.
Запускаем regedit с правами администратора.
Откройте в нём следующий путь (просто вставьте в строку поиска на самом верху и нажмите Enter):
В списке справа найдите раздел с номером своего адаптера, в моем случае это 008.
Всё что нам осталось это изменить значения нескольких значений:
Как показано на рисунке:

После этого обязательно перезагрузите ПК.
Вот и всё, после загрузки ПК у вас должен заработать VLAN, например, в GNS3.
Единственным недостатком можно назвать появление «мусора» в дампе Wireshark на настроенном интерфейсе, например, такого:
Но его можно и отфильтровать, так что это не такая большая проблема. Именно поэтому я и использую сетевой usb-адаптер, чтобы эксперименты не вредили реальной ЛВС.
Если вы знаете способ избавиться от этой проблемы – пишите в комментариях.
Заключение
Сегодня мы рассмотрели настройку Windows с целью разрешить доступ к физическим VLAN из виртуальных серверов.
Passing VLANs through in Windows 10 (Realtek)
Let’s say you have a managed switch or two and you want to be able to connect things on your computer onto a different VLAN. Normally you would have to have a seperate NIC on your computer to tie into an untagged VLAN port on the switch, however you can setup a virtual NIC within windows that takes tagged packets coming in off your main interface!
Step 1
Setup your managed switch to send tagged packets of the VLANs you want to access onto your computer. This varies from manufacturer to manufacturer but in the case of our 3Com switch, you set the port as a ‘Trunk’ port allowing tagged packets to be sent down it.
It is also important to verify that the port’s PVID is 1 (or whatever VLAN number your main network is). This allows any untagged packets coming from your computer under normal cases to pass onto your LAN.
It should also be possible to connect this trunk port through an unmanaged switch and then your computer, but I haven’t completely tested this yet.
Step 2
Your computer is now receiving some VLAN tagged packets, but is rejecting them. For realtek network interfaces, download the tool from their website here.
Browse to your interface, select VLAN and then click add typing in the number of the VLAN you want to receive on this interface. The utility will hang for a few seconds and your network adapters will drop and reconnect with a new interface!
Now you have an extra interface, but windows will probably decide to send most (if not all) your traffic over this newly created interface. To fix this, we can set the priorities of the network interface.
- Open up ‘Network Connections’ (in windows 10 easiest shortcut is Win+X -> Network Connections).
- Open properties on your normal interface
- IPv4 Properties -> Advanced
- Uncheck Automatic Metric and type in 10
- Close and Save all the windows and now do the same for the new VLAN interface but with a metric of 20
This gives a lower priority to the VLAN interface and sends your traffic properly over your main interface (untagged).
Disabling your main interface will also disable the VLAN interface, to test something on the VLAN, simply set the VLANs metric to a lower number than your main interface.