In this article, I will teach you. How to create a NAT switch on Hyper V. Before going into the technical definitions, I will explain in a few words, what a NAT switch is.
This type of switch is available by default if you have already used another hypervisor, such as VMware or VirtualBox. You can allow to creating an isolated network for virtual machines with Internet access.
On Hyper-V, this option is not natively available, but it is impossible with PowerShell to configure a virtual internal switch with the NAT option, which will allow your virtual machines to have access to the Internet while being isolated “from the network.
Create an Internal Switch
The initial step will be to create an internal switch.
1. Open the PowerShell command as administrator.
2. To create a virtual commutator on Hyper-V, using the New-VMSwitch cmdlet.
New-VMSwitch -Name "NAT" -SwitchType Internal
- We can check at the Hyper-V console to see if the virtual switch has been made and see the network card on the computer.
NAT Virtual Network Configuration
Now that the network button has been created, the network connected to this ci switch must be configured. This part is done in two steps, we will start configuring the IP address of the network card in the Hyper-V host and then activate NAT functionality.
- To create the configuration, we always use PowerShell.
1. To set up an IP address on a network card of the Hyper-V host, you must use the New-Net IPAddress cmdlet showing the IP address of the network card, the subnet mask length, and the network card.
New-NetIPAddress -IPAddress 192.168.200.1 -PrefixLenght 24 -InterfaceAlias "vEthernet (NAT)"
- You can confirm the configuration by checking the network card details in the Hyper-V host.
2. We will now activate NAT functionality on the network, so we must use the New-NetNat cmdlet by displaying the name and IP address.
New-NetNat -Name NAT -InternalIPInterfaceAddressPrefix 192.168.200.0/24
- You now understand how to set up a NAT virtual switch on Hyper-V. Unlike other virtualization solutions, Hyper-V does not integrate a DHCP server. You must configure the IP addresses of the virtual machines manually or create a Windows server with a DHCP role.
In Hyper-V, use the NAT Switch on a Virtual Machine
- Now I will explain how to use the virtual switch that we just created.
- In Virtual Machine Settings, you must select a NAT switch.
- On a virtual machine, go to the IPv4 protocol network configuration and connected to the NAT switch.
- In IPv4 architecture, indicate a free IP address, with a subnet mask, at the default gateway, indicate the IP address of the network card of the Hyper-V host and indicate a DNS Server.
- Test your optimal performance by browsing the Internet or by using Resolve-DnsName and Test-NetConnection PowerShell cmdlets as in the screenshot below.
Using a NAT switch on Hyper-V is the “simplest” solution to “isolate” the virtual machines and allow them to access the Internet. Before this functionality was implemented, it was necessary to go through connection sharing or install a virtual machine with the role of a router.
If you have any questions or queries about this article, please comment below, and we’ll get back to you. Check more daily updates to get subscribe to our website and also you can get informational articles and much more etc.