DEV Community

1suleyman
1suleyman

Posted on

Project 4: Implementing a Virtual Network in Azure

Introduction

In this project, I focused on creating and configuring a Virtual Network (VNet) in Azure. I set up subnets to handle different workloads, configured Network Security Groups (NSGs) to manage traffic, and established Virtual Network Peering to connect multiple VNets. This project helped me understand how to organize and secure network traffic in Azure and enabled me to connect multiple resources in a secure, scalable way.

Project Overview

In this project, I:

  • Created and configured a Virtual Network (VNet) in Azure.
  • Set up subnets to isolate different types of traffic.
  • Configured NSGs to control inbound and outbound traffic.
  • Established Virtual Network Peering to connect multiple VNets.

Let me walk you through the steps I followed to complete this project.

Step 1: Create a Virtual Network (VNet)

1️⃣ Navigate to Virtual Networks:

  • In the Azure portal, I searched for "Virtual Networks" and clicked on Virtual Networks.

2️⃣ Create a New Virtual Network:

  • I clicked on + Create to start creating a new VNet.

3️⃣ Fill in Virtual Network Details:

  • Subscription: I selected my active subscription.
  • Resource Group: I created a new resource group called test-rg.
  • Name: I named my virtual network vnet-1.
  • Region: I selected UK South as the region for the VNet.
  • Enable Azure Bastion: I enabled Azure Bastion to securely connect to VMs using private IPs without needing public IP addresses.
  • Bastion Host Name: I used vnet-1-Bastion as the name.
  • Public IP Address: I created a public IP address for the Bastion host.

4️⃣ Configure Subnets:

  • Address Space: I configured the address space as 10.0.0.0/16.
  • Subnets: I created a default subnet and then edited it to name it subnet-1 with an address range of 10.0.0.0/24.

5️⃣ Review and Create:

  • After reviewing the configuration, I clicked Create to provision the virtual network.

Step 2: Create Virtual Machines (VMs) in the VNet

Now that the VNet was set up, I created two virtual machines (VMs) in the same virtual network.

1️⃣ Navigate to Virtual Machines:

  • In the Azure portal, I searched for Virtual Machines and clicked on it.

2️⃣ Create First VM (vm-1):

  • Subscription: I selected the same subscription used for the VNet.
  • Resource Group: I selected test-rg (the same resource group used for the VNet).
  • VM Name: I named the first VM vm-1.
  • Region: I chose UK South, the same region as the VNet.
  • Image: I selected Ubuntu Server 22.04 LTS - x64 Gen2 for this project.
  • Size: I chose Standard B1s for a basic VM.
  • Authentication Type: I selected Password and entered the credentials for the VM (e.g., Username: azureuser, Password: a secure password).
  • Networking:
    • Virtual Network: I selected vnet-1.
    • Subnet: I selected subnet-1.
    • Public IP: I selected None since I'll connect via Bastion.
    • Network Security Group (NSG): I created a new NSG and named it vm-1-nsg.

3️⃣ Create Second VM (vm-2):

  • I followed the same steps as above to create a second virtual machine, vm-2, with the same network settings and NSG as vm-1.

Step 3: Connect to the Virtual Machines Using Bastion

Since I enabled Azure Bastion, I could securely connect to the VMs over SSH using private IPs.

1️⃣ Connect to vm-1:

  • In the Azure portal, I went to Virtual Machines and selected vm-1.
  • Under the Overview tab, I clicked on Connect and selected Bastion.
  • I entered the username and password I set earlier for vm-1 and clicked Connect. This opened a browser-based session to vm-1.

2️⃣ Connect to vm-2:

  • I repeated the same process to connect to vm-2 using Bastion.

Step 4: Test Communication Between VMs

To verify that the VMs can communicate with each other over the private network, I pinged between the two.

1️⃣ Ping from vm-1 to vm-2:

  • Once logged into vm-1, I opened the terminal and ran the following command:

     ping -c 4 vm-2
    

    This verified that vm-1 could communicate with vm-2 within the same virtual network.

2️⃣ Ping from vm-2 to vm-1:

  • I logged into vm-2 and ran the same ping command to test bidirectional communication:

     ping -c 4 vm-1
    

    This confirmed that communication between the two VMs was successful.


Step 5: (Optional) Set Up Virtual Network Peering

To connect multiple VNets, I used Virtual Network Peering.

1️⃣ Create Second Virtual Network (vnet-2):

  • I followed the same steps as above to create a second virtual network, vnet-2, with a different address range, such as 10.1.0.0/16, and created a new subnet subnet-2 with an address range of 10.1.0.0/24.

2️⃣ Set Up Peering Between vnet-1 and vnet-2:

  • In the Azure portal, I went to Virtual Networks, selected vnet-1, and under the Settings section, I clicked on Peerings.
  • I clicked + Add to create a new peering and configured the peering settings:
    • Peering Link Name: vnet-2-to-vnet-1.
    • Remote Virtual Network: I selected vnet-2.
    • Peering Settings: I enabled Allow virtual network access and Allow forwarded traffic from both VNets.
  • After reviewing the settings, I clicked OK to create the peering connection. I refreshed both VNets to ensure the Peering Status showed as Connected.

Step 6: Clean Up Resources

After completing the project, I deleted the resources to avoid unnecessary charges:

1️⃣ Delete the Virtual Network:

  • I deleted the resource group test-rg to clean up all resources, including VNets, VMs, and the Bastion host.

Conclusion

In this project, I successfully created and configured a Virtual Network (VNet) in Azure. I set up subnets to organize the network, configured Network Security Groups (NSGs) to manage traffic, and established Virtual Network Peering to enable communication between multiple VNets. Additionally, I explored Azure Bastion for secure remote access to my virtual machines.

By the end of this project, I gained valuable hands-on experience with Azure networking, which will be beneficial for managing secure and scalable network architectures in the cloud.

Credits : https://www.datacamp.com/blog/azure-project-ideas

🚀 Stay tuned for more as I continue my learning journey with Azure!

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)