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 ( 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 739 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

542 Sign Ups in the last 30 days

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.



    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:

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

    For example:

    R1(config-router)#network mask

    R2(config-router)#network mask

    One thing which I have noticed is if I do not advertise 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: : R1 is the active router to reach 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

    I have set a tracking object with IP SLA1 for type: echo to ping 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 So you are correct, it does prefer but not because of the router ID but because of the lowest neighbour IP add

    ... Continue reading in our forum

  5. That’s very helpful. Thank you Laz.

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