Create a Managed NAT Gateway

The NAT Gateway service allows instances in a private subnet to connect to the Internet or other services but prevents inbound connections from the Internet. To create a NAT gateway, use a POST request to specify the data center, public IP addresses, and the LANs that will route through it.

Endpoint

https://api.ionos.com/cloudapi/v6/datacenters/{datacenterId}/natgateways

Request

curl --location \
--request POST 'https://api.ionos.com/cloudapi/v6/datacenters/15f67991-0f51-4efc-a8ad-ef1fb31a480c/natgateways' \
--header 'Authorization: Bearer $IONOS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
  "properties": {
    "name": "Production NAT Gateway",
    "publicIps": [
      "198.51.100.25"
    ],
    "lans": [
      {
        "id": "2",
        "gatewayIps": [
          "192.168.1.5"
        ]
      }
    ]
  }
}'

The following table lists the request body parameters:

Body Parameters

Required

Type

Description

Example

properties.name

yes

string

The name of the resource.

Production NAT Gateway

properties.publicIps

yes

array

A collection of public IP addresses. Use an IP address that you have reserved for this location.

["198.51.100.25"]

properties.lans

no

array

A collection of LANs connected to the NAT gateway. Include a valid subnet mask for each IP address. If you do not provide an IP address, the system generates an IP address with a /24 subnet.

See nested object below.

properties.lans[].id

yes

string

The ID of the LAN connected to the NAT gateway.

2

properties.lans[].gatewayIps

no

array

A collection of gateway IP addresses. The system auto-generates these if you do not provide them. These addresses must stay within the LAN's IP address range.

["192.168.1.5"]

Response

A 202 Accepted response indicates that the creation of the NAT Gateway has been initiated successfully. The response body contains the resource id and other deployment details.

circle-info

Note: NAT Gateway creation is performed asynchronously. The resource status maintains a BUSY status until provisioning completes. For core Cloud API endpoints, the response includes a Location header with a URL to poll the request status.

Last updated

Was this helpful?