10-20-2011 02:45 AM - edited 03-04-2019 01:59 PM
Hi BGP Experts,
I am seeing a behaviour where the as-path prepend allows the cisco router to advertise a route with as-path where the originating AS is changed after applying route-map .
As per my understanding the originating AS should not be changed by user configuration . Also as-path prepend is used in the case of when we prepend the as number rather than appending it.
topology :
----------------
R1(gi 0/1)----------------(gi 0/1)R2
Config on R1
-----------------------------
interface gi 0/1
ip address 10.10.20.1 255.255.255.0
no shut
router bgp 200
neighbor 10.10.20.2 remote-as 100
network 1.1.1.0 255.255.255.0
neighbor 10.10.20.2 route-map ABCD out
route-map ABCD permit 10
set as-path prepend 300
ip route 1.1.1.0 255.255.255.0 null0
Config on R2
--------------------------
interface gi0/1
ip address 10.10.20.2 255.255.255.0
no shut
router bgp 100
neighbor 10.10.20.1 remote-as 200
network 2.2.2.0 255.255.255.0
ip route 2.2.2.0 255.255.255.0 null0
--------------------------------------------------------------
The output of "sh ip bgp " shows as given below :
7604-R2302#sh ip bgp
BGP table version is 3, local router ID is 12.18.23.2
Status codes: s suppressed, d damped, h history, * valid, >best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network NextHop MetricLocPrf Weight Path
*> 1.1.1.0/24 10.10.20.1 0 0 200 300 i
*> 2.2.2.0/24 0.0.0.0 0 32768 i
Here AS path is "200 300 i" which does not seem correct. As per my understanding it should have been "300 200 i" as the originating AS is : 200.
Can someone kindly help me to figure out what could be a possible reason for this issue ?
Any suggestion and help is greatly appreciated .
Thanks a ton in advance,
Regards,
Ashok Kumar .
10-20-2011 02:56 AM
Hi Ashok,
It is as-path PREPEND.
Hence, when you prepend any AS, it would be prepended to your AS.
In other words, added behind your AS.
eg, if your AS is 200 and you prepend 300 (as your config)
it would be 200 300 i
Regards,
Smitesh
10-20-2011 03:03 AM
Hi Smitesh,
I appreciate the response from you. However, When you traverse from one AS to Another AS it is prepended .
for ex : R1(100) -------------R2 (200)----------R3 (400) .
The AS path would be if originating AS is : 100 , then it would be : 400 200 100 i .
Hence in this case too , if you prepend the as no it should come out like : 300 200 i .
Kindly correct me if I am wrong here.
Anyways Thanks for your reply.
Regards,
Ashok.
10-20-2011 03:14 AM
You are correct over there.
Lemme explain you in some other way.
When you do as-path prepending, you are prepending AS number before even it is passed to another AS.
I hope it helps.
Regards,
Smitesh
10-20-2011 03:22 AM
Hi Smitesh,
Thanks for considering my approach. But I am applying route-map on outbound direction . Hence I consider that originating AS info is added first and then the output policy engine applies before sending outbound update messages.
Hence this method is introducing a issue where the originating AS info is lost . it appears as if the route/prefix originated from the 300 AS rather than AS :200 while actually route is originally originated from AS :200 .
I am not sure if this is expected behavior as per rfc 4271.
Please see the reference rfc 4271 snippet below .
Thansk for reply,
With Kind Regards,
Ashok.
.S. Snippet from rfc 4271 :
Rekhter, et al. Standards Track [Page 25]
RFC 4271 BGP-4 January 2006
1) if the first path segment of the AS_PATH is of type
AS_SEQUENCE, the local system prepends its own AS number as
the last element of the sequence (put it in the leftmost
position with respect to the position of octets in the
protocol message). If the act of prepending will cause an
overflow in the AS_PATH segment (i.e., more than 255 ASes),
it SHOULD prepend a new segment of type AS_SEQUENCE and
prepend its own AS number to this new segment.
2) if the first path segment of the AS_PATH is of type AS_SET,
the local system prepends a new path segment of type
AS_SEQUENCE to the AS_PATH, including its own AS number in
that segment.
3) if the AS_PATH is empty, the local system creates a path
segment of type AS_SEQUENCE, places its own AS into that
segment, and places that segment into the AS_PATH.
When a BGP speaker originates a route then:
a) the originating speaker includes its own AS number in a path
segment, of type AS_SEQUENCE, in the AS_PATH attribute of all
UPDATE messages sent to an external peer. In this case, the AS
number of the originating speaker's autonomous system will be
the only entry the path segment, and this path segment will be
the only segment in the AS_PATH attribute.
b) the originating speaker includes an empty AS_PATH attribute in
all UPDATE messages sent to internal peers. (An empty AS_PATH
attribute is one whose length field contains the value zero).
Whenever the modification of the AS_PATH attribute calls for
including or prepending the AS number of the local system, the local
system MAY include/prepend more than one instance of its own AS
number in the AS_PATH attribute. This is controlled via local
configuration.
10-20-2011 03:32 AM
Hi,
the originating AS is the one on the farthest right in AS_PATH so if you do AS prepending that is adding to the left multiple times your AS when sending the update then the originating AS will still be there.
Could you clarify your thoughts.
Alain.
10-20-2011 03:42 AM
Hi Alain,
I observe the same . The originating AS is the one on the farthest right in AS_PATH . but in my scenario, when I originate a prefix from AS :200 and do the AS-PATH prepend with as number 300 . The 300 is seen on farthest right in AS_PATH .
The scenario is again here :
R1(AS:100)---------------(AS:200)R2
if i apply route-map with "set as-path prepend 300" , I see 300 at farthest right as given below :
7604-R2302#sh ip bgp
BGP table version is 3, local router ID is 12.18.23.2
Status codes: s suppressed, d damped, h history, * valid, >best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network NextHop MetricLocPrf Weight Path
*> 1.1.1.0/24 10.10.20.1 0 0 200 300 i <<<<<<<<<<<<<<<<< 300 is farthest right
*> 2.2.2.0/24 0.0.0.0 0 32768 i
Hence the originating AS info is lost.
Please correct me if I am wrong.
Thanks for all help,
Regards,
Ashok.
10-20-2011 04:07 AM
Hi Ashok,
As I said earlier, your are prepending the AS before it is advertised to another AS.
In other word, even before it leaves your AS, you are prepending it wil as-path prepend ( in your cse 300).
Then once, it goes out of your AS, your AS ( which is 200) is added.
Regards,
Smitesh
10-20-2011 04:30 AM
Hi Smitesh,
Did you mean that after receiving the updates the neighbour adds the AS number ??? I am not sure about that .
However, As per my understanding the AS number is prepended when the outbound updates are sent in AS_Sequence and hence AS_Path.
Kindly refer the rfc as i mentioned earlier.
When a BGP speaker originates a route then:
a) the originating speaker includes its own AS number in a path
segment, of type AS_SEQUENCE, in the AS_PATH attribute of all
UPDATE messages sent to an external peer. In this case, the AS
number of the originating speaker's autonomous system will be
the only entry the path segment, and this path segment will be
the only segment in the AS_PATH attribute.
I hope this helps.
Thanks & Regards,
Ashok.
10-20-2011 04:34 AM
Hi Ashok,
Nopes.
Your router would be adding its own AS before it is advertised to another AS.
However, in case of prepending; prepending will be done before even adding my own AS.
hence, it would look like,
10-20-2011 04:15 AM
Hi,
when you do AS_PATH prepending you always use your own AS not another because the router when sending update always prepends its own AS number so what you had was normal behaviour because you prepending was not used correctly.
change your set command with set as-path prepend 200 instead of 300.
Alain.
10-20-2011 04:32 AM
Hi Alain
Prepending the own AS is a guideline so that route is always identified to be belonging to correct organization authority who owns the route. But this is not a limitation on AS-Path Prepending.SO this should not effect the current setup in question.
Hi Ashok
Are you testing AS-Path prepending by prepending the AS on the router originating the route or at an intermediate hop.
If we are prepending the route at the originating router then remember AS-Path is always prepended to the origin of AS-Path and thats why the prepended AS value will be the to the right most and the original AS no. will follow after that moving towards left.
So if an Originating AS 200 is prepending AS 300 to a route x localy originated then the AS path wil look like this
Network NextHop MetricLocPrf Weight Path
*> X NH 0 0 200 300 i <<<<<<<<<<<<<<<<< 300 is prepended AS.
Hope this clarifies your doubt.
Regards
Varma
10-20-2011 04:56 AM
Hi Vaibhava,
I did see the same behaviour what you have mentioned . However if you refer rfc 4271 , it clearly mentions that when it is originating AS , we must add originating AS a right most AS .
The issue is that due to such configuration , We are loosing the originating AS info and there is no other way to actually find out which AS has originated the prefix. Hence Other AS would never be able to correctly distinguish who has originated a particular prefix. I firmly beleive that we should not be allowed to do such configuration.
Kindly provide your inputs on this.
With Warm Regards,
Ashok.
10-20-2011 04:32 AM
I agree with Alain in practically scenarios.
However, as far as bgp working is concerned, you can do it.
Regards,
Smitesh
10-20-2011 04:33 AM
Hi Alain,
In this case it should not be allowed to configure the different AS numbers if as-path prepend only used for the purpose of use your own AS number.
I hope this clarifies my opinion to use different AS numbers.
Thanks & Regards,
Ashok.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide