# How to configure BGP AS Path Prepending

**URL:** https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954
**Category:** Lessons Discussion
**Created:** [December 24, 2016, 6:35pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954 "2016-12-24T18:35:49Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [December 24, 2016, 6:35pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/1 "2016-12-24T18:35:49Z")

</div>

This topic is to discuss the following lesson:

> **[How to configure BGP AS Path Prepending](https://networklessons.com/bgp/how-to-configure-bgp-as-path-prepending)**
>
> AS Path Prepending is a common BGP technique to influence path selection. In this lesson, you will learn how to configure AS Path prepending.

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [September 4, 2013, 3:19pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/2 "2013-09-04T15:19:01Z")

</div>

It was a good article but got confusing when you mixed up Jack with John.

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [September 8, 2013, 7:31am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/3 "2013-09-08T07:31:04Z")

</div>

Hi Tony,

Thanks, I just fixed it…the names are now correct.

Rene

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [January 31, 2014, 9:58am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/4 "2014-01-31T09:58:44Z")

</div>

nice explanation !!!

---

<div class="post-metadata">

### Author: ![email](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/e/54ee81/32.png) [@email](https://forum.networklessons.com/u/email)
#### Post date: [May 28, 2014, 9:06am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/5 "2014-05-28T09:06:09Z")

</div>

Hello Rene,

Thank you for yours articles, great job 😉 . I am beginner in learning of CCNP Routing so sorry for (probably) stupid question. In your articles missing the third attribute (Self-originated). Do you plan write about that? Thank you in advance.

Daniel

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [July 18, 2014, 2:00pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/6 "2014-07-18T14:00:35Z")

</div>

Great example. I do have one question: Are the prepending AS numbers arbitrary or do I have to coordinate this with my ISP. In other words, does it matter if I use random AS prepends are do they have to be reserved just as I reserved my own AS.

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [July 18, 2014, 3:02pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/7 "2014-07-18T15:02:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [July 24, 2014, 8:23am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/8 "2014-07-24T08:23:59Z")

</div>

We consider the case of dual ISP connection of a data center to the Internet. We want to receive all traffic via one ISP connection, keeping the other one as backup. How many times should i prepend my ASN#? It seems to me that # prepends \> largest ‘natural’ AS pathlength difference from any ww location to my DC. This ensures the prepended pathlength to be always longer than any ‘natural’ pathlength, hence to never take the Internet connection that prepends, unless the other one would fail.  
Can anybody give me some figure on this max expected difference in ‘natural’ AS-path lengths to a DC in Western Europe? I expect only a slight difference. Typically two local ISP’s will connect to two (or more) global ISPs, which in turn will reach out to any location worldwide, again via local ISPs at the far end. So two natural, alternate, ‘normal operations’ ASpaths should be quite similar in length. I also understand that, when backup/rerouting situations occur within the Internet, the differences in pathlength can and will increase. I would be curious if with e.g. 10 x prepending the AS, we would be at the safe side to exclude any traffic from entering the DC via the prepended path, as long as both paths are available. BTW, we consider to align the connection preference for ingress (set by AS path prepend) traffic to the egress prefence by applying a different local preference

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [July 30, 2014, 9:28pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/9 "2014-07-30T21:28:48Z")

</div>

Hello Rene Sir

This explanation was a mind dynamite. You kept it very simple and I wanted to thank you from bottom of my heart.

I have understood the concept. Thanks and keep writing and motivating people.

God bless you.  
Tc

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [July 31, 2014, 8:15am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/10 "2014-07-31T08:15:08Z")

</div>

You are very welcome Rounak.

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [July 31, 2014, 1:15pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/11 "2014-07-31T13:15:07Z")

</div>

Hi Jan,

Before I try to answer your question, I guess you want to be dual-homed so that you have a backup path but you want to be sure that your DC is never used as a transit AS?

There’s a simple solution for this, you just need to make sure you don’t advertise anything that you receive from ISP1 to ISP2 and the other way around. If that’s what you are looking for then take a look here:

> **[BGP Prevent Transit AS](https://networklessons.com/bgp/bgp-prevent-transit-as)**
>
> This lesson explains four configuration methods to prevent an autonomous system (AS) from becoming a transit AS.

If that’s not what you want…let me know and I’ll do my best to answer your question.

Rene

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [August 6, 2014, 11:58am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/12 "2014-08-06T11:58:18Z")

</div>

Hi Daniel,

I might write a short tutorial on it with an example but it is a simple one. A BGP router will prefer routes that it installed into BGP itself over a route that another router installed in BGP.

Rene

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [September 23, 2014, 10:17pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/13 "2014-09-23T22:17:47Z")

</div>

Thank you very much, very good article, learnd from you guys, really appreciated!

---

<div class="post-metadata">

### Author: ![jeffreywatson](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/j/41988e/32.png) [@jeffreywatson](https://forum.networklessons.com/u/jeffreywatson)
#### Post date: [September 24, 2015, 8:37pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/14 "2015-09-24T20:37:24Z")

</div>

Before applying AS Path prepending to one side the tie breaker was the router ID?

if both routers Jim and John have the Same Loopback0 then isn’t the router ID the same also.

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [September 24, 2015, 9:37pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/15 "2015-09-24T21:37:08Z")

</div>

The list with all BGP’s decisions for selecting the best path is quite long, this Cisco post has a good overview:

> **[Select BGP Best Path Algorithm](https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13753-25.html)**
>
> This document describes the function of the Border Gateway Protocol (BGP) best path algorithm.

It also covers some of the things we normally don’t often talk about. For example, you can see that when everything for an external path that it will prefer the oldest route before using the router ID as a tie-breaker.

The router ID of Jim and John could be the same if the loopback is created before starting the BGP process.

---

<div class="post-metadata">

### Author: ![Fabian\_Martinez1](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/f/8797f3/32.png) [@Fabian\_Martinez1](https://forum.networklessons.com/u/Fabian_Martinez1)
#### Post date: [January 18, 2016, 8:25pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/16 "2016-01-18T20:25:38Z")

</div>

Hi Team,

In the Cisco CCNP book, they say to use the inbound route map. I’m confused as to when we should use in our outbound? Can you please clarify?

Lovely site! Will continue to use.

Thanks

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [January 18, 2016, 9:35pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/17 "2016-01-18T21:35:52Z")

</div>

Hi Fabian,

It depends which BGP attribute you are trying to influence. For AS path prepending, you normally use it to advertise the longer AS path to a remote neighbor. Other attributes like local preference are done on inbound.

Rene

---

<div class="post-metadata">

### Author: ![Fabian\_Martinez1](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/f/8797f3/32.png) [@Fabian\_Martinez1](https://forum.networklessons.com/u/Fabian_Martinez1)
#### Post date: [January 19, 2016, 12:53am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/18 "2016-01-19T00:53:29Z")

</div>

Thanks Rene. Regarding inbound and outbound, can we say the following?

outbound will affect inbound traffic

inbound will affect outbound traffic

Thanks

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [January 19, 2016, 8:39am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/19 "2016-01-19T08:39:24Z")

</div>

Hi Fabian,

It’s the other way around 🙂

For example, when you use AS path prepending we configure it outbound. This means that the router on the side will receive the longer AS path…we are influencing them.

When we use a route-map to change the local preference, we do this inbound and it will influence our local AS.

Rene

---

<div class="post-metadata">

### Author: ![shivamkhandelwal](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/e19b73/32.png) [@shivamkhandelwal](https://forum.networklessons.com/u/shivamkhandelwal)
#### Post date: [February 25, 2016, 11:16am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954/20 "2016-02-25T11:16:32Z")

</div>

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 it on R1 did make sense.

Also, what difference will it make if I advertise the same subnet on R3 as well:

`R3(config-router)#network 192.168.1.0 mask 255.255.255.252`

Please explain I’ve seen some interesting changes on R5 BGP table by playing with above configurations. Requesting you to please put some light here.

Many Thanks.

[Next page](https://forum.networklessons.com/t/how-to-configure-bgp-as-path-prepending/954.md?page=2)
