In this post I describe how to configure a Hyper-V virtual network switch into promiscuous mode. This mode allows you to monitor external traffic, eg. Needed for Microsoft Defender for IoT.
Assuming you already created an dedicated virtual network switch, you have to run these four steps.
- Turn off Allow management operation system to share this network adapter
- Turn off Enable virtual machine queue
- Set port mirroing mode to Destination
- Configure the Ethernet Switch Port Security Settings
My setup:
- Hyper-V Host – HOME-NUC01
- Virtual Network Switch – Span4IoT
- Virtual Machine – MD4IOT
Step #01: Turn off the management operation system to share this network adapter
- Open Hyper-V Manager > Select Action > Virtual Switch Manager > (your NIC) > External Network
- clear option Allow management operation system to share this network adapter

Step #02: Turn off Enable virtual machine queue
- Open Hyper-V Manager > (your VM) > Settings > (your NIC) > Hardware Acceleration
- clear option Enable virtual machine queue

Step #03: Set port mirroing mode to Destination
- Open Hyper-V Manager > (your VM) > Settings > (your NIC) > Advanced Features
- Port mirroring > Mirroing mode > Destination

Step #04: Configure the Ethernet Switch Port Security Settings
Run the following PowerShell cmdlets on the hyper-v host (not in the virtual machine)
#get VMSwitch Settings
Get-VMSwitch | ft Name, SwitchType, NetAdapterInterfaceDescription, AllowManagementOs
#
# configure the corresponding switch for monitorting
$VMSwitch = "Span4IoT"
$portFeature=Get-VMSystemSwitchExtensionPortFeature -FeatureName "Ethernet Switch Port Security Settings"
$portFeature.SettingData.MonitorMode = 2
Add-VMSwitchExtensionPortFeature -ExternalPort -SwitchName $VMSwitch -VMSwitchExtensionFeature $portFeature

In step 4, is this done after you start the VM and you run powershell on the VM itself or is step 4 done on the machine that hosts the hyper v and then run powershell and then start the VM? I’m trying to set this up to run Iot on my hyper v but it’s not working. Thanks and let me know!
LikeLike
Hi John,
you have to run the PoSH script (as Administrator) on the Hyper-V Host, not in the VM.
After this step I setup the MS Defender for IoT Sensor. After the installation, you shoud see at least 800 pps within the sensor interface, in my case I see 1677 pps
LikeLike