Installing and Configuring Network Address Translation (NAT) on a Virtual Machine to connect Virtual Machines running in an Internal or a Private Hyper-V Virtual Switch

Home > Blogs > Windows Server 2012 > Installing and Configuring Network Address Translation (NAT) on a Virtual Machine to connect Virtual Machines running in an Internal or a Private Hyper-V Virtual Switch

Installing and Configuring Network Address Translation (NAT) on a Virtual Machine to connect Virtual Machines running in an Internal or a Private Hyper-V Virtual Switch

Like This Blog 2Rick Trader
Added by December 19, 2014

If you are running your virtual machines in an Internal or a Private network and you need to provide them with internet or connectivity to your corporate network there are a couple different solutions.  One solution is to use a virtual machine as a router.  In this blog I will discuss how to configure your host as the solution.

If the Virtual Machines are using an Internal Virtual Network check out this blog on how to configure a NAT on your host machine to provide the access to your corporate network and the internet.

Note:  Before configuring the Virtual Machine to provide network connectivity there are a few networking prerequisites that have to be completed within Hyper-V.

I have not configured any virtual networks  yet.  Figure 1 shows that I only have the host’s physical network card available in Network Connections pane.

001-using-you-host-computer-on-virtual-machines-running-hyper-v

Figure 1.

Use the Hyper-V Manager to create an External and a Private virtual networks.  The steps would be the same if using an Internal virtual network.

  1. Click on Virtual Switch Manager .002-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. With External highlighted click on Create Virtual Switch.
    003-using-you-host-computer-on-virtual-machines-running-hyper-v

 

  1. Replace New Virtual Switch Name your desired name and press OK.
    004-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. Click Yes to the Apply Network Changes dialog box.
    005-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. Click on Virtual Switch Manager.
    006-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. With Private highlighted click on Create Virtual Switch.
    007-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. Replace New Virtual Switch Name with your desired name and press OK.
    008-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. Network Connections on the host machine will now show 3 network adapter cards.
    009-using-you-host-computer-on-virtual-machines-running-hyper-v

 

Note that the cards names will include the names you used when you created them in Hyper-V.

Using Hyper-V Manager configure the virtual machines to connect their Network card to the newly created Internal Virtual Network.

Note:  The virtual machine that will be configured as the router must have at least 2 network adapter cards.

  1. Select the appropriate Virtual Machine and Click on Settings…
    010-using-you-host-computer-on-virtual-machines-running-hyper-v
    011-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. In the Settings window select Network Adapter in the hardware pane and then select the appropriate network from the drop down Virtual switch menu in the right hand pane and click OK.
    012-using-you-host-computer-on-virtual-machines-running-hyper-v
You may also like:  Using Deployment Image Servicing and Management (DISM.EXE) tool to convert to the MiniShell on a Windows Server 2012 R2 Datacenter

Configure the Virtual Machines NIC with an IP Address from the Private virtual network.

  1. Start the Virtual Machine if Required.
  2. Logon to each of the Virtual Machine and configure their IP addresses or allow DHCP to configure them.
  3. Using the Properties of the network adapter set an IP Address from the Private network. I will be using 172.16.0.10/24 with Gateway of 172.16.0.1 and a DNS server address of 8.8.8.8.

Configuring the Virtual router.  In my example it will be server 2

  1. Select the appropriate Virtual Machine and Click on Settings…
    013-using-you-host-computer-on-virtual-machines-running-hyper-v
    014-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. In the Settings window select Network Adapter in the hardware pane and then select the appropriate network from the drop down Virtual switch menu in the right hand pane and click OK. One Network Adapter will we set to External and one to Private.  As seen below.
    015-using-you-host-computer-on-virtual-machines-running-hyper-v

Configure the Virtual Router Computer Private NIC with an IP Address from the Private virtual network.

  1. Start and logon to the router.
  2. Using the Properties of the network adapter identified as Private, set an IP Address from the Private network. I will be using 172.16.0.1/24 with no Default Gateway or DNS server addresses.
  3. If DHCP is not being used on the external network using the Properties of the network adapter identified as External, set an IP Address from the External network.

The computer’s network prerequisites have been completed.  It is now time to configure the router computer to provide connectivity to the corporate network and the internet.

Install Routing and Remote Access on the router computer.

  1. Open Server Manager, select Add roles and features.
    016-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. On the Before you begin click Next.
  2. On the Select installation type, ensure Role-based or feature-based installation is selected, click Next.
  3. On the Select destination server, ensure the proper server is selected, click Next.
  4. On the Select server roles, select Remote access.
    017-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. On the Add Roles and Feature Wizard, click Add Features then click Next.
    018-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. On the Select features, click Next.
  2. On the Remote Access, click Next.
  3. On the Select role services, select Routing, click Next.
  4. On the Web Server Role (IIS), click Next.
  5. On the Select role services, click Next.
  6. On the Confirm installation selections, select Restart the destination server automatically if required, click Yes to prompt, click Install.
You may also like:  Are you still using Internet Explorer 10 or earlier?

WARNING:  Server will restart after installation is complete.

 

019-using-you-host-computer-on-virtual-machines-running-hyper-v

      13. After the server restarts, Logon, on the Installation progress, click Close.

020-using-you-host-computer-on-virtual-machines-running-hyper-v

Configuring Routing and Remote Access as a Network Address Translation (NAT) server.

  1. Open Server Manager, Select the Tools drop down menu, select Routing and Remote Access.
    021-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. Right click on the server and select Configure and Enable Routing and Remote Access.
  2. On the Welcome screen, click Next.
  3. On the Configuration page, select Network address translation (NAT), click Next.
    022-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. On the NAT Internet Connection, select which Interface is your external interface (Public), click Next.
    023-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. On the Name and Address Translation Service, select I will set up name and address services later, click Next.
    024-using-you-host-computer-on-virtual-machines-running-hyper-v
  1. On the Complete the Routing and Remote Access Server Setup Wizard, click Finish.
  2. If a prompt appears saying unable to open VPN Ports click OK to acknowledge.
  3. Nat is now installed.

Your Virtual Machines now have access to the internet and your corporate network.

Until next time, RIDE SAFE!

Rick Trader
Windows Server Instructor – Interface Technical Training
Phoenix, AZ

Videos You May Like

Agile Methodology in Project Management

0 63 0

In this video, you will gain an understanding of Agile and Scrum Master Certification terminologies and concepts to help you make better decisions in your Project Management capabilities. Whether you’re a developer looking to obtain an Agile or Scrum Master Certification, or you’re a Project Manager/Product Owner who is attempting to get your product or … Continue reading Agile Methodology in Project Management

Subnetting a TCP/IP Network using the Magic Box Method

0 420 2

In this session, we are going to look at how to subnet a Class B address into multiple network segments using what's called The Magic Box. Let's run through this real quick.

Detailed Forensic Investigation of Malware Infections – April 21, 2015

2 211 2

In this IT Security training video, Security expert Mike Danseglio (CISSP / CEH) will perform several malware investigations including rootkits, botnets, viruses, and browser toolbars.

Write a Comment

See what people are saying...

  1. k.6

    Hello there,
    Thanks for the informative article. Please throw some light on this issue.

    SCOPE : I am trying to set up a lab using Server 2012 and hyper-v , where the first thing I want to achieve is that my Virtual Machines are able to achieve IP address through the DHCP server which happens to be the HOST machine.
    I ll start off with 2 VM ( Win 8,7 ) and slowly grow my network by installing more VM like Server, Exchange Server etc.
    Here is the detail of the network and hardware and all the work I have done step-by-step

    Hardware : Machine I5 processor ,8 GB Ram not connected to any router or switch.
    I could not get the wireless to work but connects to the home network using the Ethernet Card : Realtek Card 1GB
    Software : Windows Server 20102 r2

    Steps I have done so far :
    1. Ran the add roles and features and installed DHCP, DNS and Hyper-V.
    2. Started Hyper-V and added the Virtual Internal Switch and then added two new VM ( Win 8 ) and added the internal virtual switch to them.
    3. If I give static IP to the Virtual Internal Switch in Host and then the two VM. All of them in same subnet.
    Disable firewall in all the machines. RESULT : All the VM and the host machine are able to PING each other.
    However, if I provide static IP to the Internal Switch in HOST and leave the VM on DHCP, I am not able to get IP address to my VM.
    With that being said, what is it that I am missing in the picture , in order to achieve that.

  2. Pingback: Using your Virtual Machines running on an internal Hyper-V

Share your thoughts...

Please fill out the comment form below to post a reply.