IBM Cloud Docs
Configuring route filters

Configuring route filters

You can configure route filters using the UI, CLI, and API.

Before you begin

Before configuring a route filter, review the following information:

  • The prefix must be an IPv4 subnet CIDR indicating both the address and mask length.
  • Route filtering examples
  • You can configure a maximum of 15 import/export route filters per direct link. To increase this quota for Direct Link Connect or Direct Link Dedicated, contact IBM Support.

Configuring route filters in the UI

To create and configure route filters on a provisioned gateway, follow these steps:

  1. Log in to the Direct Link console, then click the Direct Link name in the table to show its details.
  2. Click the BGP tab, then click Route filters. Alternatively, you can use the Route filters shortcut.
  3. Depending on the route filter that you want to configure, click Import route filters or Export route filters.
  4. For Default, specify to permit or deny all routes not specified by a route filter.
  5. To create filters to add to the list, or to prioritize filters, click Configure filters.
  6. Save your configuration. You are returned to the Details page where your route configuration is displayed.

Configuring route filters from the CLI

You can create route filters with the CLI using the exportroutefilter-create and importroutefilter-create commands. For example, the following command shows how to create an export route filter:

ibmcloud dl export-route-filter-create 58e4f46f-0dab-0000-9432-3df974db0618 --action deny --prefix 10.10.10.0/24 --ge 30 --le 26

Where:

58e4f46f-0dab-0000-9432-3df974db0618
Specifies the ID of the gateway.
--action deny
Specifies the export route filter action. Valid values are 'permit' or 'deny'.
--prefix 10.10.10.0/24
Specifies an IPv4 subnet CIDR indicating both the address and mask length.
--le LE
Specify a maximum matching length (LE, less than or equal to). Optional. For more information, see About route filtering.
--ge GE
Specify a minimum matching length (GE, greater than or equal to). Optional. For more information, see About route filtering.

Configuring route filters with the API

To create route filters using the API, follow these steps:

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

  2. Store any additional variables to be used in the API commands, for example:

    direct_link_id="11111111-b540-4766-a196-14368f328eb2"
    
  3. Use either the create an export route filter or create an import route filter API. For example, the following Curl example creates an import route filter:

curl -kX POST "https://directlink.cloud.ibm.com/v1/gateways/9a3eac6d-1951-4696-8eca-8b0198f4ddaf/import_route_filters?version=2023-01-02" -H "Authorization: Bearer $token" -d {
  "action": "permit",
  "ge": 24,
  "le": 32,
  "prefix": "192.168.100.0/24"
}

For more information about export and import route filters, including Curl, Python, Java, Node, and Go examples, see the Gateway Export Route Filters and Gateway Import Route Filters API.