Prevent a Route from being Redistributed from OSPF to BGP
Assume you wanted to prevent a route for 10.0.0.0/24 from being redistributed from OSPF to BGP.
One way to accomplish this would be to define an extended ACL matching this prefix and reference
it from the BGP redistribution route map:
router ospf 1
router-id 2.2.2.2
log-adjacency-changes
!
router bgp 65100
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
redistribute ospf 1 route-map OSPF->BGP
neighbor 172.16.23.3 remote-as 65100
no auto-summary
!
ip access-list extended OSPF_Redist
deny ip host 10.0.0.0 host 255.255.255.0
permit ip any any
!
route-map OSPF->BGP permit 10
match ip address OSPF_Redist
The above configuration prevents the exact prefix 10.0.0.0/24 from being advertised by denying the
10.0.0.0 network (“source” address) with a mask of 255.255.255.0 (“destination” address).
All other prefixes are allowed by the permit ip any any statement.
This can be accomplished more intuitively by employing a prefix list:
router ospf 1
router-id 2.2.2.2
log-adjacency-changes
!
router bgp 65100
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
redistribute ospf 1 route-map OSPF->BGP
neighbor 172.16.23.3 remote-as 65100
no auto-summary
!
ip prefix-list OSPF_Redist seq 5 deny 10.0.0.0/24
ip prefix-list OSPF_Redist seq 10 permit 0.0.0.0/0 le 32
!
route-map OSPF->BGP permit 10
match ip address prefix-list OSPF_Redis