Route Filtering Using Prefix Lists
The general syntax for configuring a prefix list is as follows:
Router(config)#ip prefix-list list-name [seq seq-value] deny | permit network/len [ge ge-value] [le le-value]
The table that follows describes the parameters for this command.
Parameter |
Description |
list-name |
The name of the prefix list |
seq |
(Optional) Applies a sequence number to the entry being created or deleted |
seq-value |
(Optional) Specifies the sequence number |
deny |
Denies access to matching conditions |
permit |
Permits access for matching conditions |
network/len |
(Mandatory) The network number and length (in bits) of the netmask |
ge |
(Optional) Applies ge-value to the range specified |
ge-value |
(Optional) Specifies the lesser value of a range (the “from” portion of the range description) |
le |
(Optional) Applies le-value to the range specified |
le-value |
(Optional) Specifies the greater value of a range (the “to” portion of the range description) |
A router tests for prefix list matches from the lowest sequence number to the highest.
By numbering your prefix-list statements, you can add new entries at any point in the list.
The following examples show how you can use the prefix-list command to filter networks using some of the more commonly used options.
Router(config)#ip prefix-list ROSE permit 192.0.0.0/8 le 24 |
Creates a prefix list that will accept a netmask of up to 24 bits (le meaning less than or equal to) in routes with the prefix 192.0.0.0/8. Because no sequence number is identified, the default number of 5 is applied. |
Router(config)#ip prefix-list ROSE deny 192.0.0.0/8 ge 25 |
Creates a prefix list that will deny routes with a netmask of 25 bits or greater (ge meaning greater than or equal to) in routes with the prefix 192.0.0.0/8. Because no sequence number is identified, the number 10 is applied—an increment of 5 over the previous statement. |
NOTE: This configuration will per-mit routes such as 192.2.0.0/16 or 192.2.20.0/24, but will deny a more spe-cific subnet such as 192.168.10.128/25. |
|
Router(config)#ip prefix-list TOWER permit 10.0.0.0/8 ge 16 le 24 |
Creates a prefix list that permits all prefixes in the 10.0.0.0/8 address space that have a netmask of between 16 and 24 bits (greater than or equal to 16 bits, and less than or equal to 24 bits). |
Router(config)#ip prefix-list TEST seq 5 permit 0.0.0.0/0 |
Creates a prefix list and assigns a sequence number of 5 to a statement which permits only the default route 0.0.0.0/0. |
Router(config)#ip prefix-list TEST seq 10 permit 0.0.0.0/0 ge 30 le 30 |
Creates a prefix list and assigns a sequence number of 10 to a statement that permits any prefix with a netmask of exactly 30 bits. |
Router(config)#ip prefix-list TEST seq 15 permit 0.0.0.0/0 le 32 |
Creates a prefix list and assigns a sequence number of 15 to a statement that permits any address or subnet (permit any). |
Router(config)#no ip prefix-list TEST seq 10 |
Removes sequence number 10 from the prefix list. |
Configuration Example: Using a Distribute List That References a Prefix List to Control Redistribution
Figure 4-7 shows the network topology for the configuration that follows, which demonstrates how to control redistribution with a prefix list using the commands covered in this chapter. Assume that all basic configurations and EIGRP and OSPF routing have been configured correctly.
Figure 4-7 Network Topology for Distribute List Configuration with Prefix Lists
The objective is to prevent networks 172.16.3.0/24 and 172.16.4.0/24 from being redistributed into the OSPF domain.
HULL(config)#ip prefix-list FILTER seq 5 permit 172.16.1.0/24 |
Creates a prefix list called FILTER with a first sequence number of 5 that explicitly permits the 172.16.1.0/24 network. |
HULL (config)#ip prefix-list FILTER seq 10 permit 172.16.2.0/24 |
Adds a second line to the FILTER prefix list that explicitly permits the 172.16.2.0/24 network. |
HULL(config)#router ospf 1 |
Enters OSPF process ID 1 routing process. |
HULL(config-router)#redistribute eigrp 10 subnets |
Redistributes all EIGRP networks into OSPF. |
HULL(config-router)#distribute-list prefix FILTER out eigrp 10 |
Creates an outbound distribute list to filter routes being redistributed from EIGRP into OSPF that references the prefix list. |
NOTE: The implicit deny any statement at the end of the prefix list prevents routing updates about any other network from being advertised. As a result, networks 172.16.3.0/24 and 172.16.4.0/24 will not be redistributed into OSPF. |
Verifying Prefix Lists
show ip prefix-list [detail | summary] |
Displays information on all prefix lists. Specifying the detail keyword includes the description and the hit count (the number of times the entry matches a route) in the display. |
clear ip prefix-list prefix-list-name [network/length] |
Resets the hit count shown on prefix list entries. |