Virtual Network Peering VNet within the Same Azure Region

Virtual network peering VNet

Virtual Network Peering VNet, in this article, I will explain how to configure virtual network peering within the same Azure region. We can connect VNets to each other with virtual network peering. These vnet to vnet peering can be in the same region or across regions (Global VNet peering).

Virtual network peering – (Connecting virtual networks within the same Azure region)
Global virtual network peering – (Connecting virtual networks different Azure regions)

Virtual network peering within same networks

Creating two virtual networks
Deploy a virtual machine (VM) into each vnet
Connect two VNet with a virtual network peering
Communicate between VMs
Create virtual networks
Create the first vnet

Log in to the Azure Portal

1- On the Azure portal, select Azure menu bar and select Virtual Network.

azure menu

2- Click on create virtual network.

azure create virtual network

3- Choose your subscriptions, to create a resource group click on create new.

azure create virtual network

4- Type a recourse group name (rg-peering)

azure create new resource group

5- Instance details type a virtual network name (vnet1) select regions and the click Next : IP Address >.

azure create virtual network

6- IP Addresses tab, enter 10.0.0.0/16 for the IPv4 Address Space field. Click the + Add subnet button below.

azure create virtual network ip address

7- Add subnet wizard; enter a Subnet Name (vnet-subnet) and type 10.0.0.0/24 for Subnet Address range and then click ok.

azure vnet add subnet

8- Click Next : Security >

azure create virtual network ip address

9- Choose DDos Protection (Basic) Firewall (disable) and Select Review + Create.

azure create virtual network security

10- Select Create.

azure create virtual network validation

To create 2nd virtual network follow the above steps from 2 to 10 again with the following changes.

SettingValue
Resources Grouprg-peeering
Namevnet2
Region(US) East US
IPv4 address space192.168.0.0/16
Subnet namevnet-subnet
Subnet address range192.168.0.0/24
SecurityDDos Protection Basic, Firewall disable
Create 

Now you can see both VNet created

azure create network virtual

Create Virtual Machines in Azure Portal

Create VMs in each virtual network so that we can test communicate between them.

First VM

1- On the Azure portal menu tab, then select Virtual machines.

microsoft azure menu

2- Select Create virtual machine.

azure virtual machine

3- Resource group select existing (rg-peering).

azure new vm wizard

4- Instance details, enter a virtual machine name (vm1), Region (East US), and then choose Image Windows Server 2019 Datacenter. You can choose a different operating system, but the remaining steps assume you selected Windows Server 2019 Datacenter.

azure instance details

5- Administrator account, enter a username (jamil), Password. Public inbound ports choose to allow selected ports. Select inbound ports (HTTP RDP) and then click Next : Disks >

azure create a new vm disks

6- Click Next : Networking >

azure create a new vm disks

7- Under the Networking tab, network interface select virtual network (vnet1) and then select the Review + Create button.

azure create vm networking

8- Click Create.

azure create vm review + create

Create the second VM

Complete steps 2-8 again, with the following changes

NameValue
Resource grouprg-peering
virtual machine namevm2
region(US) East US
ImageWindows Server 2019 Datacenter
Administrator accountusername password
Public inbound portallow selected ports
Select inbound portsHTTP, RDP
virtual networkvnet2
Create 

The VMs take a few minutes to create. Now the both VMs successfully created.

azure virtual machine

Peering Virtual Networks

1- Select Azure menu bat and then select Virtual networks.

microsoft azure menu

2- Click on vnet1

azure create virtual network

3- Under Settings Select Peerings, and then click + Add, as shown in the below picture.

azure vnet peering

4- Add peering wizard, Type a name (vnet1tovnet2) under Name of the peering from vnet1 to vnet2.
Under Virtual network deployment mode choose Resource manager.
Select your subscriptions
Under virtual network select vnet2.
Under Name of the peering from vnet2 to vnet1, enter a name (vnet2tovnet1)

azure add peering wizard

5- Configure virtual network access settings and then click ok.

azure configure gateway transit

6- Vnet1 peering status connected to vnet2

azure vnet peering

Vnet2 peering status connected to vnet1.

azure vnet peering

If you don’t see the status connected, click refresh.

Communicate between VMs

1- Select Azure menu bat, then select Virtual machine and then select vm1.

azure virtual machine

2- Select Connect button and the RDP.

azure vm overview connect

3- Click Download RDP file.

azure vm download rdp

4- To connect to the VM, open the downloaded RDP file and click Connect.

remote desktop connection

5- Enter the user name and password you specified when creating the VM and then select OK.

remote desktop connection

6- Select Yes.

remote desktop connection certificate

7- Click Windows button and click Control panel.

windows server desktop

8- Select network and sharing center

control panel

9- Select Ethernet

network and sharing center

10- Select Details

ethernet status

11- Now you can see vm1 private IP Address.

network connection details

12- Vm2 IP Address.

network connection details

We can use the ping command to communicate with the vm2 VM from the vm1 VM. Ping command uses the Internet Control Message Protocol (ICMP), which is disabled through the Windows Firewall, by default.

Disable Windows defender firewall follow the below steps.

1- Under network and sharing center click on Windows defender firewall.

network and sharing center

2- Select Windows defender firewall on or off.

windows defender firewall

3- Turn off private network, public network settings and then click OK.

customize settings for each type of network

4- Open command prompt to ping VMs

windows server bar

5- IP Address vm2 (192.168.0.4) pinging from vm1

command prompt

6- IP Address vm1 (10.0.0.4) pinging from vm2

ping

Comments

Leave a Reply