NAT

VPC VPC

  • API Reference
    • ACL-Related Interfaces
      • Add ACL rule
      • Delete ACL rules
      • Query ACL rules
      • Query ACL
      • Update ACL rules
    • API function release records
    • API Overview
    • Appendix
    • Common Headers and Error Responses
    • Dedicated Gateway-Related Interfaces
      • Bind physical dedicated line
      • Create dedicated gateway
      • Create health check for dedicated gateway
      • Query dedicated gateway details
      • Query dedicated gateway list
      • Release dedicated gateway
      • Unbind physical dedicated line
      • Update dedicated gateway
    • Elastic Network Interface-Related Interfaces
      • Add intranet IP to elastic network interface in batches
      • Add Secondary IP Address of Elastic Network Interface
      • Create elastic network interface
      • Delete elastic network interface
      • Delete Intranet IP from elastic network interface in batches
      • Delete Secondary IP Address of Elastic Network Interface
      • Elastic network interface binds to EIP
      • Elastic Network Interface Mounts Cloud Product Instance
      • Elastic network interface unbinds from EIP
      • Elastic Network Interface Unmounts Cloud Product Instance
      • Query elastic network interface list
      • Query elastic network interface status
      • Query the specified elastic network interface
      • Update elastic network interface with enterprise security group
      • Update elastic network interface with regular security group
      • Update elastic network interface
    • Gateway Bandwidth Limiting Rule Related Interfaces
      • Create gateway bandwidth limiting rules
      • Delete Gateway Bandwidth Limiting Rule
      • Modify Gateway Bandwidth Limiting Rule
      • View Gateway Bandwidth Limiting Rule
    • General Description
    • High-Availability Virtual IP Address(HAVIP) Related Interfaces
      • Bind EIP to high-availability virtual IP address
      • Bind instance to high-availability virtual IP address
      • Create high-availability virtual IP address
      • Delete high-availability virtual IP address
      • Query high-availability virtual IP address list
      • Query the specified high-availability virtual IP address
      • Unbind EIP from high-availability virtual IP address
      • Unbind instance from high-availability virtual IP address
      • Update high-availability virtual IP address
    • Interface Overview
    • IPv6 Gateway-Related Interfaces
      • Add IPv6 egress-only policy
      • Bandwidth resizing for IPv6 gateway
      • Create IPv6 gateway bandwidth limiting policy
      • Create IPv6 gateway
      • Delete IPv6 gateway bandwidth limiting policy
      • Delete IPv6 Gateway
      • Delete the IPv6 egress-only policy
      • Query IPv6 gateway bandwidth limiting policy list
      • Query IPv6 gateway
      • Query the IPv6 egress-only policy list
      • Update IPv6 gateway bandwidth limiting policy
      • Update the IPv6 gateway release protection switch
    • NAT Gateway-Related Interfaces
      • Bind DNAT EIP to the NAT gateway
      • Bind SNAT EIP to the NAT gateway
      • Create DNAT rules in batches
      • Create DNAT rules
      • Create NAT gateway
      • Create SNAT rules in batches
      • Create SNAT rules
      • Delete DNAT rules
      • Delete SNAT rules
      • NAT Gateway Binds EIP
      • NAT gateway renewal
      • NAT Gateway Resize
      • NAT Gateway Unbinds EIP
      • Query DNAT rules
      • Query NAT gateway details
      • Query NAT gateway list
      • Query SNAT rules
      • Release NAT gateway
      • Unbind DNAT EIP from the NAT gateway
      • Unbind SNAT EIP from the NAT gateway
      • Update DNAT rules
      • Update NAT Delete Protection Switch
      • Update NAT gateway name
      • Update SNAT rules
    • Network Detection Related Interfaces
      • Create Network Probe
      • Delete network probe
      • Query network probe details
      • Query network probe list.
      • Update probe
    • Parameter Template-Related Interfaces
      • Add IP addresses to the IP address family
      • Add IP addresses to the IP address group
      • Create IP address family
      • Create IP address set
      • Delete IP address family
      • Delete IP address from IP address group
      • Delete IP address set
      • Query IP address family list
      • Query IP address group list
      • Query specified IP address family
      • Query specified IP address group
      • Remove IP address group from IP address family
      • Update IP address family
      • Update IP address set
    • Peering Connections-Related Interfaces
      • Application to process the peering connection
      • Bandwidth resizing for peering connections
      • Create peering connections
      • Disable DNS synchronization for the peering connections.
      • Enable DNS synchronization for the peering connections
      • List of peering connections to be queried.
      • Peering connection renewal
      • Release peering connections
      • Update the local API name and remarks for peering connections
      • Update the peering connection release protection switch
      • View details of peering connection
    • Route Table Related Interfaces
      • Create route rules
      • Delete route rules
      • Primary-standby switch
      • Query route table
      • Query routing rules
      • Update route rules
    • Security Group Related Interfaces
      • Enterprise security group
        • Authorize enterprise security group rules
        • Create enterprise security group
        • Delete enterprise security group rules
        • Delete enterprise security group
        • Query enterprise security group list
        • Update enterprise security group rules
      • Regular security group
        • Authorize regular security group rules
        • Create regular security group
        • Delete regular security group rules
        • Delete regular security group
        • Query regular security group list
        • Revoke regular security group rules
        • Update regular security group rules
        • View security group details
    • Service domain
    • Service Network Interface Card (SNIC)-Related Interfaces
      • Create service network interface card
      • Delete service network interface card
      • Query mountable public services
      • Query service network interface card details
      • Query service network interface card list
      • Update regular security group for service network interface card
      • Update service network interface card with enterprise security group
      • Update the service network interface card
    • Subnet-Related Interfaces
      • Create reserved network segment
      • Create subnet
      • Delete reserved network segment
      • Delete subnet
      • Query specified subnet
      • Query subnet list
      • Query the reserved network segment list
      • Update subnet
    • VPC-Related Interfaces
      • Create VPC
      • Delete VPC
      • Open VPC relay
      • Query IP Usage by Products in VPC
      • Query specified VPC
      • Query VPC intranet IP
      • Query VPC list
      • Shut down VPC relay
      • Update VPC
    • VPN-Related Interfaces
      • Bind EIP
      • Create SSL VPN server
      • Create SSL VPN users in batches
      • Create VPN tunnel
      • Create VPN
      • Delete SSL VPN server
      • Delete SSL VPN user
      • Delete VPN tunnel
      • Query SSL-VPN server
      • Query SSL-VPN user
      • Query VPN details
      • Query VPN List
      • Query VPN tunnels
      • Release VPN
      • Unbind EIP
      • Update SSL VPN server
      • Update SSL VPN user
      • Update VPN release protection switch
      • Update VPN tunnel
      • Update VPN
      • VPN gateway renewal
    • High-Availability Virtual IP Address (HAVIP) Related Interfaces
      • Bind EIP to high-availability virtual IP address
      • Bind instance to high-availability virtual IP address
      • Create high-availability virtual IP address
      • Delete high-availability virtual IP address
      • Query high-availability virtual IP address list
      • Query the specified high-availability virtual IP address
      • Unbind EIP from high-availability virtual IP address
      • Unbind instance from high-availability virtual IP address
      • Update high-availability virtual IP address
  • FAQs
    • Common Questions Overview
    • NAT FAQs
    • Route Table FAQs
    • Service Network Interface Card(SNIC) Common Questions
    • VPC FAQs
    • VPN FAQs
    • Service Network Interface Card (SNIC) Common Questions
  • Function Release Records
  • Operation guide
    • Access control
      • ACL
      • Parameter Template
      • Security group
    • Identity and access management
    • Monitor and Operations
      • NAT Gateway Instance Diagnosis
    • Network Connection
      • Dedicated gateway
      • IPv6 gateway
      • Layer 2 Gateway
      • NAT Gateway
        • Private Network NAT(Network Address Translation) Gateway
        • Public Network NAT(Network Address Translation) Gateway
        • Private Network NAT (Network Address Translation) Gateway
        • Public Network NAT (Network Address Translation) Gateway
      • Peering Connections
      • VPN Gateway
        • GRE VPN Gateway
        • IPsec VPN Gateway
        • SSL VPN Gateway
    • Network Diagnostics
      • Flow log
      • Gateway bandwidth limiting
      • Network probe
      • Path analysis
      • Port verification
      • Traffic monitor
    • Network interface card
      • Elastic network interface
      • High-availability virtual IP address (HAVIP)
      • Service network interface card
    • Network topology
    • Route table
    • Subnet
    • Tag Management
    • Using IPv6
    • VPC
  • Product Description
    • Application scenarios
    • Product advantages
    • Product features
    • Product Introduction
    • Related concepts
    • Usage restrictions
  • Product pricing
  • SDK
    • Go-SDK
      • ACL
      • Dedicated gateway
      • Elastic network interface
      • Exception handling
      • High-availability virtual IP address (HAVIP)
      • Initialization
      • Install the SDK Package
      • IPv6Gateway
      • NAT
      • Network probe
      • Overview
      • Peering Connections
      • Route
      • Security group
        • Enterprise security group
        • Regular security group
      • Service network interface card
      • Subnet
      • VPC
      • VPN
    • Java-SDK
      • ACL
      • Dedicated gateway
      • Elastic network interface
      • Enterprise security group
      • High-availability virtual IP address (HAVIP)
      • Install the SDK Package
      • IPv6 gateway
      • NAT
      • Network probe
      • Overview
      • Parameter Template
      • Peering Connections
      • Regular security group
      • Route
      • Service network interface card
      • Subnet
      • Version history
      • vpc
      • VPN
    • PHP-SDK
      • ACL
      • Install the SDK Package
      • NAT
      • Overview
      • Peering Connections
      • Route
      • Security group
      • Subnet
      • Version history
      • vpc
    • Python-SDK
      • ACL
      • Dedicated gateway
      • Elastic network interface
      • Enterprise security group
      • High-availability virtual IP address (HAVIP)
      • Install the SDK Package
      • IPv6Gateway
      • NAT
      • Network probe
      • Overview
      • Peering Connections
      • Route
      • Security group
      • Service network interface card
      • Subnet
      • Version history
      • VPC
      • VPN
  • Service Level Agreement (SLA)
    • IPv6 Gateway Service Level Agreement SLA
    • NAT(Network Address Translation) Gateway Service Level Agreement SLA
    • Peering Connections Service Level Agreement SLA
    • Service Network Interface Card(SNIC) Service Level Agreement SLA
    • VPN Gateway Service Level Agreement SLA
    • NAT (Network Address Translation) Gateway Service Level Agreement SLA
    • Service Network Interface Card (SNIC) Service Level Agreement SLA
  • Typical Practices
    • Configure Custom Service and Use Service Network Interface Card(SNIC) to Provide Service for Other VPCs
    • HAVIP Combined with Keepalived to Achieve Master-Backup Multi-Machine High Availability
    • Layer 2 Gateway Combined with Dedicated Line Access ET to Build Large Layer 2 Network Between IDC and Cloud VPC
    • Network Layer Security Description
    • Peering Connections Typical Practice
    • Security Group Configuration Practice (Advanced Level)
    • Security Group Configuration Practice (Beginner Level)
    • Typical Practice of Managing Elastic Network Interface Using Terraform
    • Typical Practice of Managing IPsec VPN Gateway Using Terraform
    • Using Keepalived in VPC to Achieve High-Availability Architecture
    • VPC Custom Route Table to Achieve Secure Traffic Mutual Access
    • Windows Using HAVIP to Configure Master-Backup Multi-Machine
    • Configure Custom Service and Use Service Network Interface Card (SNIC) to Provide Service for Other VPCs
  • VPC CLI
    • Configure BCE-CLI
    • Install BCE-CLI
    • Route Table Related Operations
    • Subnet Related Operations
    • Using VPC Service via CLI
    • Version Change Records
    • VPC Related Operations
All documents
menu
No results found, please re-enter

VPC VPC

  • API Reference
    • ACL-Related Interfaces
      • Add ACL rule
      • Delete ACL rules
      • Query ACL rules
      • Query ACL
      • Update ACL rules
    • API function release records
    • API Overview
    • Appendix
    • Common Headers and Error Responses
    • Dedicated Gateway-Related Interfaces
      • Bind physical dedicated line
      • Create dedicated gateway
      • Create health check for dedicated gateway
      • Query dedicated gateway details
      • Query dedicated gateway list
      • Release dedicated gateway
      • Unbind physical dedicated line
      • Update dedicated gateway
    • Elastic Network Interface-Related Interfaces
      • Add intranet IP to elastic network interface in batches
      • Add Secondary IP Address of Elastic Network Interface
      • Create elastic network interface
      • Delete elastic network interface
      • Delete Intranet IP from elastic network interface in batches
      • Delete Secondary IP Address of Elastic Network Interface
      • Elastic network interface binds to EIP
      • Elastic Network Interface Mounts Cloud Product Instance
      • Elastic network interface unbinds from EIP
      • Elastic Network Interface Unmounts Cloud Product Instance
      • Query elastic network interface list
      • Query elastic network interface status
      • Query the specified elastic network interface
      • Update elastic network interface with enterprise security group
      • Update elastic network interface with regular security group
      • Update elastic network interface
    • Gateway Bandwidth Limiting Rule Related Interfaces
      • Create gateway bandwidth limiting rules
      • Delete Gateway Bandwidth Limiting Rule
      • Modify Gateway Bandwidth Limiting Rule
      • View Gateway Bandwidth Limiting Rule
    • General Description
    • High-Availability Virtual IP Address(HAVIP) Related Interfaces
      • Bind EIP to high-availability virtual IP address
      • Bind instance to high-availability virtual IP address
      • Create high-availability virtual IP address
      • Delete high-availability virtual IP address
      • Query high-availability virtual IP address list
      • Query the specified high-availability virtual IP address
      • Unbind EIP from high-availability virtual IP address
      • Unbind instance from high-availability virtual IP address
      • Update high-availability virtual IP address
    • Interface Overview
    • IPv6 Gateway-Related Interfaces
      • Add IPv6 egress-only policy
      • Bandwidth resizing for IPv6 gateway
      • Create IPv6 gateway bandwidth limiting policy
      • Create IPv6 gateway
      • Delete IPv6 gateway bandwidth limiting policy
      • Delete IPv6 Gateway
      • Delete the IPv6 egress-only policy
      • Query IPv6 gateway bandwidth limiting policy list
      • Query IPv6 gateway
      • Query the IPv6 egress-only policy list
      • Update IPv6 gateway bandwidth limiting policy
      • Update the IPv6 gateway release protection switch
    • NAT Gateway-Related Interfaces
      • Bind DNAT EIP to the NAT gateway
      • Bind SNAT EIP to the NAT gateway
      • Create DNAT rules in batches
      • Create DNAT rules
      • Create NAT gateway
      • Create SNAT rules in batches
      • Create SNAT rules
      • Delete DNAT rules
      • Delete SNAT rules
      • NAT Gateway Binds EIP
      • NAT gateway renewal
      • NAT Gateway Resize
      • NAT Gateway Unbinds EIP
      • Query DNAT rules
      • Query NAT gateway details
      • Query NAT gateway list
      • Query SNAT rules
      • Release NAT gateway
      • Unbind DNAT EIP from the NAT gateway
      • Unbind SNAT EIP from the NAT gateway
      • Update DNAT rules
      • Update NAT Delete Protection Switch
      • Update NAT gateway name
      • Update SNAT rules
    • Network Detection Related Interfaces
      • Create Network Probe
      • Delete network probe
      • Query network probe details
      • Query network probe list.
      • Update probe
    • Parameter Template-Related Interfaces
      • Add IP addresses to the IP address family
      • Add IP addresses to the IP address group
      • Create IP address family
      • Create IP address set
      • Delete IP address family
      • Delete IP address from IP address group
      • Delete IP address set
      • Query IP address family list
      • Query IP address group list
      • Query specified IP address family
      • Query specified IP address group
      • Remove IP address group from IP address family
      • Update IP address family
      • Update IP address set
    • Peering Connections-Related Interfaces
      • Application to process the peering connection
      • Bandwidth resizing for peering connections
      • Create peering connections
      • Disable DNS synchronization for the peering connections.
      • Enable DNS synchronization for the peering connections
      • List of peering connections to be queried.
      • Peering connection renewal
      • Release peering connections
      • Update the local API name and remarks for peering connections
      • Update the peering connection release protection switch
      • View details of peering connection
    • Route Table Related Interfaces
      • Create route rules
      • Delete route rules
      • Primary-standby switch
      • Query route table
      • Query routing rules
      • Update route rules
    • Security Group Related Interfaces
      • Enterprise security group
        • Authorize enterprise security group rules
        • Create enterprise security group
        • Delete enterprise security group rules
        • Delete enterprise security group
        • Query enterprise security group list
        • Update enterprise security group rules
      • Regular security group
        • Authorize regular security group rules
        • Create regular security group
        • Delete regular security group rules
        • Delete regular security group
        • Query regular security group list
        • Revoke regular security group rules
        • Update regular security group rules
        • View security group details
    • Service domain
    • Service Network Interface Card (SNIC)-Related Interfaces
      • Create service network interface card
      • Delete service network interface card
      • Query mountable public services
      • Query service network interface card details
      • Query service network interface card list
      • Update regular security group for service network interface card
      • Update service network interface card with enterprise security group
      • Update the service network interface card
    • Subnet-Related Interfaces
      • Create reserved network segment
      • Create subnet
      • Delete reserved network segment
      • Delete subnet
      • Query specified subnet
      • Query subnet list
      • Query the reserved network segment list
      • Update subnet
    • VPC-Related Interfaces
      • Create VPC
      • Delete VPC
      • Open VPC relay
      • Query IP Usage by Products in VPC
      • Query specified VPC
      • Query VPC intranet IP
      • Query VPC list
      • Shut down VPC relay
      • Update VPC
    • VPN-Related Interfaces
      • Bind EIP
      • Create SSL VPN server
      • Create SSL VPN users in batches
      • Create VPN tunnel
      • Create VPN
      • Delete SSL VPN server
      • Delete SSL VPN user
      • Delete VPN tunnel
      • Query SSL-VPN server
      • Query SSL-VPN user
      • Query VPN details
      • Query VPN List
      • Query VPN tunnels
      • Release VPN
      • Unbind EIP
      • Update SSL VPN server
      • Update SSL VPN user
      • Update VPN release protection switch
      • Update VPN tunnel
      • Update VPN
      • VPN gateway renewal
    • High-Availability Virtual IP Address (HAVIP) Related Interfaces
      • Bind EIP to high-availability virtual IP address
      • Bind instance to high-availability virtual IP address
      • Create high-availability virtual IP address
      • Delete high-availability virtual IP address
      • Query high-availability virtual IP address list
      • Query the specified high-availability virtual IP address
      • Unbind EIP from high-availability virtual IP address
      • Unbind instance from high-availability virtual IP address
      • Update high-availability virtual IP address
  • FAQs
    • Common Questions Overview
    • NAT FAQs
    • Route Table FAQs
    • Service Network Interface Card(SNIC) Common Questions
    • VPC FAQs
    • VPN FAQs
    • Service Network Interface Card (SNIC) Common Questions
  • Function Release Records
  • Operation guide
    • Access control
      • ACL
      • Parameter Template
      • Security group
    • Identity and access management
    • Monitor and Operations
      • NAT Gateway Instance Diagnosis
    • Network Connection
      • Dedicated gateway
      • IPv6 gateway
      • Layer 2 Gateway
      • NAT Gateway
        • Private Network NAT(Network Address Translation) Gateway
        • Public Network NAT(Network Address Translation) Gateway
        • Private Network NAT (Network Address Translation) Gateway
        • Public Network NAT (Network Address Translation) Gateway
      • Peering Connections
      • VPN Gateway
        • GRE VPN Gateway
        • IPsec VPN Gateway
        • SSL VPN Gateway
    • Network Diagnostics
      • Flow log
      • Gateway bandwidth limiting
      • Network probe
      • Path analysis
      • Port verification
      • Traffic monitor
    • Network interface card
      • Elastic network interface
      • High-availability virtual IP address (HAVIP)
      • Service network interface card
    • Network topology
    • Route table
    • Subnet
    • Tag Management
    • Using IPv6
    • VPC
  • Product Description
    • Application scenarios
    • Product advantages
    • Product features
    • Product Introduction
    • Related concepts
    • Usage restrictions
  • Product pricing
  • SDK
    • Go-SDK
      • ACL
      • Dedicated gateway
      • Elastic network interface
      • Exception handling
      • High-availability virtual IP address (HAVIP)
      • Initialization
      • Install the SDK Package
      • IPv6Gateway
      • NAT
      • Network probe
      • Overview
      • Peering Connections
      • Route
      • Security group
        • Enterprise security group
        • Regular security group
      • Service network interface card
      • Subnet
      • VPC
      • VPN
    • Java-SDK
      • ACL
      • Dedicated gateway
      • Elastic network interface
      • Enterprise security group
      • High-availability virtual IP address (HAVIP)
      • Install the SDK Package
      • IPv6 gateway
      • NAT
      • Network probe
      • Overview
      • Parameter Template
      • Peering Connections
      • Regular security group
      • Route
      • Service network interface card
      • Subnet
      • Version history
      • vpc
      • VPN
    • PHP-SDK
      • ACL
      • Install the SDK Package
      • NAT
      • Overview
      • Peering Connections
      • Route
      • Security group
      • Subnet
      • Version history
      • vpc
    • Python-SDK
      • ACL
      • Dedicated gateway
      • Elastic network interface
      • Enterprise security group
      • High-availability virtual IP address (HAVIP)
      • Install the SDK Package
      • IPv6Gateway
      • NAT
      • Network probe
      • Overview
      • Peering Connections
      • Route
      • Security group
      • Service network interface card
      • Subnet
      • Version history
      • VPC
      • VPN
  • Service Level Agreement (SLA)
    • IPv6 Gateway Service Level Agreement SLA
    • NAT(Network Address Translation) Gateway Service Level Agreement SLA
    • Peering Connections Service Level Agreement SLA
    • Service Network Interface Card(SNIC) Service Level Agreement SLA
    • VPN Gateway Service Level Agreement SLA
    • NAT (Network Address Translation) Gateway Service Level Agreement SLA
    • Service Network Interface Card (SNIC) Service Level Agreement SLA
  • Typical Practices
    • Configure Custom Service and Use Service Network Interface Card(SNIC) to Provide Service for Other VPCs
    • HAVIP Combined with Keepalived to Achieve Master-Backup Multi-Machine High Availability
    • Layer 2 Gateway Combined with Dedicated Line Access ET to Build Large Layer 2 Network Between IDC and Cloud VPC
    • Network Layer Security Description
    • Peering Connections Typical Practice
    • Security Group Configuration Practice (Advanced Level)
    • Security Group Configuration Practice (Beginner Level)
    • Typical Practice of Managing Elastic Network Interface Using Terraform
    • Typical Practice of Managing IPsec VPN Gateway Using Terraform
    • Using Keepalived in VPC to Achieve High-Availability Architecture
    • VPC Custom Route Table to Achieve Secure Traffic Mutual Access
    • Windows Using HAVIP to Configure Master-Backup Multi-Machine
    • Configure Custom Service and Use Service Network Interface Card (SNIC) to Provide Service for Other VPCs
  • VPC CLI
    • Configure BCE-CLI
    • Install BCE-CLI
    • Route Table Related Operations
    • Subnet Related Operations
    • Using VPC Service via CLI
    • Version Change Records
    • VPC Related Operations
  • Document center
  • arrow
  • VPCVPC
  • arrow
  • SDK
  • arrow
  • Python-SDK
  • arrow
  • NAT
Table of contents on this page
  • Retrieve Endpoint
  • Retrieve access key
  • nat_client
  • Create nat_client
  • Create NAT gateway
  • Query NAT gateway list
  • Query NAT gateway details
  • Update NAT gateway name
  • Release NAT gateway
  • NAT gateway renewal
  • Bind SNAT EIP to the NAT gateway
  • Unbind SNAT EIP from the NAT gateway
  • Bind DNAT EIP to the NAT gateway
  • Unbind DNAT EIP from the NAT gateway
  • Create SNAT rules
  • Create SNAT rules in batches
  • Delete SNAT rules
  • Update SNAT rules
  • Query SNAT rules
  • Create DNAT rules
  • Create DNAT rules in batches
  • Delete DNAT rules
  • Update DNAT rules
  • Query DNAT rules

NAT

Updated at:2025-10-16

Retrieve Endpoint

Before configuring the endpoint for SDK usage, please refer to the developer guide section on VPC Service Domain Name to understand endpoint-related concepts. Baidu AI Cloud currently supports multiple regions. Please refer to the VPC section in the Region Selection Guide. NAT service is part of the VPC service and adopts the VPC service domain name.

Retrieve access key

To use the Baidu AI Cloud products, you need a Baidu AI Cloud account, a valid AK (Access Key ID) and SK (Secret Access Key) for signature certification. Your AK/SK information can be obtained and understood through the following steps:

  1. Register a Baidu AI Cloud account
  2. Create AK/SK

nat_client

nat_client is the Python client for the NAT service. It packages the NAT service API, simplifying interactions for developers. Users can use nat_client methods to configure NAT gateways.

Create nat_client

When creating a nat_client, first configure a BceClientConfiguration-type config instance using endpoint, AK and SK, and then use the config instance to configure the nat_client. The specific configuration method is as follows:

Plain Text
1HOST = b''
2AK = b''
3SK = b''
4config = BceClientConfiguration(
5    credentials=BceCredentials(AK, SK), endpoint=HOST)
6self.client = nat_client.NatClient(config)

Create NAT gateway

Use the following code to create a NAT gateway

Function declaration

Python
1def create_nat(self, name, vpc_id, spec=None, billing=None, eips=None,
2                  dnat_eips=None, client_token=None, config=None, cu_num=None):

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Xjwvyul3d

Response value

Operation succeeded:

JSON
1{
2    "natId": "nat-b58rnkn1g98h"
3}

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_create_nat.py

Query NAT gateway list

Use the following code to query the NAT gateway list.

Function declaration

Python
1 def list_nats(self, vpc_id=None, nat_id=None, name=None,
2                  ip=None, marker=None, max_keys=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Tjwvyukbd

Response value

Operation succeeded:

JSON
1{
2	 "nats":[
3        {
4            "id":"nat-bir8biqwr45e",
5            "name":"mynat",
6            "vpcId":"vpc-13vuxu016dew",
7            "spec":"small",
8            "status":"unconfigured",
9            "eips":[
10            ],
11            "paymentTiming":"Prepaid",
12            "expiredTime":"2018-08-13T08:10:59Z",
13            "createTime": "2021-04-25 17:22:34"
14        },
15        {
16            "id":"nat-b9q8n98mdxwc",
17            "name":"mynat",
18            "vpcId":"vpc-13vuxu016dew",
19            "spec":"small",
20            "status":"unconfigured",
21            "eips":[
22            ],
23            "paymentTiming":"Prepaid",
24            "expiredTime":"2018-07-27T13:18:00Z",
25            "createTime": "2021-04-25 17:22:34"
26        }
27    ]
28}
29"marker":"nat-b58rnkn1g98h",
30"isTruncated": true,
31"nextMarker": "nat-bi72s924x5xu",
32"maxKeys": 2
33}    

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_list_nat.py

Query NAT gateway details

Use the following code to query the NAT gateway details

Function declaration

Python
1    def get_nat(self, nat_id, config=None):

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Mjwvyuj7m

Response value

Operation succeeded:

JSON
1{
2    "id":"nat-bir8biqwr45e",
3    "name":"mynat",
4    "vpcId":"vpc-13vuxu016dew",
5    "spec":"small",
6    "status":"unconfigured",
7    "eips":[
8    ],
9    "dnatEips":[
10    ],
11    "paymentTiming":"Prepaid",
12    "expiredTime":"2018-08-13T08:10:59Z",
13    "createTime": "2021-04-25 17:22:34",
14    "tags":[
15        {
16          "tagKey": "tagKey",
17          "tagValue": "tagValue"
18        }
19    ]
20}

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_get_nat.py

Update NAT gateway name

Use the following code to update the NAT gateway name

Function declaration

Python
1    def update_nat(self, nat_id, name, client_token=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/ojwvyuisy

Response value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_update_nat.py

Release NAT gateway

Use the following code to release a NAT gateway

Function declaration

Python
1    def delete_nat(self, nat_id, client_token=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/yjwvyujjq

Response value

Operation succeeded:

No special response parameters are available.

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_delete_nat.py

NAT gateway renewal

Use the following code to renew a NAT gateway

Function declaration

Python
1    def purchase_reserved_nat(self, nat_id, billing, client_token=None,
2                              config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Vjwvyukqv

Response Value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_purchase_reserved_nat.py

Bind SNAT EIP to the NAT gateway

Use the following code to bind an SNAT EIP

Function declaration

Python
1    def bind_eip(self, nat_id, eips, client_token=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Ljwvyujy8

Response value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_bind_eip.py

Unbind SNAT EIP from the NAT gateway

Use the following code to unbind a SNAT EIP

Function declaration

Python
1    def unbind_eip(self, nat_id, eips, client_token=None, config=None):

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/qjwvyuigl

Response value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_unbind_eip.py

Bind DNAT EIP to the NAT gateway

Use the following code to bind an DNAT EIP

Function declaration

Python
1    def bind_dnat_eip(self, nat_id, eips, client_token=None, config=None):

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/iki4chiu4

Response Value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_bind_dnat_eip.py

Unbind DNAT EIP from the NAT gateway

Use the following code to unbind a DNAT EIP

Function declaration

Python
1    def unbind_dnat_eip(self, nat_id, eips, client_token=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Uki4cj64l

Response value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_unbind_dnat_eip.py

Create SNAT rules

Users can create SNAT rules with the following code.

Function declaration

Python
1    def create_snat_rule(self, nat_id, rule_name, source_cidr, public_ip_address, client_token=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Iki4clqjv

Response Value

Operation succeeded:

JSON
1{
2    "ruleId": "rule-zrsaybxm7nrn"
3}

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_create_snat_rule.py

Create SNAT rules in batches

Users can create SNAT rules in batches with the following code.

Function declaration

Python
1    def batch_create_snat_rule(self, nat_id, snat_rules, client_token=None, config=None):

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/oktlo8qfr

Response Value

Operation succeeded:

JSON
1{
2    "snatRuleIds": [
3      "rule-zrsaybxm7nrn",
4      "rule-f5kid5g50nua"
5    ]
6}

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_batch_create_snat_rule.py

Delete SNAT rules

Users can delete SNAT rules with the following code

Function declaration

Python
1    def delete_snat_rule(self, nat_id, snat_rule_id, client_token=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/vki4cot86

Response value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_delete_snat_rule.py

Update SNAT rules

Users can update SNAT rules with the following code

Function declaration

Python
1def update_snat_rule(self, nat_id, snat_rule_id, rule_name=None, source_cidr=None,
2                         public_ip_address=None, client_token=None, config=None):

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Vki4cn14y

Response value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_update_snat_rule.py

Query SNAT rules

Users can query SNAT rules with the following code

Function declaration

Python
1    def list_snat_rule(self, nat_id, marker=None, maxKeys=None, client_token=None, config=None):

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Pki4cq2nu

Response value

Operation succeeded:

JSON
1{
2	"isTruncated": true,
3    "nextMarker": "rule-vza86i2k6dqu",
4    "maxKeys": 2,
5    "rules": [
6     {
7            "ruleId": "rule-k1jenum3v9s6",
8            "ruleName": "s3",
9            "publicIpsAddress": [
10                "100.88.10.185"
11            ],
12            "sourceCIDR": "1.1.1.1/32",
13            "status": "configuring"
14        },
15        {
16            "ruleId": "rule-kdgqkwpske2q",
17            "ruleName": "s2",
18            "publicIpsAddress": [
19                "100.88.10.185"
20            ],
21            "sourceCIDR": "192.168.1.0/24",
22            "status": "configuring"
23        }
24    ]
25}

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_list_snat_rule.py

Create DNAT rules

Users can create DNAT rules with the following code.

Function declaration

Python
1    def create_dnat_rule(self, nat_id, public_ip_address, private_ip_address, protocol, rule_name=None,
2                         public_port=None, private_port=None, client_token=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/fki4c1gb3

Response value

Operation succeeded:

JSON
1{
2    "ruleId": "rule-zrsaybxm7nrn"
3}

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_create_dnat_rule.py

Create DNAT rules in batches

Users can create DNAT rules in batches with the following code.

Function declaration

Python
1    def batch_create_dnat_rule(self, nat_id, dnat_rules, client_token=None, config=None):

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Aktl8mzvd

Response Value

Operation succeeded:

JSON
1{
2    "ruleIds": [
3      "rule-zrsaybxm7nrn",
4      "rule-f5kid5g50nua"
5    ]
6}

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_batch_create_dnat_rule.py

Delete DNAT rules

Users can delete DNAT rules with the following code

Function declaration

Python
1    def delete_dnat_rule(self, nat_id, dnat_rule_id, client_token=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/zki4cbkkf

Response Value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_delete_dnat_rule.py

Update DNAT rules

Users can update DNAT rules with the following code

Function declaration

Python
1    def update_dnat_rule(self, nat_id, dnat_rule_id,
2                         public_ip_address=None, private_ip_address=None,
3                         rule_name=None, protocol=None, public_port=None,
4                         private_port=None, client_token=None, config=None):

Parameter Meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Aki4c9crm

Response value

Operation succeeded:

There are no special response parameters

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_update_dnat_rule.py

Query DNAT rules

Users can query DNAT rules with the following code

Function declaration

Python
1    def list_dnat_rule(self, nat_id, marker=None, maxKeys=None, client_token=None, config=None):

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Hki4cf6bf

Response value

Operation succeeded:

JSON
1{
2	"isTruncated": true,
3    "nextMarker": "rule-pej10dar6pxd",
4    "maxKeys": 2,
5    "rules": [
6        {
7            "ruleId": "rule-29d9jpprcm75",
8            "ruleName": "sg",
9            "publicIpAddress": "100.88.6.197",
10            "privateIpAddress": "192.168.3.3",
11            "publicPort": 333,
12            "privatePort": 333,
13            "status": "active",
14            "protocol": "TCP"
15        },
16        {
17            "ruleId": "rule-72z6p8ni6rce",
18            "ruleName": "sd",
19            "publicIpAddress": "100.88.6.197",
20            "privateIpAddress": "192.168.2.2",
21            "publicPort": 222,
22            "privatePort": 222,
23            "status": "active",
24            "protocol": "UDP"
25        }
26    ]
27}

Operation failed:

Throw an exception. For the exception list, refer to NAT Gateway Exception List

Code example

For specific code examples, refer to example_list_dnat_rule.py

Previous
IPv6Gateway
Next
Network probe