prefix-list
match routes as opposed to traffic
two things are matched : prefix and prefix-length
range can also be specified using le,ge
configure:
ip prefix-list 1 10.1.1.0/24
ip prefix-list 1 10.1.1.0/24 le 30
The first command dictates that the first 24 bits of the prefix must match (meaning, the prefix must begin 10.1.1), and the subnet mask must be less than or equal to 30 bits.
The second command dictates again that the first 24 bits of the prefix must match, and the subnet mask must be between 26 to 30 bits (or equal to).
To view information about all prefix lists:
Router# show ip prefix-list detail
Distribute-Lists
Distribute-lists are used to filter routing updates, either inbound or outbound. Routes must first be matched using an access-list or prefix-list, and then applied using a distribute-list under the routing process:
To use an access-list to identify routes:
Router(config)# access-list 10 permit ip 172.16.0.0 0.0.255.255
Router(config)# router rip
Router(config-router)# distribute-list 10 in serial0/0
The above distribute-list will control routes sent inbound on serial0/0. Specifically, the referenced access-list will only permit routes matching 172.16 in the first two octets.
To use a prefix-list to identify routes:
Router(config)# ip prefix-list MYLIST 10.1.0.0/16
Router(config)# router rip
Router(config-router)# distribute-list prefix MYLIST out fastethernet0/0
The above distribute-list will control routes sent outbound on fastethernet0/0.
Specifically, the referenced prefix-list will only match the exact 10.1.0.0/16 route.
Route-Maps
Route-maps are advanced access-lists that serve several functions on IOS devices, including (but not limited to):
• Controlling redistribution between routing protocols.
• Adjusting the attributes of routes (especially for BGP).
• Implementing Policy Based Routing (PBR).
As with access-lists, route-maps are organized as a sequential set of rules or statements, each with a permit or deny condition. However, access-lists can merely permit or deny traffic, while a route-map can additionally modify or perform a specific action on traffic.
Route-maps follow a very simple logic:
• Traffic must be first matched, based on specified criteria.
• A particular attribute or action is set on the matched traffic.
Each statement in a route-map is assigned a sequence number, and contains a series of match and set statements. The route-map is parsed from the lowest sequence number to the highest, and will stop once a match is found.
A single route-map statement can contain multiple match commands:
Router(config)# route-map MYMAP permit 10
Router(config-route-map)# match ip address 1 2 3
The above line would match traffic in access-list 1, or access-list 2, or access-list 3.
Thus, when match criteria is contained within a single line, a logical OR is applied.
However, if match criteria is specified on separate lines:
Router(config-route-map)# match ip address 1
Router(config-route-map)# match ip address 2
Then the traffic must match access-list 1 and access-list 2 (a logical AND). Remember this distinction!
If no match criteria is specified, all traffic is matched!
There is an implicit deny any statement at the bottom of every route-map.
The impact of this deny any statement is dependent on the function of the access-list
Route-Map Criteria
The following are example attributes that can be matched by a route-map:
• match ip address Router(config)# route-map MYMAP permit 10 Router(config-route-map)# match ip address 1
• match interface Router(config-route-map)# match interface serial0/0
• match ip address prefix-list . Router(config-route-map)# match ip address prefix-list MYLIST
• match ip next-hop . Router(config-route-map)# match ip next-hop 192.168.1.2
• match metric Router(config-route-map)# match metric 40
• match route-type Router(config-route-map)# match route-type internal
• match tag
• match community
The following are example attributes that can be set by a route-map:
• set interface
• set ip next-hop
• set metric
• set tag
• set community
• set local-preference
• set weight
• set ip precedence
Router(config)# route-map MYMAP permit 10
Router(config-route-map)# set interface fastethernet0/1
Router(config-route-map)# set ip next-hop 10.1.1.1
Router(config-route-map)# set metric 200
Router(config-route-map)# set tag 44
Router(config-route-map)# set community 321
Router(config-route-map)# set local-preference 250
Router(config-route-map)# set weight 300
Router(config-route-map)# set ip precedence 2