While using Dynamic routing protocols, at some point, you will want to filter the routes that are sent out from one router to another OR filter routes that are received into your router. One of the easiest ways to do this is to use a distribute-list. Let’s find out how…
First off, let me point out that we are not talking about a “distribution-list”. While the word “distribution” may seem to fit better, that is not what it is called. I too, over the years, have periodically called it a distribution list so I first wanted to set the record straight.
A distribute-list is used to control routing updates either coming TO your router or leaving FROM your router. Distribute-lists work on a variety of different IOS routing protocols. Because of that, learning how to use distribute-lists is very valuable.
As distribute-lists use Cisco IOS Access-Lists, you can very granularly define what routes will or won’t be sent out of the router, or received into the router. Let’s find out how they work…
Let’s say that you want to filter inbound routes to a router. Start off by taking a look at your current routing table. What networks, exactly, do you want to filter out? Here is a sample routing table, for our example:
Router# show ip route
Codes: C – connected, S – static, I – IGRP, R – RIP, M – mobile, B – BGP
Gateway of last resort is not set
Let’s say that we want to filter out route 10.200.100.1/32.
Next, we need to define an ACL that identifies that route, denies it, and allows all other traffic. Here is the ACL that I used:
Router(config)# access-list 50 deny 184.108.40.206
Router(config)# access-list 50 permit any
Now, you want to create a distribute-list that references this ACL, then specify the direction that the distribute-list will be applied.
The distribute-list is defined underneath the routing process for the protocol that it is being used on. In our case, we want to filter OSPF routes so we go into the OSPF routing process configuration.
Router(config)# router ospf 10
Router(config-router)#distribute-list 50 ?
Router(config-router)# distribute-list 50 in
After you put your new ACL and distribute-list in place, verify that they were successful. Notice how, in the show ip route output below, the 10.200.100.1 no longer shows up.
Router# sh ip ro
220.127.116.11/8 is variably subnetted, 2 subnets, 2 masks
Below, you will find graphics of the configurations in place on each side of this distribute-list route filtering:
Our route filtering with the distribute-list command was successful. You can use this same concept and procedure to filter out multiple routes from either going in or out of your router. The distribute-list feature works with a number of different routing protocols. You can even specify in the distribute-list command what interfaces you want the command applied to. So, the next time that you need to not send out a route or have a router not receive a route, don’t forget about the distribute-list command (not distribution-list).
For more information on Distribute-lists, see the Cisco.com article Filtering Routing Updates on Distance Vector IP Routing Protocols.
Do you have questions about distribute-lists or the Cisco IOS? If so, please visit our Cisco Router discussion forums.
To learn more about Cisco networking, consider the Train Signal CCNA Video Training package!