How to configure BGP AS Path Prepending

The fourth BGP attribute is called AS Path:

  • BGP prefers the shortest AS path to get to a destination. Less is more!
  • We can manipulate this by using AS path prepending.

Let me show you an example:

bgp as path prepend

In my example AS 1 wants to make sure traffic enters the autonomous system through R2. We can add our own autonomous system number multiple times so the as-path becomes longer. Since BGP prefers a shorter AS path we can influence our routing. This is called AS path prepending. Let’s see what this looks like on Cisco routers, this is the topology that I will use:

bgp as path prepend lab

Above we have 3 routers. R1 and R3 are both in AS 1 advertising the same network (1.1.1.0/24) to R2. We can use AS Path prepending to make R2 prefer a certain path.

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You've Ever Spent on Your Cisco Career!
  • Full Access to our 651 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

568 Sign Ups in the last 30 days

satisfaction-guaranteed
100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.
No Questions Asked!

Forum Replies

  1. Hi Joshua,

    It’s common to prepend your own AS number multiple times, don’t prepend using random AS numbers since to the outside world it appears as someone could reach those AS’es through your AS.

    Rene

  2. http://i66.tinypic.com/33w3x29.jpg

    http://i66.tinypic.com/33w3x29.jpg

    Hello Rene,

    This is the setup I am using to configure BGP multihoming.

    AS 100 has two exit points to reach R5 which is hosting a subnet: 8.8.8.8

    My Question is what difference does it make if I advertise directly connected subnets in BGP.

    For example:

    R1(config-router)#network 192.168.1.0 mask 255.255.255.252

    R2(config-router)#network 192.168.2.0 mask 255.255.255.252

    One thing which I have noticed is if I do not advertise 192.168.1.0 subnet on R1, R2 did not know about it at all so advertising

    ... Continue reading in our forum

  3. Thanks a lot for the explanation Rene.

    I would like you to clarify one more thing.

    For the LAN segment: 192.168.100.0 : R1 is the active router to reach 8.8.8.8 and R2 is the standby as the priority for R1 is 150.

    I am not using interface for tracking as i want the failover to happen on the basis of reachability of 8.8.8.8.

    I have set a tracking object with IP SLA1 for type: echo to ping 8.8.8.8 and mapped it with Standby 1 on R1 to decrement priority by 90 if the ping fails.

    To verify this, I did a “Shut” on the interface of R1 connecting to R3, what happened

    ... Continue reading in our forum

  4. Hello Chris

    BGP will choose the router ID based first on if the router-id command is present. It is not in this case. Secondly, it will choose the highest IPv4 IP address of a loopback interface. You are correct, that both R1 and R3 have the same loopback address (seen in the configs), and thus would be advertising the same router-id. So the next step would be to determine the lowest neighbour IP address, which is indeed 192.168.12.1. So you are correct, it does prefer 192.168.12.1 but not because of the router ID but because of the lowest neighbour IP add

    ... Continue reading in our forum

  5. Great, thanks. As often the case after the question is explained it looks kind of obvious. :slight_smile:

57 more replies! Ask a question or join the discussion by visiting our Community Forum