Score:0

How do I setup two NIC's on Hyper-V VM, one for physical network and one for internet access via NAT?

vg flag

I am running Hyper-V on a physical Windows 2019 server with a dual NIC. NIC #1 is connected to my office network, which is in turn, is connected to the internet. NIC #2 is connected to a separate physical desktop switch that has other physical PCs connected to it.

On the Hyper-V Server I am running a single VM which will act as DHCP, DNS and a Web Server for the Test Network. We are running multiple test sites on IIS and use the DNS to direct the test PCs to the local sites instead of the live ones. The VM connects to the physical switch via NIC #2 of the Host Machine.

My Host can access the internet fine but I want to set it up so that the VM Server and the PCs connected to the Test Network can access the internet through NIC #1 on the host using NAT.

The reason I want to do it this way is because when we do offline testing, I can simply unplug NIC #1 and everything will keep functioning but with no connection to the outside world. When I want to update the test PCs I can simply plug in NIC #1 and all the PCs and VM will be able to connect to the internet.

Diagram

I tried following this https://petri.com/using-nat-virtual-switch-hyper-v/ but I cant seem to get either the Virtual Machine OR the Test PCs to access the internet? I think the article I followed might be wrong for my setup as I have 2 separate NICs?

Score:0
in flag
BMC

Here's my use case, it's almost identical as yours.

Facts

Two physical NICs are connected to the Hyper-V host.

NIC1: subnet 10.0.0.0/24, this is the Internet enabled network

NIC2: subnet 192.168.100.0/24, no Internet access

Goal: enable Internet access for the NIC2 subnet by translating traffic to the NIC1 subnet

Solution

  1. Create an external Hyper-V switch named vEthernet (external), and connect it to NIC2. I used the Hyper-V manager.

  2. Create a new IP address for the newly created switch/interface. It will serve as the default gateway for the NIC2 subnet.

    PS > New-NetIPAddress -IPAddress 192.168.100.1 -PrefixLength 24 -InterfaceAlias `vEthernet (external)`
    
  3. Create the NAT network*

    PS > New-NetNAT -Name `NATNetwork` -InternalIPInterfaceAddressPrefix 192.168.100.0/24
    
  4. Assign the endpoints from the 192.168.100.0/24 subnet with 192.168.100.1 as the gateway, add a DNS server of your choice and enjoy Internet connectivity.

*) interestingly, I didn't have to specify ExternalIPInterfaceAddressPrefix, I assume it implicitly used the default gateway of the host.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.