Virtual Networks and Subnets in Azure:
Tags: azure, beginners
Published: 2021-10-25 15:28:45

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jyjrk8l0i71q3g096kwy.png)

###**Content Directory:**
1. Virtual Networks 
2. Virtual Subnets
3. Creating Virtual Networks and Subnets in Azure portal
4. Peering of two virtual networks in Azure

##**Virtual Networks:**
➢Azure Virtual Network (VNet) is the fundamental building block for your private network in Azure.
➢VNet enables many types of Azure resources, such as Azure Virtual Machines (VM), to securely communicate with each other, the internet, and on-premises networks.
➢VNet is like a traditional network that you'd operate in your own data center but brings with it additional benefits of Azure's infrastructure such as scale, availability, and isolation.
➢Here we will also discuss Vnet and Subnet Practical, VNET Peering – One way and Two way

##**Virtual Subnets:**
In a virtual network, a subnet is a set of IP addresses. For organisation and security, a virtual network might be divided into many subnets. Each NIC (Network Interface) in a virtual machine is connected to a single virtual network subnet. Within a virtual network, NICs linked to subnets (same or different) can communicate with each other without any additional configuration.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f09pg3fjl0plcgzpnjmp.png)



##**Creating Virtual Networks and Subnets in Azure portal:**
To construct a virtual network and subnets, you can utilise the Azure portal. The name is a mix of the resource group name that contains the virtual network and -vnet if you let Azure construct a virtual network when you create a VM. 10.0.0.0/24 is the address space, default is the needed subnet name, and 10.0.0.0/24 is the subnet address range.

When you construct a virtual machine (VM), you either create or use an existing virtual network. It's critical to plan ahead of time before developing resources and to be aware of the limitations of networking resources.

When you create a virtual network, you specify the topology, which includes the address spaces and subnets that are available. If the virtual network is connected to other virtual networks or on-premises networks, use address ranges that do not overlap. Any address range is considered part of the private virtual network IP address space in Azure.

By default, there are no security borders between subnets. Each of these subnets has virtual machines that can communicate with each other. Use Network Security Groups (NSGs) to regulate traffic flow to and from subnets and VMs if your deployment requires security boundaries.

In the following figure, each set of virtual machines is assigned to separate subnets in the virtual network.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h3ppp1fs1jf506ah2rzz.png)

Creating Virtual Network ‘FINANCE-VNET’ with 2 SUBNETS: ‘subnet-1’, ‘subnet2’. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/artymxqj09py5g3sg50p.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rvj2ikojddkq6ex8eqiy.png)


Similarly creating a Virtual Network ‘HR-VNET’ with 2 subnets: ‘subnet-1’ and ‘subnet-2’. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrhsoluaiclpyge5et9z.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bowxmalrbsilz08uqy69.png)



##**Peering of two virtual networks in Azure:**
In Azure, virtual network peering allows you to link two or more Virtual Networks in a seamless manner. For connectivity reasons, the virtual networks appear to be one. The Microsoft backbone technology is used to transport traffic between virtual computers in peer virtual networks. Traffic is routed over Microsoft's private network only, just like traffic between virtual computers on the same network.

The following peering types are supported by Azure: 
*Virtual network peering: Connect virtual networks within the same Azure region.
*Connecting virtual networks across Azure regions using global virtual network peering.

 
Peering ‘FINANCE-VNET’ and ‘HR-VNET’:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjbiwum7vaxznrct2s3w.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhcjxvvo3gcgzfei2866.png)