Virtual, Isolated Portion of The Azure Public Network
Virtual, Isolated Portion of The Azure Public Network
Following
Gayatri Barhate
Feb 14, 2023 · 15 min read
https://teckbakers.hashnode.dev/azure-virtual-network 1/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
0:00 / 18:29
TABLE OF CONTENTS
Hands-on1: Create a VNet
Creating Subnets inside the VNet
Hands-on2: Create a VNet with two VMs inside it and communicate them with each other.
Hands-on3: Connecting two VNets from the same region using VNet peering
Hands-on4: Connecting two VNets across regions using VPN Gateways.
Azure Virtual Network (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 similar to a traditional network in
that you'd operate in your data center but brings with it additional benefits of
Azure's infrastructure such as scale, availability, and isolation.
Key scenarios that you can accomplish with a virtual network include -
communication of Azure resources with the internet, communication between
Azure resources (we will be focusing more on this scenario), communication
with on-premises resources, filtering network traffic, routing network traffic, and
integration with Azure services.
Now without any further a do let's do some hands-on.
Hands-on1: Create a VNet
https://teckbakers.hashnode.dev/azure-virtual-network 2/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Sign into your Azure portal and search for Virtual Network and click on create.
Select your subscription, and create a new resource group for this hands-on. To
understand what a subscription and resource group in Azure is, visit this Get
started with Microsoft Azure article. Name the VNet and select the region
where you want your VNet to be deployed.
The next tab is about IP address space which will be allocated to the virtual
network. By default it suggests an IP address space, you can continue with that
or use another address space based on your requirements. We will go with the
https://teckbakers.hashnode.dev/azure-virtual-network 3/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
default one. Now the IP address space is in CIDR notation (classless inter-
domain routing).
A little background about CIDR: If you know of Classful addressing in computer
networks, we have classes like class A, class B, C, D and E. Each class has a
predefined address space. I would like to provide this Networking in the Real
world to clear things up.
But there is a problem with Classful Addressing which is that in today's world,
we have zillions of devices and more coming eventually someday all the
addresses will be consumed and there will be no left for further use, which is
why CIDR was introduced. Also in Classful Addressing even if you want to buy a
network for let's say 100 computers you have to buy class C IP address space
(again you need to understand classful addressing if you want to understand
this thoroughly) which provides 256 addresses so basically 156 goes waste in
some cases. But of course, you can do variable subnetting and provide the
remaining addresses to someone in need as a solution. The initial goal of CIDR
was to decrease the rapid exhaustion of IPv4 addresses.
Now coming back here!
10.8.0.0/16: The prefix 16 here means that the first 16 bits will represent the
network id and the remaining 26 bits will represent the host id. There is a total
of 32 bits as it is an IPv4 address space. Meaning the first two octets (10.8.) will
remain as it is because it is network id and the last two octets (0.0) will have all
the binary combinations and will become (255.255). That's how there will be
65536 addresses. Simply put if we have 16 bits to generate host ids so
basically, 2^16 will be 65536. So you are creating a virtual network with 65536
addresses to allocate.
https://teckbakers.hashnode.dev/azure-virtual-network 4/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
But what if I don't need this many addresses? I just need 256 addresses
because of small business or it may be a startup. In that case, change the prefix
as shown.
10.8.0.0/24: Here the first three octets will represent the network id and the
remaining 8 bits(last octet) will represent hosts. So 2^8 = 256 addresses.
https://teckbakers.hashnode.dev/azure-virtual-network 5/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
The Next tab is Tags. Think of it as key-value pair to label or to keep track of
azure services you create in large projects. You can apply the same tag to
multiple resources under one resource group. Suppose I create 15 VMs for the
Marketing department then I will tag them as Marketing: VMs, to understand
their purpose.
Click on Review + create
https://teckbakers.hashnode.dev/azure-virtual-network 6/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
In azure, before creating any resource, the Azure Resource Manager checks if
the resource is created by an authorized person and that is what it means when
it says running final validation.
After the validation is passed, Azure will start deploying the resource and after a
few minutes the resource in our case, VNet will be created and ready to use.
https://teckbakers.hashnode.dev/azure-virtual-network 7/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
So that's how you create a VNet and then you can create resources in your
VNet, we will be creating a VM in the next hands-on.
Also Read: Introduction to Cloud Computing Fundamentals
https://teckbakers.hashnode.dev/azure-virtual-network 8/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 9/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 10/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Secondly why /25? Because the first 24 bits represent network id and as we
borrowed one bit from host id, network id (24) + subnet id(1) =25. So overall
the first 25 bits represent the subnet.
Thirdly, don't touch network id bits, use host id bits to create a subnet.
Finally, the range of subnet1 is 10.11.0.0/25 to 10.11.0/127 and subnet2 is
10.11.0.128/25 to 10.11.0.255/25.
Do try to create a VNet with subnets inside it.
In this hands-on, we have just created an empty virtual network, in the sense,
we don't have any resources in this VNet. You can start by creating a VM inside
this Vnet. Start by creating a VM. I will try to not elaborate as the focus of this
article is on VNet. There will be a dedicated article on Azure VM. As of now you
can follow the images and try to understand stuff.
Create VM
https://teckbakers.hashnode.dev/azure-virtual-network 12/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
I would suggest using the same credentials (username and password) for all
VMs so that you remember them.
Skip the Disks tab, and keep all configurations default. We don't have to dig in
there right now. Go to the Networking tab.
https://teckbakers.hashnode.dev/azure-virtual-network 13/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Select the Vnet, where you want your VM to be. In my case it's myVN. Keep the
rest of the things and tabs as it is and create this VM. Now you can access this
VM by following the steps specified in Hands-on2, so hang on.
Hands-on2: Create a VNet with two VMs
inside it and communicate them with each
other.
1. Create a VNet.
2. Create two VMs.
3. Go to the Overview tab of both VMs and download the RDP files for both
VMs.
https://teckbakers.hashnode.dev/azure-virtual-network 14/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 15/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 16/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 17/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Enter credentials
https://teckbakers.hashnode.dev/azure-virtual-network 18/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 19/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
How to know the IP address of the respective VM? You can see it in the
overview tab of the VM on the Azure portal or use the command ipconfig .Now
try to ping them. Ping is a command-line utility, that acts as a test to see if a
networked device is reachable.
https://teckbakers.hashnode.dev/azure-virtual-network 20/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Request timed out and received packets are 0. It means the VMs are not
reachable because firewalls are ON and they block ICMP traffic/packets.
Turn off the firewall in both VMs. Follow the below steps.
https://teckbakers.hashnode.dev/azure-virtual-network 21/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 22/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Turn off the firewall for both private and public network settings and try to ping
again.
Woah!!! Great!
https://teckbakers.hashnode.dev/azure-virtual-network 23/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Note: Sometimes it may happen that you can't select resources like VNet, virtual
network gateway, etc to solve this simply log out and then again log in, to your
Azure account. Sometimes you have to try it a few times these are because
resources take time to reflect in the portal.
Hands-on3: Connecting two VNets from
the same region using VNet peering
Create two VNets in the same region (you can use East US 2) and create one
VM in each VNet and establish communication between those VMs.
Virtual network peering connects two Azure virtual networks. Traffic between
virtual machines in the peered virtual networks is routed through the Microsoft
backbone infrastructure (Microsoft network), through private IP addresses only.
No public internet is involved. You can also peer virtual networks across Azure
regions means you can connect a VNet deployed in the East US region with
VNet deployed in the West US region. This is called Global peering. Virtual
network peering provides a low-latency, high-bandwidth connection.
1. Create two VNets, VNet1 and VNet2 . Remember to put all related resources
like this hands-on under one resource group. In my case it is example_VN .
2. Create VM1 (East US 2) in Vnet1 and VM2 (East US 2) in Vnet2 .
3. Now we have to do Vnet peering.
By doing peering vm1 and vm2 can communicate with each other.
https://teckbakers.hashnode.dev/azure-virtual-network 24/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 25/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
In azure, when you add peering from Vnet1 to Vnet2 , peering from Vnet2 to
Vnet2 also gets added. It's like a bidirectional connection between Vnets.
What about when you try to connect three Vnets? (Not a part of hands-on,
just for understanding)
https://teckbakers.hashnode.dev/azure-virtual-network 26/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Just add peering between virtual networks to which you want to connect.
https://teckbakers.hashnode.dev/azure-virtual-network 27/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Note: Connecting Vnet1 to Vnet2 and then Vnet2 to Vnet3 , doesn't mean that
Vnet1 and Vnet3 get connected automatically(Azure Vnet does not follow
https://teckbakers.hashnode.dev/azure-virtual-network 28/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 29/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Virtual network peering and VPN gateways both support the following
connection types:
Virtual networks in different regions
Virtual networks in different Azure subscriptions.
Lastly, let's compare both of them.
What is SKU?
Stock Keeping Unit, is a retail term that says, stock keeping unit is the unit of
measure in which the stocks of a material are managed.
In terms of the Microsoft Azure cloud, SKU signifies a purchasable SKU (stock of
any service like the number of VNet-to-VNet connections) under a product (like
VPN Gateway in our case). It has a bunch of different shapes of the product.
https://teckbakers.hashnode.dev/azure-virtual-network 31/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 33/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
1. Create Vnet named eastVnet in the East US 2 region and create a VM named
vmone in the East US 2 region inside eastVnet .
https://teckbakers.hashnode.dev/azure-virtual-network 34/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 35/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 36/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Please note that it can take about 30 minutes to create a virtual network
gateway.
5. Create VM vmeast (region: East US 2) in eastVM.
6. create VM vmwest (region: West US 2) in westVM.
https://teckbakers.hashnode.dev/azure-virtual-network 39/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 40/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Now ping both VMs and you should be able to communicate them with each
other as shown above.
FINALLY, we are done with hands-on4. I am frazzled!
Try it Yourself!
Connect two VNets in different regions using VNet peering (which is called
global peering)
Connecting two VNets in the same region using VPN Gateway.
You can go for more than two VNets also.
That's all for this article. If you got any doubt, please do comment and I will help
you. Also if you folks want a dedicated blog on networking topics like classful
addressing, CIDR, and Subnetting (fixed and variable length subnetting), then
please suggest me in the comment section because these are super important
concepts.
Please like and comment! Thanks for reading🥰👍
https://teckbakers.hashnode.dev/azure-virtual-network 41/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Your Name
Email Address
Message
Send Message
https://teckbakers.hashnode.dev/azure-virtual-network 42/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Read articles from Teckbaker's Blog directly inside your inbox. Subscribe to the
newsletter, and don't miss out.
[email protected] SUBSCRIBE
WRITTEN BY
Gayatri Barhate
Follow
My name is Gayatri Barhate. I am a undergrad student trying to learn and
explore cloud computing technologies.
PUBLISHED ON
Teckbaker's Blog
Following
Hello! We are TeckBaker's Team, and we write about all the computer
science-related stuff. Subscribe to our newsletter for all upcoming blogs.
Happy Reading:)
ARTICLE SERIES
Devops & Cloud
1
Jenkins
In this blog we are going to the theory about the what is Jenkins and how to configure
the slave nod…
2
https://teckbakers.hashnode.dev/azure-virtual-network 43/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
Azure Database for the MariaDB server by using the Azure CLI
You can use the Azure CLI to create and manage Azure resources from the command
line or in scripts. …
34
Creating custom container images 📦
Containerization is a technology that is now adopted worldwide. docker is one of the
most famous con…
https://teckbakers.hashnode.dev/azure-virtual-network 44/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
35
Getting Into the world of containers ... 🐋
In March 2013 Solomon Hykes demonstrated the docker tool at PyCon and revealed
the underlying techno…
https://teckbakers.hashnode.dev/azure-virtual-network 45/46
8/10/23, 12:12 AM virtual, isolated portion of the Azure public network
https://teckbakers.hashnode.dev/azure-virtual-network 46/46