Filtering Routes by IP Address with Prefix-List

  • by

If we want to filter unwanted prefixes from our routing table, we can filter those prefixes with a list and in this scenario, we can create a prefix-list. Here I am showing how we can create a prefix-list

Create a list of all the IP address prefixes which we dont want to show at our routing table, Here I have created a prefix-list, which name is “PREFIX-LIST”, we can give any name here whatever we want. Here, prefix list contain two prefixes, we can add more prefixes here as well.

# set policy-options prefix-list PREFIX-LIST-1 10.0.0.0/24
# set policy-options prefix-list 
PREFIX-LIST-1 10.10.0.0/16

# show policy-options
prefix-list PREFIX-LIST-1 {
      10.0.0.0/24;
      10.10.0.0/16;
}

Then create a policy that references the list of prefixes, Here the policy name is Add-to-Reject and I have made this policy as reject, in this configuration the prefixes will be reject which are contained at prefix-list:

# set policy options policy-statement Add-to-Reject term 1 from prefix-list PREFIX-LIST-1
# set policy options policy-statement Add-to-Reject term 1 then reject

Finally, apply the policy to a routing protocol, here I use BGP:
# set protocols bgp group external-group import Add-to-Reject

 

On the other hand, if we want to accept particular prefixes, then we can use just follow bellow configuration. Here the policy name is Add-to-Accept and I have made this policy for accept those prefixes only, which we have created on prefixe-list

# set policy options policy-statement Add-to-Accept term 1 from prefix-list PREFIX-LIST-1
# set policy options policy-statement Add-to-Accept term 1 then accept

Finally, apply the policy to a routing protocol, here I use BGP:
# set protocols bgp group external-group import Add-to-Accept

Leave a Reply