Wednesday, November 13, 2013

Bgp route filtering with Route-map


Bgp route filtering with Route-map

In this example we are only announcing default route and filtering specific routes.

Here is the configuration:

router bgp 65500
 no synchronization
 bgp log-neighbor-changes
 network 0.0.0.0
 network 192.168.1.0 mask 255.255.255.0
 neighbor 10.10.10.2 remote-as 65500
 neighbor 10.10.10.2 route-map spoke-out out

ip prefix-list defaultroute seq 5 permit 0.0.0.0/0

route-map spoke-out permit 10
 match ip address prefix-list defaultroute
 set metric 0
 set ip next-hop 10.10.10.1

We see that, we have 192.168.1.0/24 network in our bgp table.

R1#show ip bgp
BGP table version is 4, local router ID is 10.10.10.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network          Next Hop            Metric LocPrf Weight Path
*> 0.0.0.0          10.10.10.254               0         32768 i
*> 192.168.1.0      0.0.0.0                    0         32768 i

But we are not advertising it to the remote neighbor:

R1#show ip bgp neighbors 10.10.10.2 advertised-routes 
BGP table version is 4, local router ID is 10.10.10.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network          Next Hop            Metric LocPrf Weight Path
*> 0.0.0.0          10.10.10.254               0         32768 i
Total number of prefixes 1

Lets also check the remote router:

R4#show ip bgp neighbors 10.10.10.1 routes
BGP table version is 3, local router ID is 10.10.10.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network          Next Hop            Metric LocPrf Weight Path
*>i0.0.0.0          10.10.10.1             0    100      0 i
Total number of prefixes 1