Connecting VNets in Azure with VNet Peering

1 hour
  • 2 Learning Objectives

About this Hands-on Lab

Welcome to this Azure hands-on lab, where we connect multiple virtual networks and test connectivity. In many real world scenarios, it’s common to have multiple VNets. Using VNet Peering, we can provide secure, low-latency, high-bandwidth connectivity between VNets. The goal of this lesson is to gain knowledge and experience with the configuration of VNet peering as well as understand basic features and limitations.

VNet peering is important in many scenarios. One example is when our organization has resources in different regions or subscriptions. This is also used in many common Azure architecture patterns, such as Hub and Spoke. Good luck and enjoy the lab!

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Configure VNet Peering

Architectural notes:
In the architecture of this hands-on-lab, we consider app1-vnet and dev1-vnet to be "spoke VNets". Both of these VNets connect to core1-vnet which is considered the "hub VNet".

Configure VNet Peering

Configure Peering Between app1-vnet and core1-vnet

  1. In the Azure Portal, open the portal menu.
  2. Click on the all resources option.
  3. Click on the app1-vnet resource.
  4. Click Peerings and then Add.
  5. Set the following values:
    • Name: "app1-to-core1"
    • Deployment model: Resource manager
    • Subscription: Leave the default subscription selected
    • Virtual network: core1-vnet
    • Name: "core1-to-app1"
    • Configuration settings: Leave as the default value
  6. Click OK.

Configure Peering Between dev1-vnet and core1-vnet

  1. In the Azure Portal, open the portal menu.
  2. Click on the all resources option.
  3. Click on the dev1-vnet resource.
  4. Click Peerings, and then Add.
  5. Set the following values:
    • Name: "dev1-to-core1"
    • Deployment model: Resource manager
    • Subscription: Leave the default subscription selected
    • Virtual network: core1-vnet
    • Name: "core1-to-dev1"
    • Configuration settings: Leave as the default value
  6. Click OK.
Test Network Connectivity

Test the Peering Connectivity

Notes: See the instructions below for how to connect to each VM.

  1. From app1vm, perform a test ping using the private IP of core1vm:
    • For example: ping 10.1.1.4
    • What does this tell us?
    • Why does this work or not work?
  2. Perform a test ping from app1vm to dev1vm:
    • For example: ping 10.3.3.4
    • What does this tell us?
    • Why does this work or not work?

Help Connecting to VMs and Pinging VMs

  1. Navigate to All resources, and click on a VM (e.g. app1vm).

  2. Copy the public IP address (from the left-hand side, in the overview) and paste it into a text file, as we’ll need it to access the VM via SSH.

  3. Copy its private IP and paste it into a text file, as we’ll need it to perform the ping tests.

  4. Log in, replacing PUBLIC_IP with the one copied a minute ago:

    ssh [email protected]_IP
  5. Perform ping tests using the following command, replacing PRIVATE_IP with the IP address of the VM we copied that we’d like to test.

    ping PRIVATE_IP

Note: Connecting to the Linux VMs will require SSH.

  • Using macOS, we can run the provided ssh command after launching terminal.
  • Using Linux, we can run the provided ssh command from our bash/shell.
  • Using Windows, we can use one of two options:

Additional Resources

Scenario

We are working as an Azure administrator for The Pupper Camp, a fictitious dog services company which operates across America. In our role as an Azure adminstrator, we've been asked to help provide secure network connectivity from two different virtual networks (VNets) to a central VNet. We need to configure VNet peering from each VNet to the central VNet.

Instructions

Please go ahead and log in to the live environment with the Azure Labs credentials provided.

Follow the steps below to configure VNet peering. Feel free to try the steps without the videos first, and then use the videos to verify the solution.

In order to test the solution works, connect to the VMs and perform ping tests. Please use the following information:

  • Use SSH to log into into each Linux test VM.
  • Linux, Mac, or users with Windows Subsystem for Linux (WSL) can use SSH.
    • Cloud Shell can also be used for SSH.
  • Other users may wish to use PuTTY (e.g. on Windows when WSL is not installed).
  • Use the credentials provided on the lab page.

Click the icons below to view more details for each task.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?