INTRODUCTION
Today I will be writing about how to create a Virtual Network with Two Virtual Machines that can ping each other. This process involves setting up a virtual environment where multiple virtual machines (VMs) can communicate seamlessly, mimicking a real-world network setup.
In this article, I will walk through the steps necessary to create a virtual network and configure two virtual machines to ensure they can successfully ping each other, demonstrating effective connectivity and interaction within the virtualized environment.
STEP 1: CREATE A VIRTUAL NETWORK & A SUBNET
- From the Azure Portal home page, at the top left corner of the page, click the hamburger (menu) button.
- select virtual networks from the sidebar.
- Click +create at the top of the create network page.
- At the Basics tab, under Project details and at the Resource group label, click create new link. Provide a name for the resource group and click Ok.
Under the instance details label, provide a name for the network and select a suitable Region.
Click the IP Addresses tab at the top of the page, to add a subnet.
At the dropdown menu displayed above the address space box on the
displayed page, check that the dropdown is set to Add IPv4 address
space
In the address space box, change Subnet address range to
10.1.0.0/16 (This is usually the default IP address so you may not
need to change it in this instance).locate the pen icon at the bottom corner, in the address space box (next
to the garbage can icon). Click on this icon to edit the default
Subnet name/add a subnet.
Also, change Subnet address range to 10.1.0.0/24 using the
size label. Leave all other settings as their defaults.Click Add to close the Add a Subnet pane. This
completes the creation of the subnet.
When you see the notification that Validation passed, click the
Create button to deploy the Virtual Network.
STEP 2: CREATE TWO VIRTUAL MACHINES IN THE NETWORK (VIRTUAL NETWORK)
- After the virtual network deployment is complete click Go to resource.
- Click the hamburger menu button (top left of the page) and select virtual machines.
- Click + Create icon and then select Virtual machine.
- On the Basics tab, at the Project details and at the Resource group label, select the resource group created earlier from the drop-down list of resource groups. This is the deployment ID.
- At the Instance details heading and the Virtual machine name click the input box and name the virtual machine as vm1.
- At the Region label select a suitable region. In this case, I selected East US.
- Set Availability options to No infrastructure redundancy required
- Set Security type to Standard.
- At the Image label, select windows server 2019 Datacenter - Gen 2.
- set vm architecture to x64.
- Next, untick Run with Azure spot discount
- Then, set size to Standard_Dc4ads_cc_v5... At times the size required may not be listed. If this happens select the see all sizes link. This will take you to another page to select a VM size.
- Do not Enable Hibernation. In my case Hibernation isn't supported for my VM size.
- At the Administrator account heading, select a Username and Password. Also confirm password by re-typing the password in the input box at the confirm password label. (These are the details that will be required to access the Virtual machines when it is in operation.)
- At the Inbound port rules heading leave the Public inbound ports set at the default.
- set select inbound ports to default which is RDP(3389).
- Do not tick the Licensing section as well.
- Click the networking tab at the top of the page. Make sure that vm1 is placed on the Vnet1-subnet virtual network.
- Click Review + create to validate the configurations.
- When you see the notification that Validation passed, click the Create button to deploy the first Virtual Machine.
- Next, create the Second virtual machine in the same virtual network following the steps listed under this heading. Make sure the second Virtual machine has a different name and a different IP address for networking.
STEP 3: TEST THE CONNECTIONS
- to view the deployed virtual machines, search for virtual machines in the search bar at the top of the page.
- At the listing, click vm1 to open it.
- at vm1 overview page, you will notice that the status is Running. Click the IP address link at the Public IP address label to increase the timeout settings. You can check here to see how it is done. This is one of the industry's best practices. However, I didn’t increase the Timeout for my virtual machine in this article.
- Still at the vm1 overview page, click Connect at the top of the page.
- Select Download RDP file.
- Open the downloaded RDP file for vm1.
- When prompted, click connect.
Provide the credentials created for administrator account while creating vm1 virtual machine. Provide the password and click ok.
You may receive a certificate warning prompt. Click continue to create the connection to your deployed virtual machine.
Follow the same process listed above to also open vm2.
Now that both virtual machines are open, go to vm1 interface. Click on the search button icon at the bottom of the page.
Type firewall.
Modify the firewall setting by clicking turn off windows defender firewall for Private network settings and Public network settings
Disable the firewall for vm2 just like it was done for vm1.
Next, in vm1 click search icon at the bottom of the page and search for powershell
Select PowerShell from the search result listing.
After PowerShell completes launching, type ping vm2 into the interface.
If you can see the following display in the image below, that means the connection was successful. I have successfully pinged vm2 from vm1.
CONCLUSION
In this article we have done the following:
- Created a Virtual Network and a Subnet
- Deployed two virtual Machines onto the virtual network
- Configured them to allow one virtual machine to ping the other within that virtual network, and
- Tested the connection of the two virtual machines in the network.
Another article about virtual networks in Azure can be found here
Photo by Shubham Dhage on Unsplash
Top comments (0)