Skip to content

Lab 05: Connect networks with peering and routes

At a glance

  • Time: about 60 minutes
  • Region: Southeast Asia 3 (all resources)
  • You create: 2 small Ubuntu VMs, 2 virtual networks, a network peering, a route table
  • Cost: the VMs cost a little while they exist. Delete them at the end.

What you will learn

  • Why two virtual networks can't talk to each other until you peer them.
  • How to test connectivity with Network Watcher and from inside a VM.
  • How a route table with a user-defined route changes where traffic goes.

What is different in this environment

  • You use two Ubuntu (Linux) VMs and test the SSH port (22), instead of two Windows VMs and RDP (port 3389).
  • The VMs are in Southeast Asia 3 and use the size Standard_B1s. These are the only region and size that work for this lab.
  • You work in your own resource group. You don't create one.
Diagram: office-vnet and depot-vnet, each with a VM, joined by VNet peering. Network Watcher tests the connection before and after peering, and a route table is linked to the dmz-subnet.
Two virtual networks in Southeast Asia 3, with peering, a connection test and a custom route. Select the diagram to open it full size.

Before you start

  • You are signed in to the lab directory (Getting started).
  • Your lab resource group is rg-CLOUD-LAB-GRP-N. Replace N with your group number.
  • Delete the resources from Lab 04 first.
  • Each group may have at most 2 VMs. Make sure you have none left from earlier labs.

The plan

Resource Name Address range
Virtual network office-vnet 10.70.0.0/16
Subnet desks-subnet 10.70.0.0/24
Virtual machine office-vm in desks-subnet
Virtual network depot-vnet 172.20.0.0/16
Subnet trucks-subnet 172.20.0.0/24
Virtual machine depot-vm in trucks-subnet

Task 1: Create office-vm

  1. Search for Virtual machines and select Create → Azure virtual machine.
  2. On Basics:

    Setting Value
    Resource group rg-CLOUD-LAB-GRP-N
    Virtual machine name office-vm
    Region Southeast Asia 3
    Availability options No infrastructure redundancy required
    Security type Standard
    Image Ubuntu Server 24.04 LTS - x64 Gen2
    Size Standard_B1s
    Authentication type Password
    Username azureuser
    Password the password your trainer gives you, or one that follows the rules below
    Public inbound ports None
  3. On Disks, set OS disk type to Standard SSD (locally-redundant storage).

    Don't skip this

    The default is Premium SSD, which isn't allowed. If you leave it, the deployment is blocked with [LAB-P03D-VM-DISK]. Standard HDD also works.

  4. On Networking:

    • Virtual network: select Create new. Name office-vnet, address range 10.70.0.0/16, subnet desks-subnet with range 10.70.0.0/24. Select OK.
    • Public IP: select None.
    • NIC network security group: None.
    • Select Delete NIC when VM is deleted.
  5. On Monitoring, set Boot diagnostics to Disable.
  6. Select Review + create, then Create. You don't need to wait for it to finish.

A VM with no public address

Your VMs can't be reached from the internet. You test them from inside Azure in this lab.

Choosing a VM password

Azure accepts a password if it:

  • is 12 to 72 characters long,
  • has three of these four: a lowercase letter, an uppercase letter, a digit, a special character (for example #, !, -),
  • does not contain the username (azureuser),
  • is not a very common password such as Password1234!.

Write it down. You use the same password for both VMs, and Azure can't show it to you again. You don't need it to sign in during this lab, but you need it if you want to sign in to the VM later.

Task 2: Create depot-vm

Repeat Task 1 with these changes:

Setting Value
Virtual machine name depot-vm
Virtual network Create new: name depot-vnet, address range 172.20.0.0/16, subnet trucks-subnet with range 172.20.0.0/24

Everything else is the same: Southeast Asia 3, Standard_B1s, Ubuntu Server 24.04, Standard SSD, no public IP, no NSG, boot diagnostics disabled.

Wait until both VMs show Running in the Virtual machines list.

Task 3: Test the connection before peering

Network Watcher

  1. Search for Network Watcher and select it.
  2. Select Connection troubleshoot (under Network diagnostic tools).
  3. Fill in:

    Setting Value
    Source type Virtual machine
    Virtual machine office-vm
    Destination type Select a virtual machine
    Virtual machine depot-vm
    Preferred IP version Both
    Protocol TCP
    Destination port 22
    Source port leave blank
  4. Select Run diagnostic tests. The first time, Azure installs an agent on the VM. This can take a few minutes.

  5. The result should be Unreachable. The two VMs are in different virtual networks.

Network Watcher is limited here

You can use only Connection troubleshoot. The other Network Watcher tools aren't available to students.

From inside the VM

  1. Open office-vm. On the Overview page, note its Private IP address. It should be 10.70.0.4.
  2. Open depot-vm. Under Operations, select Run command → RunShellScript.
  3. Paste this script, replacing 10.70.0.4 if your address is different, and select Run:

    timeout 5 bash -c '</dev/tcp/10.70.0.4/22' && echo "REACHABLE: port 22 answered" || echo "NOT REACHABLE: no answer"
    
  4. The output should say NOT REACHABLE.

Task 4: Create the peering

Peering connects two virtual networks through the Azure backbone, using private addresses.

  1. Open office-vnet. Under Settings, select Peerings → + Add.
  2. Fill in:

    Setting Value
    This virtual network
    Peering link name office-to-depot
    Allow office-vnet to access the remote virtual network selected
    Allow office-vnet to receive forwarded traffic selected
    Remote virtual network
    Peering link name depot-to-office
    Virtual network depot-vnet
    Allow the remote network to access office-vnet selected
    Allow the remote network to receive forwarded traffic selected
  3. Select Add.

  4. Refresh the Peerings page. The status should be Connected. Check the same on depot-vnet.

Think about it

Why does a peering have two links, one in each virtual network?

Task 5: Test the connection after peering

  1. Open depot-vm → Run command → RunShellScript.
  2. Run the same script as in Task 3. This time the output should say REACHABLE.
  3. In Network Watcher → Connection troubleshoot, run the test from Task 3 again. The result should now be Reachable. Look at the path, the number of hops and the latency.

If it says NOT REACHABLE

Check that both peering links say Connected, that the VMs are Running, and that the IP address in your script is the private IP of office-vm.

Task 6: Add a custom route

By default, Azure routes traffic between subnets for you. A route table lets you override that, for example to send traffic through a firewall.

  1. Open office-vnet. Under Settings, select Subnets → + Subnet. Name it dmz-subnet, with the range 10.70.1.0/24. Select Save.
  2. Search for Route tables and select + Create:

    Setting Value
    Resource group rg-CLOUD-LAB-GRP-N
    Region Southeast Asia 3
    Name rt-office
    Propagate gateway routes leave the default
  3. Select Review + create, then Create. Open the route table.

  4. Under Settings, select Routes → + Add:

    Setting Value
    Route name DmzToDesks
    Destination type IP Addresses
    Destination IP addresses 10.70.0.0/16
    Next hop type Virtual appliance
    Next hop address 10.70.1.7
  5. Select Add.

  6. Under Settings, select Subnets → + Associate. Choose office-vnet and the subnet dmz-subnet. Select OK.

There is no appliance

Nothing in the lab uses the address 10.70.1.7. The route shows how you would send traffic to a firewall or other network virtual appliance (NVA). Any VM placed in dmz-subnet would lose its path to desks-subnet.

Think about it

Which route wins when a user-defined route and a system route both match the same address?

Task 7: Clean up

Delete in this order, so nothing is still in use:

  1. Delete office-vm and depot-vm. Select Delete and make sure the OS disk and network interface are checked, so they are deleted too.
  2. In each virtual network, under Peerings, delete the peering links.
  3. Delete office-vnet and depot-vnet.
  4. Delete the route table rt-office.
  5. Check that your resource group has none of these resources, including disks and network interfaces.

Don't leave VMs running

VMs bill while they exist, even when you aren't using them. Your group may hold only 2 VMs, and Lab 06 and Lab 08 need them.

Check your work

  • Connection troubleshoot said Unreachable before peering and Reachable after.
  • The Run command script said NOT REACHABLE before peering and REACHABLE after.
  • Both peering links showed Connected.
  • The route table is linked to dmz-subnet and contains DmzToDesks.
  • Your resource group is empty again.

Key points

  • Virtual networks are isolated from each other until you peer them. Peering is not transitive.
  • A peering needs a link in both virtual networks. The address ranges must not overlap.
  • Connection troubleshoot tests a path from a VM, and shows where it fails.
  • User-defined routes override Azure's default routes. A virtual appliance next hop sends traffic to a firewall or router.
  • Deleting a VM doesn't always delete its disk and network card. Check, or you keep paying and hit the limits.