14.2.4 OSPF learned route filtering [SL-L3A]
- <Structure of this section>
(1) Learning routes for a specific destination network
Configure OSPF to only learn routes to addresses in the 192.168.0.0/16 range.
- Points to note
-
To apply learned route filtering, configure the distribute-list in command. To filter routes by their destination networks, use an ip prefix-list filter.
First, configure an ip prefix-list filter to permit routes to the 192.168.0.0/16 address range. By referencing this filter from the distribute-list in command, you can configure OSPF to filter learned routes based on the destination networks.
Command examples
-
(config)# ip prefix-list ONLY192168 seq 10 permit 192.168.0.0/16
Configures prefix-list to permit only routes in the 192.168.0.0/16 range. Because ONLY192168 has no other conditions, the filter denies routes with any other destination address or mask length.
-
(config)# router ospf 1
(config-router)# distribute-list prefix ONLY192168 in
Configures OSPF to apply the conditions ONLY192168 to the OSPF external AS routes and NSSA routes it learns.
(2) Learned route filtering by tag value
Configure the switch not to learn routes with a tag value of 15. Other routes are learned.
- Points to note
-
The example below shows how to use route-map to filter a route by an attribute other than its destination network, or to modify some of its attributes. You can reference this route-map from the distribute-list in command.
First, configure route-map to deny routes with a tag value of 15. Next, configure OSPF learned route filtering by tag value by referencing route-map from the distribute-list in command.
Command examples
-
(config)# route-map TAG15DENY deny 10
(config-route-map)# match tag 15
(config-route-map)# exit
Configures route-map to deny routes with a tag value of 15.
-
(config)# route-map TAG15DENY permit 20
(config-route-map)# exit
Configures route-map to permit routes that do not match the conditions associated with sequence number 10.
-
(config)# router ospf 1
(config-router)# distribute-list route-map TAG15DENY in
Applies the filter to OSPF learned route filtering. This configures OSPF not to learn external AS routes and NSSA routes that have a tag value of 15.
(3) Changing Distance Values by Destination Network
Configure OSPF to assign a distance value of 150 to external AS routes and NSSA routes whose destination network is in the 192.168.0.0/16 range, thereby giving priority to RIP routes.
- Points to note
-
The example below shows how to use route-map to filter a route by an attribute other than its destination network, or to modify some of its attributes. You can reference this route-map from the distribute-list in command.
First, configure a prefix-list filter to permit routes in the 192.168.0.0/16 range. Next, configure route-map to assign a distance value of 150 to routes permitted by this prefix-list filter.
Finally, by referencing route-map from the distribute-list in command, configure the switch to change distances based on destination networks when performing OSPF learned route filtering.
Command examples
-
(config)# ip prefix-list PERMIT192168LONGER seq 10 permit 192.168.0.0/16 ge 16 le 32
Configures prefix-list to permit routes in the 192.168.0.0/16 range.
-
(config)# route-map Distance150 permit 10
(config-route-map)# match ip address prefix-list PERMIT192168LONGER
(config-route-map)# set distance 150
(config-route-map)# exit
Configures route-map to assign a distance value of 150 to routes in the 192.168.0.0/16 range, and permits those routes.
-
(config)# route-map Distance150 permit 20
(config-route-map)# exit
Configures the route-map to permit routes that do not match the conditions associated with sequence number 10, without changing any of their attributes.
-
(config)# router ospf 1
(config-router)# distribute-list route-map Distance150 in
Applies the above filter to OSPF learned route filtering. This configures OSPF to assign a distance value of 150 to external AS routes and NSSA routes in the 192.168.0.0/16 range.