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.
Before you start¶
- You are signed in to the lab directory (Getting started).
- Your lab resource group is
rg-CLOUD-LAB-GRP-N. ReplaceNwith 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¶
- Search for Virtual machines and select Create → Azure virtual machine.
-
On Basics:
Setting Value Resource group rg-CLOUD-LAB-GRP-NVirtual machine name office-vmRegion 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 azureuserPassword the password your trainer gives you, or one that follows the rules below Public inbound ports None -
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. -
On Networking:
- Virtual network: select Create new. Name
office-vnet, address range10.70.0.0/16, subnetdesks-subnetwith range10.70.0.0/24. Select OK. - Public IP: select None.
- NIC network security group: None.
- Select Delete NIC when VM is deleted.
- Virtual network: select Create new. Name
- On Monitoring, set Boot diagnostics to Disable.
- 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¶
- Search for Network Watcher and select it.
- Select Connection troubleshoot (under Network diagnostic tools).
-
Fill in:
Setting Value Source type Virtual machine Virtual machine office-vmDestination type Select a virtual machine Virtual machine depot-vmPreferred IP version Both Protocol TCP Destination port 22Source port leave blank -
Select Run diagnostic tests. The first time, Azure installs an agent on the VM. This can take a few minutes.
- 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¶
- Open
office-vm. On the Overview page, note its Private IP address. It should be10.70.0.4. - Open
depot-vm. Under Operations, select Run command → RunShellScript. -
Paste this script, replacing
10.70.0.4if 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" -
The output should say
NOT REACHABLE.
Task 4: Create the peering¶
Peering connects two virtual networks through the Azure backbone, using private addresses.
- Open
office-vnet. Under Settings, select Peerings → + Add. -
Fill in:
Setting Value This virtual network Peering link name office-to-depotAllow office-vnetto access the remote virtual networkselected Allow office-vnetto receive forwarded trafficselected Remote virtual network Peering link name depot-to-officeVirtual network depot-vnetAllow the remote network to access office-vnetselected Allow the remote network to receive forwarded traffic selected -
Select Add.
- 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¶
- Open
depot-vm→ Run command → RunShellScript. - Run the same script as in Task 3. This time the output should say
REACHABLE. - 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.
- Open
office-vnet. Under Settings, select Subnets → + Subnet. Name itdmz-subnet, with the range10.70.1.0/24. Select Save. -
Search for Route tables and select + Create:
Setting Value Resource group rg-CLOUD-LAB-GRP-NRegion Southeast Asia 3 Name rt-officePropagate gateway routes leave the default -
Select Review + create, then Create. Open the route table.
-
Under Settings, select Routes → + Add:
Setting Value Route name DmzToDesksDestination type IP Addresses Destination IP addresses 10.70.0.0/16Next hop type Virtual appliance Next hop address 10.70.1.7 -
Select Add.
- Under Settings, select Subnets → + Associate. Choose
office-vnetand the subnetdmz-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:
- Delete
office-vmanddepot-vm. Select Delete and make sure the OS disk and network interface are checked, so they are deleted too. - In each virtual network, under Peerings, delete the peering links.
- Delete
office-vnetanddepot-vnet. - Delete the route table
rt-office. - 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 REACHABLEbefore peering andREACHABLEafter. - Both peering links showed Connected.
- The route table is linked to
dmz-subnetand containsDmzToDesks. - 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.