Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this quickstart, learn how to create a Standard V2 Azure NAT Gateway by using the Azure portal, and PowerShell. The NAT Gateway service provides scalable outbound connectivity for virtual machines in Azure.
Important
Standard V2 SKU Azure NAT Gateway is currently in PREVIEW. See the Supplemental Terms of Use for Microsoft Azure Previews for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.
Note
Terraform is currently unavailable. Use the Azure preview portal, CLI, or Azure PowerShell to create a Standard V2 NAT Gateway.
Prerequisites
- An Azure account with an active subscription. Create an account for free.
Create a resource group
Create a resource group to contain all resources for this quickstart.
- Sign in to the Azure preview portal.
Note
StandardV2 SKU NAT Gateway can be deployed through the Azure preview portal only at this time.
In the search box at the top of the portal enter Resource group. Select Resource groups in the search results.
Select + Create.
In the Basics tab of Create a resource group, enter, or select the following information.
Setting Value Subscription Select your subscription Resource group test-rg Region East US Select Review + create.
Select Create.
Create the NAT gateway
In this section, create the NAT gateway and supporting resources.
Azure NAT Gateway supports multiple deployment options for IP addresses and redundancy configurations to meet your connectivity and availability requirements.
Zone redundant IPv4 address
Sign in to the Azure preview portal.
In the search box at the top of the Azure portal, enter Public IP address. Select Public IP addresses in the search results.
Select Create.
Enter the following information in Create public IP address.
Setting Value Project details Subscription Select your subscription. Resource group Select your resource group. The example uses test-rg. Instance details Region Select a region. This example uses East US. Configuration details Name Enter public-ip-nat. IP version Select IPv4. SKU Select Standard V2 (For use with Standard V2 NAT Gateway). Tier Select Regional. Select Review + create and then select Create.
In the search box at the top of the Azure portal, enter NAT gateway. Select NAT gateways in the search results.
Select Create.
Enter or select the following information in the Basics tab of Create network address translation (NAT) gateway.
Setting Value Project details Subscription Select your subscription. Resource group Select test-rg or your resource group. Instance details NAT gateway name Enter nat-gateway. Region Select your region. This example uses East US. SKU Select Standard V2. TCP idle timeout (minutes) Leave the default of 4. Select Next.
In the Outbound IP tab, select + Add public IP addresses or prefixes.
In Add public IP addresses or prefixes, select Public IP addresses. Select the public IP address you created earlier, public-ip-nat.
Select Save.
Select Review + create, then select Create.
Zone redundant IPv4 prefix
Sign in to the Azure preview portal.
In the search box at the top of the Azure portal, enter Public IP prefix. Select Public IP Prefixes in the search results.
Select Create.
Enter the following information in the Basics tab of Create a public IP prefix.
Setting Value Project details Subscription Select your subscription. Resource group Select your resource group. This example uses test-rg. Instance details Name Enter public-ip-prefix-nat. Region Select your region. This example uses East US. Sku Select Standard V2. IP version Select IPv4. Prefix ownership Select Microsoft owned. Prefix size Select a prefix size. This example uses /28 (16 addresses). Select Review + create, then select Create.
In the search box at the top of the Azure portal, enter NAT gateway. Select NAT gateways in the search results.
Select Create.
Enter or select the following information in the Basics tab of Create network address translation (NAT) gateway.
Setting Value Project details Subscription Select your subscription. Resource group Select test-rg or your resource group. Instance details NAT gateway name Enter nat-gateway. Region Select your region. This example uses East US. SKU Select Standard V2. TCP idle timeout (minutes) Leave the default of 4. Select Next.
In the Outbound IP tab, select + Add public IP addresses or prefixes.
In Add public IP addresses or prefixes, select Public IP prefixes. Select the public IP prefix you created earlier, public-ip-prefix-nat.
Select Review + create, then select Create.
Create virtual network and subnet configurations
Create the virtual network and subnets needed for this quickstart.
In the search box at the top of the Azure portal, enter Virtual network. Select Virtual networks in the search results.
Select Create.
Enter or select the following information in the Basics tab of Create virtual network.
Setting Value Project details Subscription Select your subscription. Resource group Select test-rg or your resource group. Instance details Name Enter vnet-1. Region Select your region. This example uses East US. Select the IP Addresses tab, or select Next, then Next.
In Subnets select the default subnet.
Enter or select the following information in Edit subnet.
Setting Value Subnet purpose Leave the default. Name Enter subnet-1. Private subnet Enable private subnet (no default outbound access) Check the box. Security NAT gateway Select nat-gateway. Select Save.
Select + Add a subnet.
In Add a subnet enter or select the following information.
Setting Value Subnet purpose Select Azure Bastion. Leave the rest of the settings as default, then select Add.
Select Review + create, then select Create.
Create Azure Bastion host
Create an Azure Bastion host to securely connect to the virtual machine.
In the search box at the top of the Azure portal, enter Bastion. Select Bastions in the search results.
Select Create.
Enter or select the following information in the Basics tab of Create a Bastion.
Setting Value Project details Subscription Select your subscription. Resource group Select test-rg or your resource group. Instance details Name Enter bastion. Region Select your region. This example uses East US. Tier Select Developer. Virtual network Select vnet-1. Subnet Select AzureBastionSubnet. Select Review + create, then select Create.
The bastion host can take several minutes to deploy. Wait for the bastion host to deploy before moving on to the next section.
Create virtual machine
In this section, you create a virtual machine to test the NAT gateway and verify the public IP address of the outbound connection. The following command creates SSH keys for authentication. The private key is needed later to sign in to the virtual machine through Azure Bastion. The username and password credential is required for the command. The password isn't used to sign in to the virtual machine.
In the search box at the top of the portal, enter Virtual machine. Select Virtual machines in the search results.
Select Create > Virtual machine.
In Create a virtual machine enter or select the following information in the Basics tab.
Setting Value Project details Subscription Select your subscription. Resource group Select test-rg or your resource group. Instance details Virtual machine name Enter vm-1. Region Select your region. This example uses East US. Availability options Leave the default of No infrastructure redundancy required. Security type Select Standard. Image Select Ubuntu Server 24.04 LTS - Gen2. Size Select a size Authentication type Select SSH public key. Username Enter a username of your choice. You need this username to sign in to the virtual machine later. SSH public key source Select Generate new key pair. Key pair name Enter ssh-key. Public inbound ports Select None. Select Next: Disks, then select Next: Networking.
In the Networking tab, enter or select the following information.
Setting Value Network interface Virtual network Select vnet-1. Subnet Select subnet-1. Public IP Select None. NIC network security group Select Basic. Public inbound ports Leave the default of None. Select Review + create, then select Create.
Wait for the virtual machine creation to complete before moving on to the next section.
Important
Ensure that you download the SSH private key to the virtual machine. You need the private key to sign in to the virtual machine through Azure Bastion.
Test NAT gateway
In this section, you test the NAT gateway. You first discover the public IP of the NAT gateway. You then connect to the test virtual machine and verify the outbound connection through the NAT gateway public IP.
In the search box at the top of the portal, enter NAT gateway. Select NAT gateways in the search results.
Select nat-gateway.
Expand Settings, then select Outbound IP.
Make note of the IP address deployed for the outbound IP address. Individual Public IPs and Public IP Prefixes configured for the NAT gateway are listed here.
In the search box at the top of the portal, enter Virtual machine. Select Virtual machines in the search results.
Select vm-1.
On the Overview page, select Connect, then select Connect via Bastion.
In the Authentication pull-down, select SSH Private Key From Local File.
In Username, enter the username you entered during virtual machine creation.
In Local File, select the SSH private key file you downloaded earlier.
Select Connect.
In the bash prompt, enter the following command:
curl ifconfig.meVerify the IP address returned by the command matches the public IP address of the NAT gateway you noted earlier.
azureuser@vm-1:~$ curl ifconfig.me 203.0.113.0.25
Clean up resources
When you finish using the resources that you created, you can delete the resource group and all its resources.
In the Azure portal, search for and select Resource groups.
On the Resource groups page, select the test-rg resource group.
On the test-rg page, select Delete resource group.
Enter test-rg in Enter resource group name to confirm deletion, and then select Delete.
Next steps
For more information on Azure NAT Gateway, see: