How are we all doing
So recently following on for some security blogs ive been reading i decided i needed a fresh lab environment, so i decided to look into simplifying things to give my VM’s access to the internet. In the past while putting together my Hyper-V cluster environment with a little help i used the NAT functionality within Hyper-V, this can be very powerful as well as a handy way of segmentation.
Creating the NAT Switch
Using Powershell run the following commands
- Creating the VMSwicth to be used for the NAT
New-VMSwitch -SwitchName “NATSwitch” -SwitchType Internal
- Once created you can create the NAT gateway address for the switch we just created.
New-NetIPAddress -IPAddress 192.168.0.254 -PrefixLength 24 -InterfaceAlias “NATSwitch”
IPAddress — NAT Gateway IP specifies the IPv4 or IPv6 address to use as the NAT gateway IP
PrefixLength — NAT Subnet Prefix Length defines the NAT local subnet size (subnet mask)
InterfaceAlias— The alias of the switch created in the first step
- Now we create the subnet to be used for the Internal network to be NAT
New-NetNat -Name NatNetwork -InternalIPInterfaceAddressPrefix 192.168.0.0/24
Now you will be able to allocate manually/automatically via DHCP to the VM’s that are assigned to use this vSwitch with IP’s in the created network and use the IP created in the NetIPAddress as the Default Gateway. Your VM’s will now have access to the external resources.
Lab environment built and functioning 🙂