I will give an example of creating virtual switches, configuring network and NAT in Hyper-V.
Open PowerShell from the menu or by running the command in the command line (as administrator):
Let’s see a list of existing network adapters:
Let’s see the existing NAT networks:
Let’s see the existing IP addresses:
I will give examples of creating new switches with the network type “Internal”, “Private”, “External”:
New-VMSwitch -SwitchName "IXNFO_COM_Switch" -SwitchType Internal New-VMSwitch -name PrivateSwitch -SwitchType Private New-VMSwitch -name ExternalSwitch -NetAdapterName Ethernet -AllowManagementOS $true
Examples of adding a gateway to a new switch:
New-NetIPAddress -IPAddress 192.168.5.1 -PrefixLength 24 -InterfaceIndex 38 New-NetIPAddress -IPAddress 192.168.5.1 -PrefixLength 24 -InterfaceAlias "vEthernet (IXNFO_COM_Switch)"
New-NetNat -Name "vNAT" -InternalIPInterfaceAddressPrefix 192.168.5.0/24
Example for removing NAT network and gateway:
Get-NetNat | Remove-NetNat Get-NetIPAddress Remove-NetIPAddress -IPAddress 192.168.5.1 -InterfaceIndex 44 Remove-NetIPAddress -IPAddress 192.168.5.1 -InterfaceAlias "vEthernet (IXNFO_COM_Switch)"
Example of removing a virtual switch:
Remove-VMSwitch -SwitchName "IXNFO_COM_Switch"
You can also manage virtual switches through Hyper-V Manager > Virtual Switch Manager.
See also my articles:
- Install Hyper-V
- Why Hyper-V virtual machines are not always available over the network
- The solution to the error “Virtual machine could not be started because the hypervisor is not running”