Wednesday, June 15, 2011

Prefix List in BGP

Ok, so yesterday we took a quick look at prefix lists. Lets try a real world example in BGP. Say your ISP is pushing you hundreds of routes but all you want to receive is a default route.

#Router bgp 65001
#neighbor 1.1.1.1 remote-as 65002
#neighbor 1.1.1.1 route-map RouteFilter in

#route-map RouteFilter permit 10
#match ip address prefix-list defaultOnly

#ip prefix-list defaultOnly seq 10 permit 0.0.0.0/0

So what have I done here.
First we neighbored with AS 65002 and applied a routefilter in (filter routes inbound from our neighbor)
Then we create a route filter that requires matching the prefix list defaultOnly.

Last we create a prefix-list that requires the route to match 0.0.0.0/0 exactly (eg. only default routes)

If we had two+ ISPs, we could add

match as-path ##
set weight 120

then make another filter entree like we did above and set the weight to 110 for any other ISP's default routes. Then we have successfully filtered out all incoming routes except default routes, and weighted our prefered path by setting that AS to a higher weight.

No comments: