DEV Community

Cover image for How to create communication between two virtual machines using virtual network and subnet
Olalekan Oladiran
Olalekan Oladiran

Posted on

How to create communication between two virtual machines using virtual network and subnet

Introduction

Creating private networks in Azure requires the use of Azure virtual networks. They provide safe communication between various Azure resources, the internet, and on-premises networks.

Creating a virtual network and subnet

  • Log in to your azure account.
  • Click create a resource Image description
  • Search for virtual network in the Market place Image description
  • Fill in the project details which comprises subscription and resource group Image description
  • Then fill the instance details which comprises virtual network name and region. Image description
  • Change the tab from Basics to Ip addresses Image description
  • Edit the Ipv4 address space to 10.1.0.0 Image description
  • Click Default to edit the subnet, give a name for the subnet and change the starting address to 10.1.0.0 and leave the other settings as default and click save Image description
  • Click review + create Image description
  • Click create once validation is passed Image description

How to Create two virtual machines in the same virtual network

  • Click create a resource Image description
  • Search for virtual machine in the market place and click create Image description
  • Fill the project details which comprises of subscription and resource group Image description
  • Fill in the instance details Image description
  • Fill the Administrator account Image description
  • Leave the inbound port rules as default Image description
  • Click Networking tab and set the virtual network to the virtual network created earlier, leave other settings as default. Image description
  • Click review + create Image description
  • Click create once validation is passed Image description
  • Use this method to create another virtual machine and still set it to the virtual network created earlier. The two virtual machines are VM1 and VM2. Image description

How to test if the Virtual machines can communicate using Ping.

  • open VM1 by clicking on it and click connect in the overview page Image description
  • Click select under Native RDP Image description
  • This will open a pane to download RDP file Image description
  • After downloading the RDP file click on the file to launch it and click connect Image description
  • Enter your username and password and click Ok Image description
  • Click yes Image description
  • This will take you to the desktop page of your virtual machine and repeat this process to launch the second virtual machine
  • We need to disable the public and private firewall of both virtual machine by searching for firewall in the search tab and click on Windows Defender Firewall Image description
  • Click on Turn Windows Defender Firewall on and off Image description
  • Click on Turn Windows Defender Firewall on and off for both public and private settings, click okay. Image description Image description From the first virtual machine open powershell command prompt by searching powershell in the search tab and click powershell Image description Image description
  • In the powershell command prompt, run the code: ping vm2 Image description This shows that the first virtual machine is connected to or can communicate with the second virtual machine

Top comments (0)