To filter routes based on the prefix, you can do any of the following:
The router compares each route’s prefix against the conditions in the list or tree one by one. If the first match is for a permit condition, the route is accepted or passed. If the first match is for a deny condition, the route is rejected or blocked. The order of conditions is critical because testing stops with the first match. If no conditions match, the router rejects or blocks the address; that is, the last action of any list is an implicit deny condition for all routes. The implicit rule is displayed by show access-list and show configuration commands.
You cannot selectively place conditions in or remove conditions from an access list, prefix, list, or prefix tree. You can insert a new condition only at the end of a list or tree.
Consider the network structure in Figure 21.
Figure 21: Filtering with Access Lists

The following commands configure router Boston to apply access list reject1 to routes inbound from router SanJose. Access list reject1 rejects routes matching 172.24.160.0/19.
- host3(config)#router bgp 17
- host3(config-router)#neighbor 10.5.5.4 remote-as
873
- host3(config-router)#neighbor 10.5.5.4 distribute-list
reject1 in
- host3(config-router)#exit
- host3(config)#access-list reject1 permit 172.24.48.0
0.0.255
- host3(config)#access-list reject1 deny 172.24.160.0
0.0.255
- host3(config)#access-list reject1 permit 172.24.24.0
0.0.255
Consider the network shown in Figure 22. Router NY originates network 10.16.22.0/23 and advertises it to router LA. Suppose you do not want router LA to advertise that network to router Boston. You can apply an access list to updates from router LA to router Boston that prevents router LA from propagating updates for network 10.16.22.0/23.
Figure 22: Filtering Routes with an Access List

The following commands configure router LA:
- host2(config)#router bgp 400
- host2(config-router)#network 172.24.160.0
mask 255.255.224.0
- host2(config-router)#neighbor 10.72.4.2 remote-as
300
- host2(config-router)#neighbor 10.5.5.1 remote-as
100
- host2(config-router)#neighbor 10.5.5.1 distribute-list
1 out
- host2(config-router)#exit
- host2(config)#access-list 1 deny 10.16.22.0
0.254.255.255
access-list
clear access-list
- host1#clear access-list reject1
neighbor distribute-list
To apply the new policy to routes that are already present in the BGP routing table, you must use the clear ip bgp command to perform a soft clear or hard clear of the current BGP session.
Behavior is different for outbound policies configured for peer groups for which you have enabled Adj-RIBs-Out. If you change the outbound policy for such a peer group and want to fill the Adj-RIBs-Out table for that peer group with the results of the new policy, you must use the clear ip bgp peer-group command to perform a hard clear or outbound soft clear of the peer group. You cannot merely perform a hard clear or outbound soft clear for individual peer group members because that causes BGP to resend only the contents of the Adj-RIBs-Out table.
neighbor prefix-list
- host1(config-router)#neighbor 192.168.1.158
prefix-list seoul19 in
To apply the new policy to routes that are already present in the BGP routing table, you must use the clear ip bgp command to perform a soft clear or hard clear of the current BGP session.
Behavior is different for outbound policies configured for peer groups for which you have enabled Adj-RIBs-Out. If you change the outbound policy for such a peer group and want to fill the Adj-RIBs-Out table for that peer group with the results of the new policy, you must use the clear ip bgp peer-group command to perform a hard clear or outbound soft clear of the peer group. You cannot merely perform a hard clear or outbound soft clear for individual peer group members because that causes BGP to resend only the contents of the Adj-RIBs-Out table.
neighbor prefix-tree
- host1(config-router)#neighbor 192.168.1.158
prefix-tree newyork out
To apply the new policy to routes that are already present in the BGP routing table, you must use the clear ip bgp command to perform a soft clear or hard clear of the current BGP session.
Behavior is different for outbound policies configured for peer groups for which you have enabled Adj-RIBs-Out. If you change the outbound policy for such a peer group and want to fill the Adj-RIBs-Out table for that peer group with the results of the new policy, you must use the clear ip bgp peer-group command to perform a hard clear or outbound soft clear of the peer group. You cannot merely perform a hard clear or outbound soft clear for individual peer group members because that causes BGP to resend only the contents of the Adj-RIBs-Out table.