Distribute-List Command on CISCO Router/Switch

Command

Distribute-List

Use

Allows you to filter routes from the routing table. For CCNA purposes, this is usually done through access lists.

Syntax

Router(config-router)#distribute-list <list> <in/out>
OR
Router(config-router)#distribute-list <list> <in/out> <interface>

Options

<list> Access list
<in/out> Whether the router is receiving or sending the route

Example

Distribute-List Command on CISCO Router/Switch 1

In this example, we will apply a distribute-list to R2. First, we will see what OSPP routes we have on R2.

R2(config)#do show ip route ospf
1.0.0.0/32 is subnetted, 3 subnets
O 1.1.1.1 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0
O 1.3.3.3 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0
O 1.2.2.2 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0
192.168.13.0/30 is subnetted, 1 subnets
O 192.168.13.0 [110/65] via 10.2.2.3, 00:00:22, FastEthernet1/0
33.0.0.0/32 is subnetted, 1 subnets
O 33.33.33.33 [110/2] via 10.2.2.3, 00:00:22, FastEthernet1/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/2] via 10.2.2.3, 00:00:22, FastEthernet1/0
111.0.0.0/32 is subnetted, 1 subnets
O 111.111.111.111 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0
10.0.0.0/24 is subnetted, 3 subnets
O 10.4.4.0 [110/65] via 10.2.2.3, 00:00:22, FastEthernet1/0
11.0.0.0/32 is subnetted, 1 subnets
O 11.11.11.11 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0
133.133.0.0/32 is subnetted, 1 subnets
O 133.133.133.133 [110/2] via 10.2.2.3, 00:00:22, FastEthernet1/0

Next, we will set an access-list to only allow 1.2.2.2 and use it in a distribute-list.

R2(config)#access-list 25 permit 1.2.2.2
R2(config)#router ospf 1
R2(config-router)#distribute-list 25 in

Finally, we see only 1.2.2.2 is in the routing table.

R2(config-router)#do show ip route ospf
1.0.0.0/32 is subnetted, 1 subnets
O 1.2.2.2 [110/2] via 10.1.1.1, 00:00:09, FastEthernet0/0
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x