The Advanced Networking Services API supports configuring both source NAT (SNAT) and destination NAT (DNAT) rules. When you update (PUT) a NAT configuration, all the rules (both SNAT and DNAT) must be updated together. Otherwise, only the posted rules are retained, and unposted rules are deleted.

Note

VMware recommends you issue a GET request to retrieve the NAT configuration, modify the configuration, then submit the changes by sending a PUT request.

1

Log in to vCloud Air as an administrator. See Log in to vCloud Air for information.

2

Create a login session with vCloud Director. See Create a Session for a Virtual Data Center in a Service for information.

3

Using the vCloud API, query vCloud Director for the ID of the edge gateway you require NAT configuration details about. See Querying the vCloud API for information.

1

(Optional) Request the current NAT configuration for the edge gateway. See List NAT Rules.

2

Examine the response and update the required elements.

For a description of each element of the NAT schema, see Schema for NAT Configuration.

3

Submit the updated configuration using the following request header and request body:

PUT https://vchs.vmware.com/hybridity/api/gateways/gatewayId/nat/config

In the request header, include the OATH token and the Accept header that you obtained when creating a login session:

Accept: application/json
Content-Type: application/json
X-Vcloud-Authorization: "vcloud-auth-token"

In the request body, include the schema elements you retrieved and updated from the GET request.

The server returns status 204 NO CONTENT in the response header. The server does not return a response body.

Request Header – Get the NAT Configuration

GET https://vchs.vmware.com/hybridity/api/gateways/gw-5/nat/config
Accept: application/json
Content-Type: application/json
X-Vcloud-Authorization: "d6eFLOqQYfuEn2MJTp7BQ2ISEO+ZYaEgTcqBy8wZQ6js="

Request body not required.

Response Body – Get the NAT Configuration

{
"featureType": "nat",
"version": 5,
"enabled": true,
"rules": {
    "natRulesDtos": [ {
            "ruleId": 196609,
            "ruleTag": 196609,
            "ruleType": "user",
            "action": "dnat",
            "vnic": "0",
            "originalAddress": "10.112.200.3",
            "translatedAddress": "1.1.1.1",
            "loggingEnabled": false,
            "enabled": true,
            "description": "",
            "protocol": "any",
            "originalPort": "any",
            "translatedPort": "any"
        }
    ]
  }
}

Request Header – Add a NAT Rule

PUT https://vchs.vmware.com/hybridity/api/gateways/gw-5/nat/config
Accept: application/json
Content-Type: application/json
X-Vcloud-Authorization: "d6eFLOqQYfuEn2MJTp7BQ2ISEO+ZYaEgTcqBy8wZQ6js="

Request Body – Get the NAT Configuration

{
"featureType": "nat",
"version": 5,
"enabled": true,
"rules": {
    "natRulesDtos": [ {
            "ruleId": 196609,
            "ruleTag": 196609,
            "ruleType": "user",
            "action": "dnat",
            "vnic": "0",
            "originalAddress": "10.112.200.3",
            "translatedAddress": "1.1.1.1",
            "loggingEnabled": false,
            "enabled": true,
            "description": "",
            "protocol": "any",
            "originalPort": "any",
            "translatedPort": "any"
        } {
            "ruleId": 196610,
            "ruleTag": 196610,
            "ruleType": "user",
            "action": "snat",
            "vnic": "0",
            "originalAddress": "192.168.10.1",
            "translatedAddress": "10.112.200.3",
            "loggingEnabled": false,
            "enabled": true,
            "description": "",
            "protocol": "any",
            "originalPort": "any",
            "translatedPort": "any"
        }
    ]
  }
}

Add a corresponding edge gateway firewall rule for the SNAT or DNAT rule you just configured. See Configure the Edge Gateway Firewall.