Advanced · Outbound access · 18 of 32

Give a private subnet internet access

Your tasks
  • Get vm-app reaching updates.example.org through nat-gw

vm-app sits in subnet-app, a private subnet, and can't reach updates.example.org on 443 to download updates. It must not get a public IP of its own. Give subnet-app a NAT gateway.

You'll learn
Outbound access and NAT gateway
  1. Connect to vm-app.

    ssh vm-app
    What's this?

    Opens a shell on vm-app, 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.

  2. Try the site. It fails. Type exit when done.

    curl -sI https://updates.example.org
    What's this?

    Fetches a web address and shows the reply. Tells you whether the web service itself answers, not just the port.

    • -s quiet: no progress bar
    • -I ask only for the headers, not the whole page
  3. Create a Standard public IP.

    az network public-ip create -g rg-lab --name pip-nat --sku Standard
    What's this?

    Creates a public IP address that you can attach to things like Azure Bastion or a NAT gateway.

    • -g the resource group the resources live in
    • --name the name of the thing to look at or change
  4. Create the NAT gateway with it.

    az network nat gateway create -g rg-lab --name nat-gw --public-ip-addresses pip-nat --idle-timeout 10
    What's this?

    A NAT gateway gives a subnet explicit outbound internet access through the gateway's public IP.

    • -g the resource group the resources live in
    • --name the name of the thing to look at or change
  5. Associate it with subnet-app.

    az network vnet subnet update -g rg-lab --vnet-name vnet-app --name subnet-app --nat-gateway nat-gw
    What's this?

    Changes a subnet's settings, such as which NSG or route table is attached to it.

    • -g the resource group the resources live in
    • --vnet-name the virtual network
    • --name the name of the thing to look at or change
  6. Answer the question below.

    NAT gateway
    Gives a subnet outbound internet access through the gateway's public IP.
    User-defined route
    A route you add in a route table: traffic for this range goes to this next hop.
    Prefix
    An address range written as start/bits, like 10.1.0.0/16. The number after the slash is how many leading bits are fixed.
    Appliance
    A VM, such as a firewall, that traffic is routed through.
Sources on Microsoft Learn (3)
0/3 changes
Network map
?
  • 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
  • NICVM 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.
Resource grouprg-labvnet-app: tap to inspectVirtual networkvnet-app10.1.0.0/16subnet-app: tap to inspectsubnet-app10.1.1.0/24 · 251 usablevm-app 10.1.1.4: tap to inspectNICvm-app10.1.1.4subnet-web: tap to inspectsubnet-web10.1.2.0/24 · 251 usable
Goals 0/3
Cloud Shell · bashVMsrg-lab · eastus2
cloudshell:~$