Azure NAT Gateway

This document provides a comprehensive overview of Azure NAT Gateway, its capabilities, benefits, and how to implement it in your Azure network.

What is Azure NAT Gateway?

Azure NAT Gateway is a fully managed network service that provides outbound connectivity from virtual networks to the internet. It simplifies outbound-only internet connectivity for virtual networks. NAT Gateway provides a managed and scalable solution for network address translation (NAT) for your Azure resources.

Key Features and Benefits

How NAT Gateway Works

NAT Gateway is associated with a subnet within your virtual network. All outbound traffic originating from resources in that subnet is automatically translated to the public IP addresses associated with the NAT Gateway. This means your virtual machines and other resources can communicate with the internet using the NAT Gateway's IP addresses, without needing their own public IPs.

NAT Gateway Components

Scenarios for Using NAT Gateway

Implementing NAT Gateway

You can deploy and configure NAT Gateway using the Azure portal, Azure CLI, PowerShell, or ARM templates.

Deploying with Azure Portal

  1. Navigate to the Azure portal.
  2. Search for "NAT Gateways" and select it.
  3. Click "Create".
  4. Fill in the required details: Subscription, Resource Group, Name, Region, SKU (Standard), Idle Timeout (in minutes).
  5. Under "Public IP addresses", create a new Public IP Address or select an existing Public IP Prefix.
  6. Under "Subnet", select the virtual network and subnet you want to associate with the NAT Gateway.
  7. Review and create the NAT Gateway.

Example using Azure CLI


# Create a resource group
az group create --name MyResourceGroup --location eastus

# Create a virtual network and subnet
az network vnet create --name MyVNet --resource-group MyResourceGroup --location eastus --address-prefix 10.0.0.0/16
az network vnet subnet create --name MySubnet --resource-group MyResourceGroup --vnet-name MyVNet --address-prefix 10.0.1.0/24

# Create a public IP address
az network public-ip create --name MyPublicIP --resource-group MyResourceGroup --location eastus --allocation-method Static --sku Standard

# Create the NAT Gateway
az network nat gateway create --name MyNatGateway --resource-group MyResourceGroup --location eastus --public-ip-addresses MyPublicIP --idle-timeout 4

# Associate the NAT Gateway with the subnet
az network vnet subnet update --name MySubnet --resource-group MyResourceGroup --vnet-name MyVNet --nat-gateway MyNatGateway
            

NAT Gateway vs. Load Balancer Outbound Rules

Both NAT Gateway and Load Balancer outbound rules provide outbound connectivity. However, NAT Gateway offers several advantages:

Note

NAT Gateway is a Standard SKU resource. Ensure your public IP addresses or prefixes are also Standard SKU.

Tip

Consider using Public IP Prefixes for NAT Gateway to manage a range of IP addresses efficiently.

Pricing

NAT Gateway pricing is based on the amount of data processed and the hourly cost of the NAT Gateway resource. Refer to the Azure NAT Gateway pricing page for the latest details.

Further Reading