AÂ prefix list is a set of IP Address prefixes that are grouped and can be denied or permitted to be advertised into the routing protocol according to our needs.
Suppose there is a network topology with 5 routers and EIGRP is running on it. We need to filter some routes of R1 from R2 and R4 but want to allow them on R3 and R5.
How can we achieve this since when we add a network in the EIGRP protocol, it will be advertised to all the routers configured with EIGRP?
Routes can be filtered with the help of a Prefix list.
Don’t worry we will understand how to use and configure a prefix list in this lesson.
What is the function of a Prefix-list on Cisco Router?
Prefix lists and access lists often serve the same purpose, but prefix lists can provide more precise route filtering, it is easy to configure compared to that of access lists. The prefix list comes with le (Less than) and ge (greater than) operators which makes it handy to filter routes.
Let us now learn how can we configure the prefix list using the basic topology given below.
We have 2 directly connected routers R1 and R2.
Let us first configure EIGRP into it.
R1#configure terminal Â
R1(config)#router eigrp 1Â
R1(config-router)#network 172.16.0.0Â
R1(config-router)#network 172.16.1.0Â
R1(config-router)#network 172.16.2.0Â
R1(config-router)#network 172.16.3.0Â
R1(config-router)#network 192.168.1.0Â
R1(config-router)#network 192.168.12.0Â
R1(config-router)#no auto-summary Â
R2(config-router)#router eigrp 1Â
R2(config-router)# network 1.0.0.0Â
R2(config-router)# network 192.168.12.0Â
R2(config-router)#no auto-summary Â
Â
Â
%DUAL-5-NBRCHANGE: IP-EIGRP 1: Neighbor 192.168.12.1 (GigabitEthernet0/0/0) is up: new adjacencyÂ
Since EIGRP Adjacency is created, let us see how route tables looks like for R1 and R2.Â
R1#show ip route  Â
Codes: C – connected, S – static, R – RIP, M – mobile, B – BGPÂ
      D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area Â
      N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2Â
      E1 – OSPF external type 1, E2 – OSPF external type 2Â
      i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2Â
      ia – IS-IS inter area, * – candidate default, U – per-user static routeÂ
      o – ODR, P – periodic downloaded static routeÂ
Â
Gateway of last resort is not setÂ
Â
CÂ Â Â 192.168.12.0/24 is directly connected, FastEthernet0/0Â
DÂ Â Â 1.0.0.0/8 [90/409600] via 192.168.12.2, 00:35:55, FastEthernet0/0Â
    172.16.0.0/16 is variably subnetted, 4 subnets, 4 masksÂ
CÂ Â Â Â Â Â 172.16.0.0/24 is directly connected, Loopback1Â
CÂ Â Â Â Â Â 172.16.1.0/25 is directly connected, Loopback2Â
CÂ Â Â Â Â Â 172.16.2.0/26 is directly connected, Loopback3Â
CÂ Â Â Â Â Â 172.16.3.0/27 is directly connected, Loopback4Â
CÂ Â Â 192.168.1.0/24 is directly connected, Loopback5Â
Â
R1#show ip route eigrp Â
Â
DÂ Â Â 1.0.0.0/8 [90/409600] via 192.168.12.2, 01:07:30, FastEthernet0/0
R2# show ip route Â
Codes: C – connected, S – static, R – RIP, M – mobile, B – BGPÂ
      D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area Â
      N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2Â
      E1 – OSPF external type 1, E2 – OSPF external type 2Â
      i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2Â
      ia – IS-IS inter area, * – candidate default, U – per-user static routeÂ
      o – ODR, P – periodic downloaded static routeÂ
Â
Gateway of last resort is not setÂ
Â
CÂ Â Â 192.168.12.0/24 is directly connected, FastEthernet0/0Â
    1.0.0.0/8 is variably subnetted, 2 subnets, 2 masksÂ
CÂ Â Â Â Â Â 1.1.1.0/24 is directly connected, Loopback1Â
DÂ Â Â Â Â Â 1.0.0.0/8 is a summary, 00:42:32, Null0Â
    172.16.0.0/16 is variably subnetted, 4 subnets, 4 masksÂ
DÂ Â Â Â Â Â 172.16.0.0/24 [90/409600] via 192.168.12.1, 00:05:23, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.1.0/25 [90/409600] via 192.168.12.1, 00:13:12, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.2.0/26 [90/409600] via 192.168.12.1, 00:05:23, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.3.0/27 [90/409600] via 192.168.12.1, 00:05:24, FastEthernet0/0Â
R2#show ip route eigrp Â
    1.0.0.0/8 is variably subnetted, 2 subnets, 2 masksÂ
DÂ Â Â Â Â Â 1.0.0.0/8 is a summary, 00:42:41, Null0Â
    172.16.0.0/16 is variably subnetted, 4 subnets, 4 masksÂ
DÂ Â Â Â Â Â 172.16.0.0/24 [90/409600] via 192.168.12.1, 00:05:31, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.1.0/25 [90/409600] via 192.168.12.1, 00:13:21, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.2.0/26 [90/409600] via 192.168.12.1, 00:05:31, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.3.0/27 [90/409600] via 192.168.12.1, 00:05:31, FastEthernet0/0
We can see all the Eigrp networks are in the routing table of R2.Â
Now let us look at how powerful a prefix list is.Â
Let us filter 172.16.1.0/25 from R2.Â
R2(config)#ip prefix-list NWKINGS seq 10 deny 172.16.1.0/25Â
R2(config)#ip prefix-list NWKINGS seq 20 permit 0.0.0.0/0 le 32Â
By using the ip prefix-list command under config mode, we can create a prefix list.Â
NWKINGS is the name of the prefix list. Â
10 is the seq number which can be any numerical value.Â
After creating the prefix list, we need to apply it under a routing protocol.Â
Since our network is configured with EIGRP, we will apply it under EIGRP.Â
R2(config)#router eigrp 1Â
R2(config-router)#distribute-list prefix NWKINGS in
We used the IN operator here since the routes are coming in R2 from R1.Â
R2#show ip route eigrp Â
    1.0.0.0/8 is variably subnetted, 2 subnets, 2 masksÂ
DÂ Â Â Â Â Â 1.0.0.0/8 is a summary, 00:14:19, Null0Â
    172.16.0.0/16 is variably subnetted, 3 subnets, 3 masksÂ
DÂ Â Â Â Â Â 172.16.0.0/24 [90/409600] via 192.168.12.1, 00:00:09, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.2.0/26 [90/409600] via 192.168.12.1, 00:00:09, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.3.0/27 [90/409600] via 192.168.12.1, 00:00:09, FastEthernet0/0Â
We are not able to see the 172.16.1.0/25 network in the Eigrp table of R2.Â
Prefix list OUTÂ
To use a prefix list with the OUT operator we need to configure it on R1 since R1 is the router that is exporting the routes to R2.Â
R1(config)#ip prefix-list NWKINGSS seq 10 deny 172.16.1.1/25Â
R1(config)#ip prefix-list NWKINGSS seq 20 permit 0.0.0.0/0 le 32Â
R1(config)#router eigrp 1Â
R1(config-router)#distribute-list prefix NWKINGSS outÂ
Let us check if our prefix list is working or not.Â
R2#show ip route eigrp Â
    1.0.0.0/8 is variably subnetted, 2 subnets, 2 masksÂ
DÂ Â Â Â Â Â 1.0.0.0/8 is a summary, 00:21:45, Null0Â
    172.16.0.0/16 is variably subnetted, 3 subnets, 3 masksÂ
DÂ Â Â Â Â Â 172.16.0.0/24 [90/409600] via 192.168.12.1, 00:07:35, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.2.0/26 [90/409600] via 192.168.12.1, 00:07:35, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.3.0/27 [90/409600] via 192.168.12.1, 00:07:35, FastEthernet0/0Â
Crazy, Route 172.16.1.1/25 is not available in the Eigrp table of R2Â
Le operator: –Â
Let us first remove the previous prefix list: –Â
(config)#no ip prefix-list NWKINGSÂ
(config)#router eigrp 1Â
(config-router)#no distribute-list prefix NWKINGS inÂ
Â
R2#show ip route eigrp Â
    1.0.0.0/8 is variably subnetted, 2 subnets, 2 masksÂ
DÂ Â Â Â Â Â 1.0.0.0/8 is a summary, 00:29:30, Null0Â
    172.16.0.0/16 is variably subnetted, 4 subnets, 4 masksÂ
DÂ Â Â Â Â Â 172.16.0.0/24 [90/409600] via 192.168.12.1, 00:15:20, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.1.0/25 [90/409600] via 192.168.12.1, 00:00:10, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.2.0/26 [90/409600] via 192.168.12.1, 00:15:20, FastEthernet0/0Â
Â
DÂ Â Â Â Â Â 172.16.3.0/27 [90/409600] via 192.168.12.1, 00:15:20, FastEthernet0/0Â
Now all the routes are visible at R2.Â
Let us now use le operator.Â
R2(config)#ip prefix-list NK seq 10 permit 172.16.1.0/25 le 26Â
R2(config)#router eigrp 1Â
R2(config-router)#distribute-list prefix NK inÂ
Â
R2#show ip route eigrp Â
    1.0.0.0/8 is variably subnetted, 2 subnets, 2 masksÂ
DÂ Â Â Â Â Â 1.0.0.0/8 is a summary, 00:29:30, Null0Â
    172.16.0.0/16 is variably subnetted, 4 subnets, 4 masksÂ
DÂ Â Â Â Â Â 172.16.0.0/24 [90/409600] via 192.168.12.1, 00:15:20, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.1.0/25 [90/409600] via 192.168.12.1, 00:00:10, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.2.0/26 [90/409600] via 192.168.12.1, 00:15:20, FastEthernet0/0Â
DÂ Â Â Â Â Â 172.16.3.0/27 [90/409600] via 192.168.12.1, 00:15:20, FastEthernet0/0Â
Â
R2#show ip route eigrp                                              Â
    1.0.0.0/8 is variably subnetted, 2 subnets, 2 masksÂ
DÂ Â Â Â Â Â 1.0.0.0/8 is a summary, 00:31:11, Null0Â
    172.16.0.0/25 is subnetted, 1 subnetsÂ
DÂ Â Â Â Â Â 172.16.1.0 [90/409600] via 192.168.12.1, 00:01:51, FastEthernet0/0Â
See, routes are now filtered accordingly.Â
ge (Greater than) operator can also be used in a similar way.Â