Here is three way to filter routes / prefixes in BGP and examples
- Distribute-list filtering
- Route-map filtering
- Filter-list(AS filtering) filtering
1. Distribute-list
neighbor 1.1.1.1 distribute-list 1 out
!
access-list 1 deny 10.30.0.0 0.0.0.255 (IP route that is not be announced)
access-list 1 deny 10.40.0.0 0.0.0.255 (IP route that is not be announced)
access-list 1 permit any
!
access-list 1 deny 10.30.0.0 0.0.0.255 (IP route that is not be announced)
access-list 1 deny 10.40.0.0 0.0.0.255 (IP route that is not be announced)
access-list 1 permit any
2. Route-map
neighbor 1.1.1.1 route-map ipBalance out
!
access-list 1 deny 10.30.0.0 0.0.0.255
access-list 1 deny 10.40.0.0 0.0.0.255
access-list 1 permit any
!
route-map ipBalance permit 10
match ip address 1 (Applying access-list 1)
!
access-list 1 deny 10.30.0.0 0.0.0.255
access-list 1 deny 10.40.0.0 0.0.0.255
access-list 1 permit any
!
route-map ipBalance permit 10
match ip address 1 (Applying access-list 1)
3. Filter-list(AS filtering)
neighbor 1.1.1.1 filter-list 1 out (Applying access-list 1 on filter-list)
!
ip as-path access-list 1 deny 100 (Deny AS 100)
ip as-path access-list 1 permit .* (Permit all AS)
or ————————–
neighbor 1.1.1.1 route-map ipBalance out
!
ip as-path access-list 1 deny 100
ip as-path access-list 1 permit .*
!
route-map ipBalance permit 10
match as-path 1
!
ip as-path access-list 1 deny 100 (Deny AS 100)
ip as-path access-list 1 permit .* (Permit all AS)
or ————————–
neighbor 1.1.1.1 route-map ipBalance out
!
ip as-path access-list 1 deny 100
ip as-path access-list 1 permit .*
!
route-map ipBalance permit 10
match as-path 1