Add a NAT gateway

Give the instances of a network that have no public IPv4 outbound IPv4 internet access through one shared address.

Last updated 18 November 2026View as Markdown

An instance launched with enablePublicIpv4: false keeps a public IPv6 address but has no IPv4 route to the internet. A NAT gateway gives the machines of one network outbound IPv4 through one address, and lets nothing in. It is one small machine run by the platform, at a fixed address in the network, with the network route 0.0.0.0/0 to it. Replace the ids with your own.

Important

The gateway is a machine, metered for every started hour until you delete it. It is not redundant: if its machine is lost, it turns failed; delete it and create it again.

Prerequisites

  • Permission for ec2:CreateNatGateway; deleting needs ec2:DeleteNatGateway, reading ec2:DescribeNatGateways.
  • In the console, also ec2:DescribeVpcs to open the network's page (without it the page is not found).
  • One gateway per network: a second is refused with 409 "The VPC already has NAT gateway …; one per VPC". Room in the NAT gateways quota.

Create it

  1. Open Compute, then Networks, and open the network.
  2. Under NAT gateway, choose Create NAT gateway.
  3. In Create NAT gateway?, check the price, then choose Create NAT gateway.

Result

The answer is 202 with the gateway in status creating; it turns available once its machine and route are in place. status is creating, available, failed or deleting; publicAddress is what the internet sees your machines come from, privateAddress its address in the network. The console shows them as Egress address and Address in the network.

Instances launched without a public IPv4 after the gateway is available route through it on their own. An instance that already existed needs the route once, as root; the console shows the command with your network's gateway address under Route an existing instance through it (once). For a 10.0.0.0/16 network:

sudo ip route replace default via 10.0.0.1 dev $(ip -o route get 10.0.0.1 | awk '{print $3}') onlink

A problem the platform finds with the gateway (a missing route, for example) shows as The gateway reported a problem. on the network page, and as reconcileError in the API.

Delete it

  1. Under NAT gateway, choose Delete NAT gateway.
  2. In Delete the NAT gateway, choose Delete NAT gateway.

The answer is 202 with status deleting; the route goes first, then the machine. Machines without a public IPv4 lose IPv4 internet access. A network with a NAT gateway cannot be deleted until the gateway is.

Did this page help you?