Route

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
  • Java-SDK
  • arrow
  • Route
Table of contents on this page
  • Confirm Endpoint
  • Retrieve access key
  • Create RouteClient
  • Create a route client with STS
  • Request STS Token
  • Create route client with STS token
  • Configure HTTPS protocol access route
  • Configure RouteClient
  • Use a proxy
  • Set network parameters
  • Query route table
  • Create route rules
  • Delete route rules
  • Update route rules
  • Query routing rules with pagination
  • Active-standby route switch
  • Appendix

Route

Updated at:2025-10-16

Confirm Endpoint

Before configuring the endpoint for SDK usage, please refer to the developer guide section on API Service Domain Name to understand endpoint-related concepts. Baidu AI Cloud currently supports multiple regions. Please refer toRegion Selection Guide.

The currently supported region details are as follows:

Access region Endpoint
Beijing bcc.bj.baidubce.com
Guangzhou bcc.gz.baidubce.com
Suzhou bcc.su.baidubce.com
Hong Kong bcc.hkg.baidubce.com
Wuhan bcc.fwh.baidubce.com
Baoding bcc.bd.baidubce.com

Retrieve access key

To use Baidu AI Cloud route, you need a valid AK (Access Key ID) and SK (Secret Access Key) for signature certification. AK/SK are system-assigned strings used to identify users and perform signature certification for route. Your AK/SK information can be obtained and understood through the following steps:

Register a Baidu AI Cloud account

Create AK/SK

Create RouteClient

The Route client acts as the client for route services, offering developers various methods to interact with those services.

Create a new route client with AK/SK Users can refer to the following code to create a new route client to access route with AK/SK:

Plain Text
1public class Sample {
2    public static void main(String[] args) {
3 String ACCESS_KEY_ID =<your-access-key-id>;                   // User’s Access Key ID
4 String SECRET_ACCESS_KEY =<your-secret-access-key>;           // User’s Secret Access Key
5 // Initialize a route client
6        BceClientConfiguration config = new BceClientConfiguration();
7        config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
8        RouteClient client = new RouteClient(config);
9    }
10}

In the code above, ACCESS_KEY_ID corresponds to “Access Key ID” in the console. SECRET_ACCESS_KEY corresponds to “Access Key Secret” in the console. For the method to get them, refer to Guide - Manage ACCESSKEY.

This method adopts the default domain name as the service address for the route. To use a custom domain name, provide the ENDPOINT parameter.

Plain Text
1String ACCESS_KEY_ID =<your-access-key-id>;                   // User’s Access Key ID
2 String SECRET_ACCESS_KEY =<your-secret-access-key>;           // User’s Secret Access Key
3 String ENDPOINT = <domain-name>;                               // User-defined domain name
4BceClientConfiguration config = new BceClientConfiguration();
5config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID,SECRET_ACCESS_KEY));
6config.setEndpoint(ENDPOINT);
7RouteClient client = new RouteClient(config);

Note: The ENDPOINT parameter must use region-specific domain names. If not specified, it defaults to the Beijing region.

Create a route client with STS

Request STS Token

Route supports temporary third-party access authorization through the STS mechanism. STS (Security Token Service) is a temporary authorization service provided by Baidu AI Cloud. Using STS, you can issue access credentials with customized validity periods and permissions to third-party users. These users can leverage these credentials to directly call Baidu AI Cloud APIs or SDKs to access cloud resources.

To access route via STS, users must first request a certification string through the STS client. For instructions on obtaining STS credentials, refer to Baidu AI Cloud STS Usage Guide.

Create route client with STS token

After requesting the STS token, configure it in the route client. The following codes demonstrate how to create a route client:

Plain Text
1public class StsExample {
2    private static final String STS_ENDPOINT = "http://sts.bj.baidubce.com";
3    private static final String ACCESS_KEY_ID = "your accesskey id";
4    private static final String SECRET_ACCESS_KEY = "your secret accesskey";
5    public static void main(String[] args) {
6        BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY);
7        StsClient client = new StsClient(
8                new BceClientConfiguration().withEndpoint(STS_ENDPOINT).withCredentials(credentials)
9        );
10        GetSessionTokenResponse response = client.getSessionToken(new GetSessionTokenRequest());
11        // or simply call:
12        // GetSessionTokenResponse response = client.getSessionToken();
13        // or you can specify limited permissions with ACL:
14        // GetSessionTokenResponse response = client.getSessionToken(new GetSessionTokenRequest().withAcl("blabla"));
15        // build DefaultBceSessionCredentials object from response:
16        BceCredentials routestsCredentials = new DefaultBceSessionCredentials(
17                response.getAccessKeyId(),
18                response.getSecretAccessKey(),
19                response.getSessionToken());
20        System.out.println("==================================");
21        System.out.println("GetSessionToken result:");
22        System.out.println("    accessKeyId:  " + response.getAccessKeyId());
23        System.out.println("    secretAccessKey:  " + response.getSecretAccessKey());
24        System.out.println("    securityToken:  " + response.getSessionToken());
25        System.out.println("    expiresAt:  " + response.getExpiration().toString());
26        System.out.println("==================================");
27        // build Route client
28        BceClientConfiguration config = new BceClientConfiguration();
29        config.setCredentials(routestsCredentials);
30        RouteClient routeClient = new RouteClient(config);
31    }
32}

Note: When configuring a client with STS, regardless of the location of the route service endpoint, the endpoint must be set to http://sts.bj.baidubce.com.

Configure HTTPS protocol access route

Route supports HTTPS transport protocol. You can use HTTPS to access the route service in the Route Java SDK in the following two ways:

  • Specify HTTPS in the endpoint:
Plain Text
1String endpoint = "https://bcc.bj.baidubce.com";
2String ak = "ak";
3String sk = "sk";
4BceClientConfiguration config = new BceClientConfiguration();
5config.setCredentials(new DefaultBceCredentials(ak, sk));
6RouteClient client = new RouteClient(config);
  • Configure HTTPS by calling setProtocol:
Plain Text
1String endpoint = "bcc.bj.baidubce.com"; // endpoint without protocol
2String ak = "ak";
3String sk = "sk";
4BceClientConfiguration config = new BClientConfiguration();
5config.setCredentials(new DefaultBceCredentials(ak, sk));
6config.setEndpoint(ENDPOINT);
7 config.setProtocol(Protocol.HTTPS); // Defaults to HTTP if unspecified
8RouteClient client = new RouteClient(config);

Note: **If the endpoint already includes a protocol, the protocol within the endpoint takes precedence, and the setProtocol() method will be ignored.

Plain Text
1String endpoint = "https://bcc.bj.baidubce.com";
2String ak = "ak";
3String sk = "sk";
4BceClientConfiguration config = new BceClientConfiguration();
5config.setCredentials(new DefaultBceCredentials(ak, sk));
6config.setEndpoint(ENDPOINT);    
7 config.setProtocol(Protocol.HTTPS); // Invalid operation if specified in endpoint, applicable to HTTP cases
8RouteClient client = new RouteClient(config);

Configure RouteClient

To configure specific parameters for the route client, users can provide the BCE client configuration object while creating the route client. The BCE client configuration class allows you to set parameters such as proxy and maximum connection count for the client.

Use a proxy

The following code snippet enables the client to access route service using a proxy:

Plain Text
1String ACCESS_KEY_ID =<your-access-key-id>;                   // User’s Access Key ID
2 String SECRET_ACCESS_KEY =<your-secret-access-key>;           // User’s Secret Access Key
3 String ENDPOINT = <domain-name>;                               // User-defined domain name
4 // Create BceClientConfiguration instance
5BceClientConfiguration config = new BceClientConfiguration();
6 // Configure proxy to local port 8080
7config.setProxyHost("127.0.0.1");
8config.setProxyPort(8080);
9 // Create route client
10config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID,SECRET_ACCESS_KEY));
11config.setEndpoint(ENDPOINT);
12RouteClient client = new RouteClient(config);

All client requests will then be routed through the proxy at 127.0.0.1:8080.

For verified proxies, configure credentials:

Plain Text
1// Create BceClientConfiguration instance
2BceClientConfiguration config = new BceClientConfiguration();
3    
4 // Configure proxy to local port 8080
5config.setProxyHost("127.0.0.1");
6config.setProxyPort(8080);
7    
8 // Set username and password
9 config.setProxyUsername(<username>);                             // Username
10 config.setProxyPassword(<password>);                             // Password

Set network parameters

Users may set the basic network parameters with BceClientConfiguration:

Plain Text
1BceClientConfiguration config = new BceClientConfiguration();
2    
3 // Set maximum number of HTTP connections to 10
4config.setMaxConnections(10);
5    
6 // Set TCP connection timeout to 5,000 milliseconds
7config.setConnectionTimeout(5000);
8    
9 // Set timeout for Socket data transmission to 2,000 milliseconds
10config.setSocketTimeout(2000);

Parameter description

The following parameters can be configured via BceClientConfiguration:

Parameters Description
UserAgent User agent, refers to HTTP’s User-Agent header
Protocol Connection protocol type
ProxyDomain Windows domain for NTLM-verified proxy
ProxyHost Proxy server host address
ProxyPort Proxy server port
ProxyUsername Proxy verification username
ProxyPassword Proxy verification password
ProxyPreemptiveAuthenticationEnabled Enable user agent verification or not
ProxyWorkstation NTLM proxy workstation name
LocalAddress Local address
ConnectionTimeoutInMillis Timeout for establishing TCP connections (unit: ms)
SocketTimeoutInMillis Timeout for socket data transmission (unit: ms)
MaxConnections Maximum allowable HTTP connections
RetryPolicy Retry policy for connections
SocketBufferSizeInBytes Buffer size for socket operations
StreamBufferSize Stream file buffer size

Query route table

Query route table. The request parameters routeTableId and vpcId cannot both be left empty.

Function declaration

Plain Text
1  public GetRouteResponse getRoute(String routeTableId, String vpcId) {
2  }

Parameter meaning

Refer to OpenAPI documentation: Request Parameters for Querying Route Table

Response value

  • Operation succeeded
Plain Text
1{
2    "routeTableId": "rt-se9wn4za55dx",
3    "vpcId": "vpc-hdq0mqg68si0",
4    "routeRules": [
5        {
6            "routeRuleId": "rr-7651t0c1j546",
7            "sourceAddress": "0.0.0.0/0",
8            "destinationAddress": "172.16.0.0/16",
9            "nexthopId": "tgw-e5eecf9xevtnddga",
10            "nexthopType": "vpc2tgw",
11            "description": "",
12            "pathType": "normal",
13            "routeTableId": "rt-se9wn4za55dx"
14        }
15    ]
16}
  • Operation failed

For response exception list of operation failure, refer to the Exception List.

Code example

For specific code examples, refer to ExampleListRouteRule.java

Create route rules

When creating route table rules, note the following points:

  • When selecting a custom source network segment, the custom segment must fall within the range of existing subnets, excluding 0.0.0.0/0;
  • The destination segment must not overlap with the current VPC CIDR (except when either is 0.0.0.0/0);
  • The source and destination network segments of a new route entry must not duplicate those of any existing entries in the route table.

Function declaration

Plain Text
1  public CreateRouteResponse createRoute(CreateRouteRequest request){
2  }

Parameter Meaning

Refer to OpenAPI documentation: Request Parameters for Creating routing rule List

Response value

  • Operation succeeded

No return

  • Operation failed

For response exception list of operation failure, refer to the Exception List.

Code example

For specific code examples, refer to ExampleCreateRouteRule.java

Delete route rules

Function declaration

Plain Text
1  public GetRouteResponse getRoute(String routeTableId, String vpcId) {
2  }

Parameter Meaning

Refer to OpenAPI documentation: Request Parameters for Querying Route Table

Response Value

  • Operation succeeded

No return

  • Operation failed

For response exception list of operation failure, refer to the Exception List.

Code example

For specific code examples, refer to ExampleDeleteRouteRule.java

Update route rules

Function declaration

Plain Text
1  public void updateRouteRule(UpdateRouteRuleRequest updateRouteRuleRequest)  {
2  }

Parameter Meaning

Refer to OpenAPI documentation: Request Parameters for Updating routing rules

Response Value

  • Operation succeeded

No return

  • Operation failed

For response exception list of operation failure, refer to the Exception List.

Code example

For specific code examples, refer to ExampleUpdateRouteRule.java

Query routing rules with pagination

Function declaration

Plain Text
1public ListRouteRuleResponse listRouteRule(ListRouteRuleReq listRouteRuleReq) {
2}

Parameter Meaning

Refer to OpenAPI documentation: Request Parameters for Querying Route Table with Pagination

Response Value

  • Operation succeeded
Plain Text
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3    "nextMarker": "rr-rbn5yyz6rtn8",
4    "marker": "rr-y43tr5disam1",
5    "maxKeys": 1,
6    "isTruncated": true,
7    "routeRules": [
8        {
9            "routeTableId": "rt-q1zg3i8mx8p6",
10		    "description": "",
11		    "nexthopId": "vpn-snx074964j9d",
12		    "destinationAddress": "10.0.0.1/32",
13		    "sourceAddress": "192.168.0.0/20",
14		    "routeRuleId": "rr-dvq3cxpghw5e",
15		    "nexthopType": "vpn"
16        }
17    ]
18}
  • Operation failed

For response exception list of operation failure, refer to the Exception List.

Code example

For specific code examples, refer to ExampleMarkerListRouteRule.java

Active-standby route switch

Function declaration

Plain Text
1  public void switchRouteHa(String ruleId) {
2  }
3  public void switchRouteHa(SwitchRouteHaRequest switchRouteHaRequest) {
4  }

Parameter Meaning

Refer to OpenAPI documentation: Request Parameters for Switching Active-standby Route

Response value

  • Operation succeeded

No return

  • Operation failed

For response exception list of operation failure, refer to the Exception List.

Code example

For specific code examples, refer to ExampleRouteRuleSwithHa.java

Appendix

Public response information in Metadata format

Plain Text
1 {
2      "bceRequestId":"f5f0821d-45fe-439b-bbf4-fc48b639f84a",
3      "contentLength":28,
4      "contentType":"application/json;charset=UTF-8",
5      "date":1701917695000,
6      "server":"openresty/1.15.8.1"
7 }

Previous
Regular security group
Next
Service network interface card