Conditional Advertisement and Import Policy (Routing Table) with certain match conditions
BGP accepts all non-looped routes learned from neighbors and imports them into the RIB-In table. If these routes are accepted by the BGP import policy, they are then imported into the inet.0 routing table. In cases where only certain routes are required to be imported, provisions can be made such that the peer routing device exports routes based on a condition or a set of conditions.
The condition for exporting a route can be based on:
The peer the route was learned from
The interface the route was learned on
Some other required attribute
For example:
[edit] policy-options { condition condition-name { if-route-exists address table table-name; } }
This is known as conditional installation of prefixes and is described in Example: Configuring a Routing Policy for Conditional Advertisement Enabling Conditional Installation of Prefixes in a Routing Table.
Conditions in routing policies can be configured irrespective of whether they are a part of the export or import policies or both. The export policy supports these conditions inherited from the routing policy based on the existence of another route in the routing policy. However, the import policy doesn't support these conditions, and the conditions are not executed even if they are present.
Figure 1 illustrates where BGP import and export policies are applied. An import policy is
applied to inbound routes that are visible in the output of the show route
receive-protocol bgp neighbor-address
command. An export
policy is applied to outbound routes that are visible in the output of the show
route advertising-protocol bgp neighbor-address
command.
To enable conditional installation of prefixes, an export policy must be configured on the device where the prefix export has to take place. The export policy evaluates each route to verify that it satisfies all the match conditions under the from
statement. It also searches for the existence of the route defined under the condition
statement (also configured under the from
statement).
If the route does not match the entire set of required conditions defined in the policy, or if the route defined under the condition
statement does not exist in the routing table, the route is not exported to its BGP peers. Thus, a conditional export policy matches the routes for the desired route or prefix you want installed in the peers’ routing table.
To configure the conditional installation of prefixes with the help of an export policy:
Create a
condition
statement to check prefixes.[edit] policy-options { condition condition-name { if-route-exists address table table-name; } }
Create an export policy with the newly created condition using the
condition
statement.[edit] policy-options { policy-statement policy-name { term 1 { from { protocols bgp; condition condition-name; } then { accept; } } } }
Apply the export policy to the device that requires only selected prefixes to be exported from the routing table.
[edit] protocols bgp { group group-name { export policy-name; } }