Peer two VNets
- Peer vnet-a and vnet-b both ways with VNet access allowed
- Get vm-a reaching vm-b on 443
- Test the connection from vm-a with nc
vnet-a (10.10.0.0/16) and vnet-b (10.20.0.0/16) are separate networks, so vm-a can't reach the HTTPS service on vm-b (10.20.1.4, port 443). Peer the two VNets, watch the peering state change, then test the connection from vm-a.
Create the link from vnet-a to vnet-b.
az network vnet peering create -g rg-lab --name a-to-b --vnet-name vnet-a --remote-vnet vnet-b --allow-vnet-accessWhat's this?
Connects two virtual networks, or changes what the connection allows. A peering needs a link from each side.
-gthe resource group the resources live in--namethe name of the thing to look at or change--vnet-namethe virtual network--remote-vnetthe virtual network on the other side
--vnet-name vnet-athe local side of this link--remote-vnet vnet-bthe other VNet, by name or resource ID--allow-vnet-accesslet traffic flow through this link
Check the state from vnet-a. It should say Initiated.
az network vnet peering list -g rg-lab --vnet-name vnet-a -o tableWhat's this?
Shows the peerings on a virtual network and their state.
-gthe resource group the resources live in--vnet-namethe virtual network
Create the reverse link.
az network vnet peering create -g rg-lab --name b-to-a --vnet-name vnet-b --remote-vnet vnet-a --allow-vnet-accessWhat's this?
Connects two virtual networks, or changes what the connection allows. A peering needs a link from each side.
-gthe resource group the resources live in--namethe name of the thing to look at or change--vnet-namethe virtual network--remote-vnetthe virtual network on the other side
Check the state again. Both links should now say Connected.
az network vnet peering list -g rg-lab --vnet-name vnet-a -o tableWhat's this?
Shows the peerings on a virtual network and their state.
-gthe resource group the resources live in--vnet-namethe virtual network
Connect to vm-a so the next command runs from there.
ssh vm-aWhat's this?
Opens a shell on vm-a, so the next commands run on that VM. In this lab it's a shortcut. In real Azure you'd connect through something like Azure Bastion, or SSH to an address you can reach.
From vm-a, test vm-b's port 443. Then type exit.
nc -zv 10.20.1.4 443What's this?
netcat, a standard Linux tool. Tries to open a TCP connection and reports whether it worked.
-zonly check whether the port answers. Send no data-vprint the result in words10.20.1.4where to connect443the port to try
?
- Resource group, the outer dashed frame
- Virtual network, with its address space top right
- Subnet, with range and usable IPs (5 reserved)
- Network security group. A small shield on a VM's NIC means the NIC has one too
- Route table on the subnet
- VM Appliance Private endpoint
- Peering Connected Initiated or access off
- Goal working Goal broken, X marks where it stops
- Private DNS zone, dotted lines go to linked VNets
- Orange pulse: what your last command changed. Drag to pan, Ctrl and scroll to zoom.
vm-a → vm-b:443should work: dropped by routing