Tuesday, February 26, 2008

Q: How to I implement AS_PATH prepending?

A:

Here's the scenario: you have multiple BGP connections to the Internet. For one of the prefixes you advertise, 33.44.55.0/24, you don't want traffic to come via the link with neighbor 1.2.3.4 unless all of the other BGP links are down. So you want to use ASPATH preprding on the advertisements you send to 1.2.3.4.

Let's say your own AS number is 65111. We'll prepend it twice to the advertisements of prefix 33.44.55.0/24 sent to neighbor 1.2.3.4:

! first define an ACL to use later to select which adverts to affect; 
! I numbered it 5
access-list 5 permit 33.44.55.0 0.0.0.255 !
! then make a route-map to do the prepending; I named it PREPEND1 
route-map PREPEND1 permit 10  
 match ip address 5  
 set as-path prepend 65111 65111 
!
route-map PREPEND1 permit 20
!
! so far, no effect. Next change makes it take effect
!
! finally, add the following command to the 
! router bgp 65111 section:
!
router bgp 65111
 neighbor 1.2.3.4 route-map PREPEND1 out

After doing this I did clear ip bgp 1.2.3.4. I think I could have used clear ip bgp 1.2.3.4 soft out

Q: How do I know what BGP advertisements I am sending to a neighbor?

A:

One way: sho ip bgp neigh 1.2.3.4 adv

Also, this might work: debug ip bgp 1.2.3.4 updates