Configuring a Routing Policy with a Configuration Editor
A routing policy has a major impact on the flow of routing information or packets within and through the device. The match conditions and actions allow you to configure a customized policy to fit your needs.
To configure a routing policy, you must perform the following tasks marked (Required). Perform additional tasks as needed for your router. For information about using the J-Web and CLI configuration editors, see the J-Web Interface User Guide and the JUNOS CLI User Guide.
- Configuring the Policy Name (Required)
- Configuring a Policy Term (Required)
- Rejecting Known Invalid Routes (Optional)
- Injecting OSPF Routes into the BGP Routing Table (Optional)
- Grouping Source and Destination Prefixes in a Forwarding Class (Optional)
- Configuring a Policy to Prepend the AS Path (Optional)
- Configuring Damping Parameters (Optional)
Configuring the Policy Name (Required)
Each routing policy is identified by a policy name. The name can contain letters, numbers, and hyphens (-) and can be up to 255 characters long. To include spaces in the name, enclose the entire name in double quotation marks.
Each routing policy name must be unique within a configuration.
To configure the policy name:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 212.
- Go on to Configuring a Policy Term (Required).
Table 212: Configuring the Policy Name
Task | J-Web Configuration Editor | CLI Configuration Editor |
---|---|---|
Navigate to the Policy statement level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit policy-options |
Enter the policy name—for example, policy1. |
| Type the policy-name value: set policy-statement policy1 |
Configuring a Policy Term (Required)
Each routing policy term is identified by a term name. The name can contain letters, numbers, and hyphens (-) and can be up to 255 characters long. To include spaces in the name, enclose the entire name in double quotation marks.
To configure a policy term:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 213.
- If you are finished configuring the router, commit the configuration.
- To configure additional routing policy features,
go on to one of the following procedures:
- To remove useless routes, see Rejecting Known Invalid Routes (Optional).
- To advertise additional routes, see Injecting OSPF Routes into the BGP Routing Table (Optional).
- To create a forwarding class, see Grouping Source and Destination Prefixes in a Forwarding Class (Optional).
- To make a route less preferable to BGP, see Configuring a Policy to Prepend the AS Path (Optional).
- To suppress route information, see Configuring Damping Parameters (Optional).
Table 213: Configuring a Policy Term
Task | J-Web Configuration Editor | CLI Configuration Editor |
---|---|---|
Navigate to the Policy statement level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit policy-options policy-statement policy1 |
Create and name a policy term—for example, term1. |
| Create and name a policy term: set term term1 |
Rejecting Known Invalid Routes (Optional)
You can specify known invalid (“bad”) routes to ignore by specifying matches on destination prefixes. When specifying a destination prefix, you can specify an exact match with a specific route, or a less precise match by using match types. You can configure either a common reject action that applies to the entire list, or an action associated with each prefix. Table 214 lists route list match types.
Table 214: Route List Match Types
Match Type | Match Conditions |
---|---|
exact | The route shares the same most-significant bits (described by prefix-length), and prefix-length is equal to the route's prefix length. |
longer | The route shares the same most-significant bits (described by prefix-length), and prefix-length is greater than the route's prefix length. |
orlonger | The route shares the same most-significant bits (described by prefix-length), and prefix-length is equal to or greater than the route's prefix length. |
prefix-length-range prefix-length2-prefix-length3 | The route shares the same most-significant bits (described by prefix-length), and the route's prefix length falls between prefix-length2 and prefix-length3, inclusive. |
through destination-prefix | All the following are true:
You do not use the through match type in most routing policy configurations. For more information, see the JUNOS Policy Framework Configuration Guide. |
upto prefix-length2 | The route shares the same most-significant bits (described by prefix-length) and the route's prefix length falls between prefix-length and prefix-length2. |
For example, you can create a policy named rejectpolicy1 to reject routes with a mask of /8 and greater (/8, /9, /10, and so on) that have the first 8 bits set to 0, and to accept routes less than 8 bits in length.
To create rejectpolicy1:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 215.
- If you are finished configuring the router, commit the configuration.
- To configure additional routing policy features,
go on to one of the following procedures:
- To advertise additional routes, see Injecting OSPF Routes into the BGP Routing Table (Optional).
- To create a forwarding class, see Grouping Source and Destination Prefixes in a Forwarding Class (Optional).
- To make a route less preferable to BGP, see Configuring a Policy to Prepend the AS Path (Optional).
- To suppress route information, see Configuring Damping Parameters (Optional).
Table 215: Creating a Policy to Reject Known Invalid Routes
Task | J-Web Configuration Editor | CLI Configuration Editor |
---|---|---|
Navigate to the Policy statement level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit policy-options policy-statement |
Create a rejection policy and term—for example, rejectpolicy1 and rejectterm1. |
| Enter set rejectpolicy1 term rejectterm1 |
Specify the routes to accept—for example, routes with a mask of 0/0 up to /7. |
| Accept routes less than 8 bits in length: set from route-filter 0/0 up to /7 accept |
Specify the routes to reject—for example, routes with a mask of /8 or greater. |
|
|
Injecting OSPF Routes into the BGP Routing Table (Optional)
You can specify a match condition for policies based on protocols by naming a protocol from which the route is learned or to which the route is being advertised. You can specify one of the following protocols: aggregate, BGP, direct, DVMRP, IS-IS, local, OSPF, PIM-dense, PIM-sparse, RIP, or static
For example, you can inject or redistribute OSPF routes into the BGP routing table by creating a routing policy.
To create a routing policy named injectpolicy1 that redistributes OSPF routes from Area 1 only into BGP and does not advertise routes learned by BGP:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 216.
- If you are finished configuring the router, commit the configuration.
- To configure additional routing policy features,
go on to one of the following procedures:
- To create a forwarding class, see Grouping Source and Destination Prefixes in a Forwarding Class (Optional).
- To make a route less preferable to BGP, see Configuring a Policy to Prepend the AS Path (Optional).
- To suppress route information, see Configuring Damping Parameters (Optional).
Table 216: Creating a Policy to Inject OSPF Routes into BGP
Task | J-Web Configuration Editor | CLI Configuration Editor |
---|---|---|
Navigate to the Policy statement level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit policy-options policy-statement |
Create an injection policy and term—for example, injectpolicy1 and injectterm1. |
| Enter set injectpolicy1 term injectterm1 |
Specify the OSPF routes. |
| Specify the OSPF match condition: set from ospf |
Specify the routes from a particular OSPF area—for example, Area 1. |
| Specify Area 1 as a match condition: set from area 1 |
Specify that the route is to be accepted if the previous conditions are matched. Set the default option to reject other OSPF routes. |
| Specify the action to accept: set then accept |
Navigate to the Bgp level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit protocols bgp |
Apply the routing policy injectpolicy1 to BGP. |
| Specify the OSPF match condition: set export injectpolicy1 |
Grouping Source and Destination Prefixes in a Forwarding Class (Optional)
Create a forwarding class called forwarding-class1 that includes packets based on both the destination address and the source address in the packet.
To configure and apply the routing policy policy1, which you configured in Table 212 and Table 213, to group source and destination prefixes in a forwarding class:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 217.
- If you are finished configuring the router, commit the configuration.
- To configure additional routing policy features,
go on to one of the following procedures:
- To make a route less preferable to BGP, see Configuring a Policy to Prepend the AS Path (Optional).
- To suppress route information, see Configuring Damping Parameters (Optional).
Table 217: Creating a Policy to Group Source and Destination Prefixes in a Forwarding Class
Task | J-Web Configuration Editor | CLI Configuration Editor |
---|---|---|
Navigate to the term1 level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit policy-options policy-statement policy1 term term1 |
Specify the routes to include in the route filter. For example:
|
| Specify the source routes for the route filter: set from route-filter 10.210.0.0/16 orlonger |
| Specify the destination routes for the route filter: set from route-filter 10.215.0.0/16 orlonger | |
Group the source and destination prefixes into a forwarding class—for example, forwarding-class1. |
| Specify the forwarding class name: set then forwarding class forwarding-class1 |
Navigate to the Forwarding table level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit routing-options forwarding-table |
Apply the policy1 policy to the forwarding table. The routing policy is evaluated when routes are being exported from the routing table into the forwarding table. Only active routes are exported from the routing table. |
| Specify the routing policy to apply: set export policy1 You can refer to the same routing policy one or more times in the same or a different export statement. |
Configuring a Policy to Prepend the AS Path (Optional)
You can prepend or add one or more autonomous system (AS) numbers at the beginning of an AS path. The AS numbers are added after the local AS number has been added to the path. Prepending an AS path makes a shorter AS path look longer and therefore less preferable to the Border Gateway Protocol (BGP).
For example, from AS 1, there are two equal paths (through AS 2 and AS 3) to reach AS 4. You might want packets from certain sources to use the path through AS 2. Therefore, you must make the path through AS 3 look less preferable so that BGP chooses the path through AS 2. In AS 1, you can prepend multiple AS numbers.
To create a routing policy prependpolicy1 that prepends multiple AS numbers:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 218.
- If you are finished configuring the router, commit the configuration.
- To suppress route information, see Configuring Damping Parameters (Optional).
Table 218: Creating a Policy to Prepend AS Numbers
Task | J-Web Configuration Editor | CLI Configuration Editor |
---|---|---|
Navigate to the Policy statement level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit policy-options policy-statement |
Create a prepend policy and term—for example, prependpolicy1 and prependterm1. |
| Enter set prependpolicy1 term prependterm1 |
Specify the routes to prepend AS numbers to. For example:
|
| Specify the first routes to prepend: set from route-filter 172.16.0.0/12 orlonger |
| Specify the next routes to prepend: set from route-filter 192.168.0.0/16 orlonger | |
| Specify the last routes to prepend: set from route-filter 10.0.0.0/8 orlonger | |
Specify the AS numbers to prepend. Separate each AS number with a space—for example, 1 1 1 1. |
| Specify the AS numbers to prepend, and enclose them inside double quotation marks: set then as-path-prepend “1 1 1 1” |
Navigate to the Bgp level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit protocols bgp |
Apply the prependpolicy1 policy as an import policy for all BGP routes. The routing policy is evaluated when routes are being imported to the routing table. |
| Apply the policy: set import prependpolicy1 You can refer to the same routing policy one or more times in the same or a different import statement. |
Configuring Damping Parameters (Optional)
Flap damping reduces the number of update messages by marking routes as ineligible for selection as the active or preferable route. Marking routes in this way leads to some delay, or suppression, in the propagation of route information, but the result is increased network stability. You typically apply flap damping to external BGP (EBGP) routes (routes in different ASs). You can also apply flap damping within a confederation, between confederation member ASs. Because routing consistency within an AS is important, do not apply flap damping to internal BGP (IBGP) routes. (If you do, it is ignored.)
You can specify one or more of the damping parameters described in Table 219. If you do not specify a damping parameter, the default value of the parameter is used.
Table 219: Damping Parameters
Damping Parameter | Description | Default Value | Possible Values |
---|---|---|---|
half-life minutes | Decay half-life—Number of minutes after which an arbitrary value is halved if a route stays stable. | 15 (minutes) | 1 through 4 |
max-suppress minutes | Maximum hold-down time for a route, in minutes. | 60 (minutes) | 1 through 720 |
reuse | Reuse threshold—Arbitrary value below which a suppressed route can be used again. | 750 | 1 through 20000 |
suppress | Cutoff (suppression) threshold—Arbitrary value above which a route can no longer be used or included in advertisements. | 3000 | 1 through 20000 |
To change the default BGP flap damping values, you define actions by creating a named set of damping parameters and including it in a routing policy with the damping action. For the damping routing policy to work, you also must enable BGP route flap damping.
To configure damping with a policy named dampenpolicy1, perform these steps:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 220.
- If you are finished configuring the router, commit the configuration.
Table 220: Creating a Policy to Accept and Apply Damping on Routes
Task | J-Web Configuration Editor | CLI Configuration Editor |
---|---|---|
Navigate to the Policy statement level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit policy-options policy-statement |
Create a damping policy and term—for example, dampenpolicy1 and dampenterm1. |
| Enter set dampenpolicy1 term dampenterm1 |
Specify the routes to dampen and associate each group of routes with a group name. For example:
|
| Specify the first routes to dampen: set from route-filter 172.16.0.0/12 orlonger damping group 1 |
| Specify the next routes to dampen: set from route-filter 192.168.0.0/16 orlonger | |
| Specify the last routes to dampen: set from route-filter 10.0.0.0/8 orlonger | |
Create three damping parameter groups with different damping actions. For example:
| For each damping group:
| Create and configure the damping parameter groups: edit damping group1 half-life 30 max-suppress 60 reuse 750 suppress 3000 edit damping group2 half-life 40 max-suppress 45 reuse 1000 suppress 400 edit damping group3 disable |
Navigate to the Bgp level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit protocols bgp |
Enable damping. |
| Enable damping: set damping |
Navigate to the Neighbor level in the configuration hierarchy, for the BGP neighbor to which you want to apply the damping policy—for example, the neighbor at IP address 172.16.15.14. |
| From the [edit] hierarchy level, enter edit protocols bgp group groupA neighbor 172.16.15.14 |
Apply the policy as an import policy for the BGP neighbor. The routing policy is evaluated when routes are imported to the routing table. |
| Apply the policy: set import dampenpolicy1 You can refer to the same routing policy one or more times in the same or a different import statement. |