Mastering Windows Server 2016 Hyper-V

(Romina) #1
New-VMSwitch    -SwitchName "NATSwitch" -SwitchType Internal
New-NetIPAddress –IPAddress 192.168.1.1 -PrefixLength 24 `
-InterfaceAlias "vEthernet (NATSwitch)"
New-NetNat –Name NATnetwork -InternalIPInterfaceAddressPrefix
192.168.1.0/24

To  create  a   NAT static-forwarding   rule    to  send    traffic directed    to  the host    to  a   VM,
use the following:
#Map the host IP to port 80 on VM 192.168.1.10 through switch
Add-NetNatStaticMapping -NatName NATnetwork -Protocol TCP `
-ExternalIPAddress 0.0.0.0 `
-InternalIPAddress 192.168.1.10 -InternalPort 81 -ExternalPort 81

PRIVATE VIRTUAL NETWORKS


Private virtual networks are visible only on virtual machines, and they are used for
virtual machines to communicate with each other. This type of network could be used
for virtual machines that are part of a guest cluster. The private network could be used
for the cluster network, provided that all hosts in the cluster are running on the same
Hyper-V host.


In most cases, an external switch is used, because most virtual machines require
communications beyond the local Hyper-V host, with internal and private networks
used in testing and niche scenarios, such as the guest cluster that is confined to a
single host. However, most likely, if you were creating a production guest cluster in
virtual machines, you would want them distributed over multiple Hyper-V hosts to
protect against a host failure, in which case an external switch would be required.


A single physical network adapter can be bound only to a single external switch, and in
production environments it’s common to use NIC Teaming on the Hyper-V host. This
allows multiple network adapters to be bound together and exposed to the operating
system as a single teamed network adapter, which provides resiliency from a network
adapter failure as well as aggregated bandwidth that enables higher-speed
communications. (There are many caveats around this, which I cover later in this
chapter.) A teamed network adapter can also be used and bound for an external switch
with Hyper-V, giving all of the virtual network adapters connected to that switch
additional resiliency.


If you have numerous network adapters in a host and they connect to different
networks (which may, for example, use VLANs to isolate traffic), then, if virtual
machines need access to those networks, you would create multiple external virtual
switches, with each bound to the physical network adapter connected to one of the
networks. It may seem obvious, but virtual machines can communicate only with the
other services that are available on that physical network or can be routed via that
network. Effectively, you are expanding the connectivity of the physical network
adapter to virtual machines via the virtual switch.

Free download pdf