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.