Mastering Windows Server 2016 Hyper-V

(Romina) #1

updates that can be used by all.


Hyper-V supports all three PVLAN modes, but this is not exposed through the
graphical Hyper-V Manager. Instead, all configuration is done in PowerShell by using
the Set-VMNetworkAdapterVlan cmdlet. Remember that each VLAN can be used as the
primary VLAN of only one isolated PVLAN, so ensure that different VLANs are used as
the primary for your isolated PVLANs. Note that the same secondary VLAN can be
used in multiple isolated PVLANs without a problem. The following configurations are
some that you will perform for PVLAN via PowerShell.


To set a VM in isolated mode, use this command:


Set-VMNetworkAdapterVlan –VMName testvm –Isolated –PrimaryVlanId 100 `
–SecondaryVlanId 200


Use this command to set a VM in community mode (note that the secondary VLAN ID
sets the community for the VM):


Set-VMNetworkAdapterVlan –VMName testvm2 –Community –PrimaryVlanId 100 `
–SecondaryVlanId 201


Use this command to set a VM in promiscuous mode (note that the secondary VLAN
is now a list of all VLAN IDs used in the community and for the isolated):


Set-VMNetworkAdapterVlan –VMName testvm3 –Promiscuous –PrimaryVlanId 100 `
–SecondaryVlanIdList 200–400


To check the configuration of a virtual machine, use the Get-VMNetworkAdapterVlan
cmdlet, as in this example:


Get-VMNetworkAdapterVlan –VMName testvm | fl *


The preceding commands assume that a virtual machine has a single network adapter,
which essentially changes the configuration for the entire virtual machine. If a virtual
machine has multiple network adapters and you wish to configure only one of the
virtual network adapters, then pass the specific network adapter to the Set-
VMNetworkAdapterVlan cmdlet. For example, the following command sets the VLAN for
the virtual network adapter with the MAC address (remember, you can view the MAC
addresses of all the virtual machines’ NICs with the command Get-VMNetworkAdapter
-VMName "VMName"). This command lists all of the adapters for the VM, narrows the list
down by the one that matches the passed MAC address, and then passes that adapter
to the Set-VMNetworkAdapterVlan cmdlet:


Get-VMNetworkAdapter -VMName "VMName" | where {$_.MACAddress -like "00155DADB60A"}
| Set-VMNetworkAdapterVlan -Isolated -PrimaryVlanID 100 -SecondaryVlanId 200


Some configuration of PVLANs is also possible using SCVMM, but only isolated mode
is supported, and not promiscuous or community mode. If you are using SCVMM and
wish to have promiscuous and community mode virtual machines, you will need to

Free download pdf