The goal of this task is to establish a peering relationship between two existing virtual networks. The task includes verifying the peering relationship by communicating between virtual machines on both networks.

Configure network peering

When you will login to your azure portal with the generated credentials. You will see that there are some resources pre created for you.

This all you will need to work with this lab.

We have to create a peering relationship between the hub and public virtual network.

Go to any of the network, just like I have choosen the hub-vnet. It doesn't matter which one you choose as we are going to peer from both the networks.

Now go to the peerings option and click on Add to add peering relationship.

Set the name of peering from hub to public as Hub2Public.

For public to hub as Public2Hub.

You can name them whatever you want, it's just for our reference.

As we are doing the peering relationship from hub vnet choose the public-vnet to where we want to do this peering. See image below.

Click on Add to add this peering relationship.

Now if you go and check the peering in hub-vnet, you can see the peering relationship is established to public-vnet.

In similar fashion peering from public to hub virtual network is also done.

Verify network peering

We will need to login to hub virtual machine and make a request to either of the virtual machine which are in public vnet.

For that first of all we need to get the password for the virtual machines.

Go to the resource group and open the deployments. You will see a deployment is there. Click on it.

Go to the output of the deployment and copy the password for our virtual machines.

Go to the connect option in the hub virtual machine. Click on Use Bastion to login into the machine with bastion.

Enter the username as student and password we copied earlier from the deployments. Click on Connect to connect the virtual machine via a SSH.

A new tab will open and you will have the SSH access to the hub virtual machine here.

Go to the webapp1 virtual machine and find out the private IP address of the virtual machine.

You can go and find the private IP address of webapp2 vitual machine also.

Use the below commands to request on the web servers of the public virtual network.

curl PrivateIpAddress

Use the private IP addresses of the virutal machine.

If the peering relationship is done correctly, you will see the response as the name of the virutal machine just like the below image.

This means that peering relationship is done properly and hub virual network's VM can access the public vnet's VMs.

This lab is now complete.