Skip to content

1️⃣ NAT Gateway

🔹 Definition

Image

NAT Gateway provides outbound-only internet access for private subnets.

  • No inbound traffic allowed
  • Stable, static outbound IP
  • More secure than public IPs on VMs

When to use

  • Private VMs need to download updates
  • Backend services calling external APIs

🔧 Azure CLI (Basic)

az network nat gateway create \
  --resource-group rg-vnet-demo \
  --name nat-gateway \
  --public-ip-addresses nat-ip \
  --idle-timeout 10

Attach to subnet:

az network vnet subnet update \
  --resource-group rg-vnet-demo \
  --vnet-name vnet-main \
  --name subnet-private \
  --nat-gateway nat-gateway

🖥️ Azure Portal Flow

Portal → NAT Gateway → Create
→ Select Resource Group
→ Attach Public IP
→ Attach to Private Subnet

📦 Example

Private VM → NAT Gateway → Internet
Internet ❌→ Private VM

✔ Outbound allowed ❌ Inbound blocked