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:
- Review Planning considerations for dynamic route servers.
- Review Known issues for dynamic route servers.
- Make sure that you have a dynamic route server that is provisioned with at least one member. For more information, see Creating a dynamic route server.
Creating a static route in the console
To create a static route in the console, follow these steps:
- From your browser, open the IBM Cloud console and log in to your account.
- Select the Navigation menu
, and then click Infrastructure
> Network > Dynamic route servers.
- In the list, select the dynamic route server that you want to work with, and then click the Routes tab.
- Click Create.
- Enter a name for the static route, such as
my-static-route. - Enter the destination CIDR where you want the traffic to be directed.
- For Next hop, select the peer group to use as the next hop.
- Optional: Enter a Route delete delay (in sec).
- 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.
- Click Add.
Creating a static route from the CLI
To create a static route from the CLI, follow these steps:
-
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 -
Enable the following feature flag:
export IBMCLOUD_IS_FEATURE_DYNAMIC_ROUTE_SERVER=true -
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:
-
Set up your API environment with the required variables.
-
Store any additional variables to use in the API commands. For example:
ResourceGroupId- Find the resource group ID by using theget resource groupscommand and then populate the variable:
export ResourceGroupId=<your_resourcegroup_id> -
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 } ] }'