For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create a NAT Gateway Rule

Create a NAT gateway rule to configure Source NAT (SNAT) behavior for your private network traffic using the POST request. The rules determine which private IP addresses can access the Internet through the NAT gateway.

Rule specifications: Define a name, protocol (TCP, UDP, ICMP, ESP, AH, or GRE), source subnet, and target subnet for each rule. You can also optionally specify a target port range.

Endpoint

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

Request

curl --location \
--request POST 'https://api.ionos.com/cloudapi/v6/datacenters/15f67991-0f51-4efc-a8ad-ef1fb31a480c/natgateways/d8fbc490-3b3e-4f7a-b6e1-2c8d5f3e7a9b/rules' \
--header 'Authorization: Bearer $IONOS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
  "properties": {
    "name": "Web Traffic Rule",
    "protocol": "TCP",
    "publicIp": "203.0.113.50",
    "sourceSubnet": "10.0.1.0/24",
    "targetSubnet": "0.0.0.0/0",
    "targetPortRange": {
      "start": 80,
      "end": 443
    },
    "type": "SNAT"
  }
}'

The following table lists the request body parameters:

Body Parameters

Required

Type

Description

Example

properties.name

yes

string

The name of the NAT gateway rule.

Web Traffic Rule

properties.protocol

no

string

The network protocol for the rule. If you do not specify a protocol, the system allows all supported protocols.

TCP

properties.publicIp

yes

string

The public IP address that the NAT gateway uses for the specific rule.

203.0.113.50

properties.sourceSubnet

yes

string

The source subnet in CIDR notation.

10.0.1.0/24

properties.targetSubnet

no

string

The target or destination subnet in CIDR notation.

0.0.0.0/0

properties.targetPortRange

no

object

The port range for the target subnet.

See nested properties.

properties.targetPortRange.start

no

integer

The starting port of the range.

80

properties.targetPortRange.end

no

integer

The ending port of the range.

443

properties.type

no

string

The type of NAT gateway rule.

SNAT

Include the following mandatory fields in the request header to authenticate your requests:

Header Parameters

Required

Type

Description

Authorization

yes

string

Use a Bearer token to authenticate requests through a JSON Web Token (JWT).

Content-Type

yes

string

Set it to application/json.

Response

A 202 Accepted response indicates that the NAT Gateway rule is successfully created. The id and other details are provided in the response.

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

Last updated

Was this helpful?