Creating a static route

Dynamic Route Server for VPC is a beta feature that is available for evaluation and testing purposes to select customers. Access is restricted to allowlisted accounts.

A static route on a dynamic route server is a manually defined network path that the dynamic route server manages in VPC routing tables on your behalf. Unlike a traditional VPC static route, a dynamic route server static route is health-aware: it is automatically added to or removed from the specified VPC routing tables based on the health of the peer group that serves as the next hop.

Before you begin

Before you create a static route:

Creating a static route in the console

To create a static route in the console, follow these steps:

  1. From your browser, open the IBM Cloud console and log in to your account.
  2. Select the Navigation menu Navigation menu icon, and then click Infrastructure VPC icon > Network > Dynamic route servers.
  3. In the list, select the dynamic route server that you want to work with, and then click the Routes tab.
  4. Click Create.
  5. Enter a name for the static route, such as my-static-route.
  6. Enter the destination CIDR where you want the traffic to be directed.
  7. For Next hop, select the peer group to use as the next hop.
  8. Optional: Enter a Route delete delay (in sec).
  9. In the Ingress routing table and Egress routing table sections, click Create to add the VPC routing tables to use. For each routing table, turn on Advertise routes if you want to advertise the routes.
  10. Click Add.

Creating a static route from the CLI

To create a static route from the CLI, follow these steps:

  1. Set up your CLI environment.

  2. Log in to your CLI environment. After you enter the password, the system prompts which account and region that you want to use:

    ibmcloud login --sso
    
  3. Enable the following feature flag:

    export IBMCLOUD_IS_FEATURE_DYNAMIC_ROUTE_SERVER=true
    
  4. Run the following command:

    ibmcloud is dynamic-route-server-static-route-create DYNAMIC_ROUTE_SERVER --destination DESTINATION (--next-hops NEXT_HOPS_JSON | @NEXT_HOPS_JSON_FILE) (--routing-tables ROUTING_TABLES_JSON | @ROUTING_TABLES_JSON_FILE) [--name NAME] [--route-delete-delay ROUTE_DELETE_DELAY] [--output JSON] [-q, --quiet]
    

Where:

DYNAMIC_ROUTE_SERVER
The dynamic route server identifier.
--destination
The destination CIDR of the static route. The host identifier in the CIDR must be zero.
--next-hops
A JSON array that defines the peer group to use as the next hop for the static route. You can specify only one next hop.
@NEXT_HOPS_JSON_FILE
A file that contains the next hops JSON payload.
--routing-tables
A JSON array that defines the VPC routing tables to add the static route to.
@ROUTING_TABLES_JSON_FILE
A file that contains the routing tables JSON payload.
--name
The name of the static route.
--route-delete-delay
The delay, in seconds, before the routes are deleted when the status of the associated peer is down. The value must be 0 - 60. The default is 0.
--output
Output in JSON format.
-q, --quiet
Suppresses verbose output.

Command examples

  • To create a static route, run the following command:

    ibmcloud is dynamic-route-server-static-route-create 0717-drs-12345678 --destination 10.50.0.0/16 --next-hops '[{"id":"0717-pg-12345678"}]' --routing-tables '[{"vpc_routing_table":{"id":"0717-rt-12345678"},"advertise":true}]' --name my-static-route-1 --route-delete-delay 5 --output JSON
    

Creating a static route with the API

To create a static route with the API, follow these steps:

  1. Set up your API environment with the required variables.

  2. Store any additional variables to use in the API commands. For example:

    • ResourceGroupId - Find the resource group ID by using the get resource groups command and then populate the variable:
    export ResourceGroupId=<your_resourcegroup_id>
    
  3. When all variables are set, create the static route:

    curl -X POST \
      "$vpc_api_endpoint/v1/dynamic_route_servers/DRS_ID/static_routes?version=$api_version&generation=2" \
      -H "Authorization: Bearer $iam_token" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "my-static-route",
        "destination": "10.0.0.0/8",
        "next_hops": [
          {
            "id": "PEER_GROUP_ID"
          }
        ],
        "routing_tables": [
          {
            "vpc_routing_table": {
              "id": "ROUTING_TABLE_ID"
            },
            "advertise": true
          }
        ]
      }'