百度智能云

All Product Document

          Virtual Private Cloud

          NAT

          Acquire Endpoint

          When confirming the Endpoint configured when you use the SDK, you can first read the section on VPC Sservice Domain Name in the Developer Guide to understand the Endpoint concept. Baidu AI Cloud currently opens the multi-region (Region) support. Please refer to the part of network product VPC in Region Selection Introduction. The NAT services are a part of VPC services, and use the VPC service domain name.

          Get the Key

          To use Baidu Cloud products, you need to have a Baidu Cloud account and a valid AK (Access Key ID) and SK (Secret Access Key) for signature verification. You can obtain and understand your AK/SK information through the following steps:

          1.[Register Baidu Cloud Account](https://login.bce.baidu.com/reg.html? tpl=bceplat&from=portal)

          2.[Create AK/SK](https://console.bce.baidu.com/iam/? _=1513940574695#/iam/accesslist)

          NatClient

          Natclient is the PHP client of NAT services, encapsulates the API of NAT services, and simplifies the interaction between developers and NAT services. The users can call the methods in NatClient to configure the NAT gateway. The method return parameter in NatClient is consistent with [API Method](https://console.bce.baidu.com/iam/? _=1513940574695#/iam/accesslist).

          Create NatClient

          When creating NatClient, you need to first use Endpoint, AK and SK to configure the g_NatConfigs, and then use the g_NatConfigs to configure the NatClient. The specific configuration method is as follows:

          $g_NatConfigs = array(
              'credentials' => array(
                  'ak' => '',
                  'sk' => '',
              ),
              'endpoint' => '',
          );
          public $client;
          client = new NatClient($g_NatConfigs);

          Create an NAT Gateway

          The createNat function can be used to create the gateway in the specified VPC, and is defined as below:

          public function createNat($name, $vpcId, $spec, $eips = null, $billing = null, $clientToken = null,  $options = array())

          The parameters are described as follows:

          Parameter name Type Required or not Description
          name string Yes The name of NAT gateway is composed by upper and lower case letters, numbers, and -_ /. special characters, and must start with letters, with a length of 1-65.
          vpcId string Yes ID of VPC to which NAT gateway belongs
          spec string Yes The size of NAT gateway is divided into three kinds: small (supporting binding a maximum of 5 public network IPs), medium (supporting binding a maximum of 10 public network IPs) and large (supporting binding a maximum of 15 public network IPs).
          billing Customized Billing type No The billing mode is postpaid by default and supports the monthly repayment. Refer to Billing Description for details.
          eips array No EIP bound to the NAT gateway
          clientToken string No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          options array No For the additional configurations, the parameters in the option can be used to temporarily replace the default parameters (AK, SK and Endpoint) in NatClient.

          For the customized Billing type definition, refer to Billing.php.

          Query the NAT Gateway List

          The listNats function can be used to query the NAT gateway list. If the query condition is queried, the NAT gateways are screened according to the query condition. If no query condition is provided, all NAT gateways are queried by default. The function is defined as below:

          public function listNats($vpcId, $natId = null, $name = null, $ip = null, $marker = null, $maxKeys = 1000,$options = array())

          The parameters are described as follows:

          Parameter name Type Required or not Description
          vpcId string Yes ID of VPC to which NAT gateway belongs
          natId string No ID of NAT gateway
          name string No Name of NAT gateway
          ip string No IP address bound to the gateway
          marker string No Starting location of query for batch acquisition of lists
          maxKeys int No Maximum number contained in each page, generally not exceeding 1000. The default value is 1000.
          options array No For the additional configurations, the parameters in the option can be used to temporarily replace the default parameters (AK, SK and Endpoint) in NatClient.

          Query the NAT Gateway Details

          The detailNats function can be used to query the NAT details, and is defined as below:

          public function detailNats($natId, $options = array())

          The parameters are described as follows:

          Parameter name Type Required or not Description
          natId string Yes ID of NAT gateway
          options array No For the additional configurations, the parameters in the option can be used to temporarily replace the default parameters (AK, SK and Endpoint) in NatClient.

          Update the NAT Gateway Name

          The renameNat function can be used to update the NAT gateway name, and is defined as below:

          public function renameNat($natId, $name, $clientToken = null, $options = array())

          The parameters are described as follows:

          Parameter name Type Required or not Description
          natId string Yes ID of NAT gateway
          name string Yes New name of NAT gateway
          clientToken string No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          options array No For the additional configurations, the parameters in the option can be used to temporarily replace the default parameters (AK, SK and Endpoint) in NatClient.

          Bind EIP

          The bindNat function can be used to bind EIP to the NAT gateway, and is defined as below:

          public function bindNat($eips, $natId, $clientToken = null, $options = array())

          The parameters are described as follows:

          Parameter name Type Required or not Description
          natId string Yes ID of NAT gateway
          eips array Yes EIP to be bound to the NAT gateway
          clientToken string No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          options array No For the additional configurations, the parameters in the option can be used to temporarily replace the default parameters (AK, SK and Endpoint) in NatClient.

          Unbind EIP

          The unbindNat function can be used to unbind EIP from the NAT gateway, and is defined as below:

          public function unbindNat($eips, $natId, $clientToken = null, $options = array())

          The parameters are described as follows:

          Parameter name Type Required or not Description
          natId string Yes ID of NAT gateway
          eips array Yes EIP to be unbound from the NAT gateway
          clientToken string No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          options array No For the additional configurations, the parameters in the option can be used to temporarily replace the default parameters (AK, SK and Endpoint) in NatClient.

          Release the NAT Gateway

          The releaseNat function can be used to release the NAT gateway, and is defined as below:

          public function releaseNat($natId, $clientToken = null, $options = array())

          The parameters are described as follows:

          Parameter name Type Required or not Description
          natId string Yes ID of NAT gateway
          clientToken string No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          options array No For the additional configurations, the parameters in the option can be used to temporarily replace the default parameters (AK, SK and Endpoint) in NatClient.

          NAT Gateway Renewal

          The purchaseReservedNat function can be used to renew the NAT gateway , and only the prepaid type supports the renewal operation. The function is defined as below:

          public function purchaseReservedNat($natId, $billing = null, $clientToken = null, $options = array())

          The parameters are described as follows:

          Parameter name Type Required or not Description
          natId string Yes ID of NAT gateway
          billing Customized Billing type No For the billion mode, the renewal period is 1 month by default if you don't fill in anything Billing Description for details.
          clientToken string No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          options array No For the additional configurations, the parameters in the option can be used to temporarily replace the default parameters (AK, SK and Endpoint) in NatClient.
          Previous
          Route
          Next
          Peer Connection