Connect Virtual Networks With Virtual Network Peering
Create virtual networks
- On the Azure portal, select + Create a resource.
- Search for Virtual Network, and then select Create.
- On the Basics tab, enter or select the following information and accept the defaults for the remaining settings:
- On the IP Addresses tab, enter 10.0.0.0/16 for the IPv4 address Space field. Select the + Add subnet button below and enter Subnet1 for Subnet Name and 10.0.0.0/24 for the Subnet Address range.
- Select Review + create and then select Create.
- Repeat steps 1-5 again to create a second virtual network with the following settings:
- Name: myVirtualNetwork2
- Address space: 10.1.0.0/16
- Resource group: myResourceGroup
- Subnet name: Subnet2
- Subnet address range: 10.1.0.0/24
Peer virtual networks
- In the search box at the top of the Azure portal, look for myVirtualNetwork1. When myVirtualNetwork1 appears in the search results, select it.
- Under Settings, select Peerings, and then select + Add, as shown in the following picture:
- Enter or select the following information, accept the defaults for the remaining settings, and then select Add.
- In the Peerings page, the Peering status is Connected, as shown in the following picture:
- If you don’t see a Connected status, select the Refresh button.
Create the first VM
- On the Azure portal, select + Create a resource.
- Select Compute, and then Create under Virtual machine.
- Enter or select the following information on the Basics tab. Accept the defaults for the remaining settings, and then select Create:
- On the Networking tab, select the following values:
- Select the Review + Create and then Create to start the VM deployment.
Create the second VM
- Repeat steps 1-5 again to create a second virtual machine with the following changes:
- Name: myVm2
- Virtual network: myVirtualNetwork2
- The VMs take a few minutes to create. Don’t continue with the remaining steps until both VMs are created.
Communicate between VMs
- In the search box at the top of the portal, look for myVm1. When myVm1 appears in the search results, select it.
- To connect to the virtual machine, select Connect and then select RDP from the drop-down. Select Download RDP file to download the remote desktop file.
- To connect to the VM, open the downloaded RDP file. If prompted, select Connect.
- Enter the username and password you specified when creating myVm1 (you may need to select More choices, then Use a different account, to specify the credentials you entered when you created the VM), then select OK.
- You may receive a certificate warning during the sign-in process. Select Yes to continue with the connection.
- In a later step, ping is used to communicate with myVm1 from myVm2. Ping uses the Internet Control Message Protocol (ICMP), which is denied through the Windows Firewall, by default. On myVm1, enable ICMP through the Windows firewall, so that you can ping this VM from myVm2 in a later step, using PowerShell:
New-NetFirewallRule –DisplayName "Allow ICMPv4-In" –Protocol ICMPv4
- To connect to myVm2 from myVm1, enter the following command from a command prompt on myVm1:
mstsc /v:10.1.0.4
- Since you enabled ping on myVm1, you can now ping it from myVm2:
ping 10.0.0.4
- Disconnect your RDP sessions to both myVm1 and myVm2.
Tag:Azure