How to configure BGP AS Path Prepending

Hello David

Which attribute you will use depends on your situation as well as the capabilities and configurations of your neighboring AS. Let’s take a look at each option:

MED is an optional, non-transitive BGP attribute that suggests to external neighbors the preferred path into your AS. A lower MED value is preferred over a higher one. The MED attribute can be very effective, but it’s not always the best solution because its interpretation can vary depending on the BGP configurations on neighboring AS. Moreover, the MED is not always transmitted through multiple ASes, making it less effective in scenarios where you are trying to influence routing decisions several hops away.

AS Path Prepending involves adding additional instances of your own AS number to the AS path of certain routes. This makes the path seem longer, so it is less likely to be chosen by BGP, which prefers shorter paths. AS Path Prepending is a more aggressive way to influence inbound traffic because it will be seen by all BGP routers that receive your announcements, not just your immediate neighbors.

However, the best approach is to talk with the administrators of your neighboring AS (i.e. your ISP) before configuring any BGP attributes that influence incoming traffic. Make sure that what you have configured is acceptable on their end as well. You may find that one or the other option may be frowned upon and may be considered aggressive by your ISP if not discussed beforehand.

Generally speaking, MED may be a better choice when you’re only dealing with direct peers or neighbors, and you can be sure they’ll honor MED. AS Path Prepending might be more suitable if you want to ensure your changes will be seen throughout the internet, or you’re dealing with networks that ignore MED.

There are other ways to influence incoming traffic using BGP. For more information about this, take a look at this NetworkLessons note on BGP influencing incoming traffic.

Indeed, MED is a non-transitive attribute by design, and there is a reason for this. First of all, MED is often meant to dictate preferences based on factors like link bandwidth or congestion that aren’t necessarily relevant to ASes that are multiple hops away. So the MED attribute is typically used to implement local policy. For example, one might use it to guide traffic toward a cheaper but slower link for certain kinds of non-critical traffic. Since such policies are typically local to an AS or a set of directly connected ASes, it makes sense for MED to be non-transitive.

Conversely, AS Path Prepending is a feature that is inherently transitive because the AS Path attribute provides critical information for routers to make decisions about the best path to a destination based on the number of ASes that must be passed through.

I hope this has been helpful!

Laz

1 Like