« Back to home

Static IPs with NAT on Hyper-V

Posted on

The goal is to have networking with static ip addresses for virtual machines on Hyper-V. The machine must also be able to access the internet.

The easiest way is to start a Powershell session with elevated rights. Then use the follwing three commands. Feel free to change any names and ip address ranges.

  1. Create a new switch
New-VMSwitch -SwitchName "NAT Switch 192.168.40.x" -SwitchType Internal
  1. Assign and IP address
New-NetIPAddress -IPAddress -PrefixLength 24 -InterfaceAlias "vEthernet (NAT Switch 192.168.40.x)"
  1. Enable NAT
New-NetNAT -Name "NATNetwork" -InternalIPInterfaceAddressPrefix

This will result in:

  1. a virtual network interface card (vEthernet) that has ip assigned to it.
  2. a virtual network switch (NAT Switch 192.168.40.x) that can be connected to virtual machines
  3. Network Address Translation (NAT) between vEthernet and the the hosts physical network connection.


Be sure the configure networking on your virtual machines as follows:

Address: 192.168.40.<anything between 2 and 254>

That's it!

« Back to home