Quickstart: Create a NAT gateway using the Azure portal
This quickstart shows you how to use Azure Virtual Network NAT service. You'll create a NAT gateway to provide outbound connectivity for a virtual machine in Azure.
Prerequisites
- An Azure account with an active subscription. Create an account for free.
Virtual network
Before you deploy a VM and can use your NAT gateway, we need to create the resource group and virtual network.
Sign in to the Azure portal.
On the upper-left side of the screen, select Create a resource > Networking > Virtual network or search for Virtual network in the search box.
Select Create.
In Create virtual network, enter or select this information in the Basics tab:
Setting Value Project Details Subscription Select your Azure subscription Resource Group Select Create new. Enter myResourceGroupNAT. Select OK. Instance details Name Enter myVNet Region Select (Europe) West Europe Select the IP Addresses tab or select the Next: IP Addresses button at the bottom of the page.
In the IP Addresses tab, enter this information:
Setting Value IPv4 address space Enter 10.1.0.0/16 Select + Add subnet.
In Edit subnet, enter this information:
Setting Value Subnet name Enter mySubnet Subnet address range Enter 10.1.0.0/24 Select Add.
Select the Security tab.
Under BastionHost, select Enable. Enter this information:
Setting Value Bastion name Enter myBastionHost AzureBastionSubnet address space Enter 10.1.1.0/24 Public IP Address Select Create new. For Name, enter myBastionIP. Select OK. Select the Review + create tab or select the Review + create button.
Select Create.
NAT gateway
You can use one or more public IP address resources, public IP prefixes, or both. We'll add a public IP resource and a NAT gateway resource.
On the upper-left side of the screen, select Create a resource > Networking > NAT gateway or search for NAT gateway in the search box.
Select Create.
In Create network address translation (NAT) gateway, enter or select this information in the Basics tab:
Setting Value Project Details Subscription Select your Azure subscription. Resource Group Select myResourceGroupNAT. Instance details Name Enter myNATgateway Region Select (Europe) West Europe Availability Zone Select None. Idle timeout (minutes) Enter 10. Select the Outbound IP tab, or select the Next: Outbound IP button at the bottom of the page.
In the Outbound IP tab, enter or select the following information:
Setting Value Public IP addresses Select Create a new public IP address. In Name, enter myPublicIP. Select OK. Select the Subnet tab, or select the Next: Subnet button at the bottom of the page.
In the Subnet tab, select myVNet in the Virtual network pull-down.
Check the box next to mySubnet.
Select the Review + create tab, or select the blue Review + create button at the bottom of the page.
Select Create.
Virtual machine
In this section, you'll create a virtual machine to test the NAT gateway and verify the public IP address of the outbound connection.
On the upper-left side of the portal, select Create a resource > Compute > Virtual machine.
In the Create a virtual machine page in the Basics tab, enter, or select the following information:
Setting Value Project details Subscription Select your subscription. Resource group Select myResourceGroupNAT. Instance details Virtual machine name Enter myVM. Region Select (Europe) West Europe. Availability options Select No infrastructure redundancy required. Image Select Windows Server 2019 Datacenter - Gen2. Size Select Standard_DS1_v2. Administrator account Username Enter a username for the virtual machine. Password Enter a password. Confirm password Confirm password. Inbound port rules Public inbound ports Select None. Select the Disks tab, or select the Next: Disks button at the bottom of the page.
Leave the default in the Disks tab.
Select the Networking tab, or select the Next: Networking button at the bottom of the page.
In the Networking tab, enter or select the following information:
Setting Value Network interface Virtual network Select myVNet. Subnet Select mySubnet. Public IP Select None. NIC network security group Select Basic. Public inbound ports Select None. Select the Review + create tab, or select the blue Review + create button at the bottom of the page.
Select Create.
Test NAT gateway
In this section, we'll test the NAT gateway. We'll first discover the public IP of the NAT gateway. We'll then connect to the test virtual machine and verify the outbound connection through the NAT gateway.
Find the public IP address for the NAT gateway on the Overview screen. Select All services in the left-hand menu, select All resources, and then select myPublicIP.
Make note of the public IP address:
Select All services in the left-hand menu, select All resources, and then from the resources list, select myVM that is located in the myResourceGroupNAT resource group.
On the Overview page, select Connect, then Bastion.
Select the blue Use Bastion button.
Enter the username and password entered during VM creation.
Open Internet Explorer on myTestVM.
Enter https://whatsmyip.com in the address bar.
Verify the IP address displayed matches the NAT gateway address you noted in the previous step:
Clean up resources
If you're not going to continue to use this application, delete the virtual network, virtual machine, and NAT gateway with the following steps:
From the left-hand menu, select Resource groups.
Select the myResourceGroupNAT resource group.
Select Delete resource group.
Enter myResourceGroupNAT and select Delete.
Next steps
For more information on Azure Virtual Network NAT, see:
Feedback
Submit and view feedback for