This article describes how to filter routes going from one routing table to several routing-instances.
The goal is to import routes using RIB groups (RIB: routing information base, also known as routing table), and filter what the RIB copies to other routing instances using policy-options and import-policy over the rib-groups stanza.
Example 1 shows how to use RIB groups over interface-routes, and copy them from inet.0 to several routing instances.
Example 2 shows how to filter routes going from inet.0 to PBR1 and PBR2, and copy all inet.0 information to other TEST routing instances.
Example 1: Use RIB groups over interface-routes, and copy them from inet.0 to several routing instances
routing-options { interface-routes { rib-group inet interfaces; } rib-groups { interfaces { import-rib [ inet.0 TEST1.inet.0 TEST2.inet.0 TEST3.inet.0 PBR1.inet.0 PBR2.inet.0 ]; import-policy only-specific-routes; <--------- This will be reference over the next step. } } }
Example 2: Policy structure: Filter routes going from inet.0 to PBR1 and PBR2, and copy all inet.0 information to other TEST routing instances
policy-options { policy-statement only-specific-routes { term PBR1 { from { route-filter 10.0.0.2/31 exact; } to rib PBR1.inet.0; then accept; } term PBR1-reject-others { to rib PBR1.inet.0; then reject; } term PBR2 { from { route-filter 10.0.0.4/31 exact; } to rib PBR2.inet.0; then accept; } term PBR2-reject-others { to rib PBR2.inet.0; then reject; } term else { then accept; } } }
Outputs after the implementation filters the Direct routes
Note that TEST2.inet.0 and TEST3.inet.0 have the same output as TEST1.inet.0.
inet.0: 20 destinations, 20 routes (20 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.0.0/31 *[Direct/0] 00:13:11 > via lt-1/2/0.1 10.0.0.1/32 *[Local/0] 00:13:12 Local via lt-1/2/0.1 10.0.0.2/31 *[Direct/0] 00:13:11 > via lt-1/2/0.2 10.0.0.2/32 *[Local/0] 00:13:12 Local via lt-1/2/0.2 10.0.0.4/31 *[Direct/0] 00:13:11 > via lt-1/2/0.4 10.0.0.4/32 *[Local/0] 00:13:12 Local via lt-1/2/0.4 10.0.0.12/31 *[Direct/0] 00:13:11 > via lt-1/2/0.12 10.0.0.12/32 *[Local/0] 00:13:12 Local via lt-1/2/0.12 192.168.1.1/32 *[IS-IS/15] 00:12:54, metric 10 > to 10.0.0.0 via lt-1/2/0.1 192.168.1.2/32 *[Direct/0] 00:13:12 > via lo0.2 PBR1.inet.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.0.2/31 *[Direct/0] 00:13:11 > via lt-1/2/0.2 PBR2.inet.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.0.4/31 *[Direct/0] 00:13:11 > via lt-1/2/0.4 TEST1.inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.0.0/31 *[Direct/0] 00:13:11 > via lt-1/2/0.1 10.0.0.1/32 *[Local/0] 00:13:11 Local via lt-1/2/0.1 10.0.0.2/31 *[Direct/0] 00:13:11 > via lt-1/2/0.2 10.0.0.2/32 *[Local/0] 00:13:11 Local via lt-1/2/0.2 10.0.0.4/31 *[Direct/0] 00:13:11 > via lt-1/2/0.4 10.0.0.4/32 *[Local/0] 00:13:11 Local via lt-1/2/0.4 10.0.0.6/31 *[Direct/0] 00:13:11 > via lt-1/2/0.6 10.0.0.6/32 *[Local/0] 00:13:11 Local via lt-1/2/0.6 10.0.0.12/31 *[Direct/0] 00:13:11 > via lt-1/2/0.12 10.0.0.12/32 *[Local/0] 00:13:11 Local via lt-1/2/0.12 192.168.1.2/32 *[Direct/0] 00:13:12 > via lo0.2