Windows Hyper-V NAT Mode

 

Windows

Step 1:

Creating Internal NAT Virtual Switch:

To create NAT switch, we need to run the below command on Windows Administrator PowerShell and check the status.

PS C:\> New-VMSwitch -Name NATSWITCH -SwitchType Internal

After running the command you will get the display shown below.

Hyper-V-Virtual-Switch

Run the Get-NetAdapter command to get the ifindex (connected interface) and Virtual Switch details.

Hyper-V-Virtual-Switch

Step 2:
Run the below command to configure NAT Gateway IP.

PS C:\> New-NetIPAddress –IPAddress 192.168.103.185 -PrefixLength 24 -InterfaceIndex 14

For above command:
NAT Switch IP Address is: 192.168.103.185(NAT GATEWAY IP)
Prefix Length: 24 (Subnet mask)
Interface Index: 14 Connected interfaces (See above screenshot for interfaces)

After running this command and it displays the required brief details, refer below screenshot.

Hyper-V-Virtual-Switch

Step3:
Now run the below command in order to configure NAT Network. To assign NAT IP segment(192.168.103.0/24), we have to use Host Machine VMs.

PS C:\> New-NetNat -Name NATSWITCH -InternalIPInterfaceAddressPrefix 192.168.103.0/24

InternalIPInterfaceAddressPrefix: Internal NAT Network IP Range with the Subnet mask.

Hyper-V-Virtual-Switch

Once completed the above commands, and the Virtual Machines is created on Hyper-V Host, they need to be configured. Virtual Machines are configured as 103.xx series IP range, and Gateway is configured as 192.168.103.185. Since NAT Gateway is already configured in Step2.

  • Hyper-V host, Virtual Adaptor configured as 192.168.102.190
  • NAT Gateway configured on NATSWITCH (Internal Switch) 192.168.103.185
  • 3 three Win10 Virtual Machines configured in Hyper-V host and IP address configured as 192.168.103.186, 187 & 188

Now we need to check if the Virtual Machines are able to ping the External IP or not.

Pinging from VM1

Virtual Machine 1 configured IP address as 192.168.103.186 and trying to ping destination IP 192.168.102.25 are able to ping.

Hyper-V-Virtual-Switch

We can see the NAT session from Hyper-V Host Machine. Refer the below screenshot.

Hyper-V-Virtual-Switch

Pinging from VM2

Virtual Machine 2 configured IP address as 192.168.103.187 and trying to ping destination IP 192.168.102.142 are able to ping.

Hyper-V-Virtual-Switch

Now we will be able to see the NAT session from Hyper-V Host Machine. Refer the below screenshot.

Hyper-V-Virtual-Switch

Popular posts from this blog

Mikrotik v.7 Using cell lock on LHG LTE18

Zabbix Proxy RAM config