BGP AS-path attribute: a list of autonomous systems that the Update already passed.
The AS-path attribute is a well-known mandatory attribute. RFC 1930 defines it as a 16-bit integer. The numbers 1 – 65.511 are assigned by IANA/RIR. AS numbers 64.512 – 65534 are reserved for private use.
To prevent a depletion of AS numbers RFC 4893 defines a 32-bit AS as well as a way ‘Old’ and ‘New’ BGP implementations can communicate these values without breaking.
A BGP speaking router will not modify the AS-path attribute when a route is advertised to an internal peer. When a route is advertised to an external peer, its own AS is prepended to the list. The attribute AS-path is mainly used to prevent loops. When a BGP speaking router receives an Update message in which the local AS is already in the AS-path, the route is dropped. The AS-path is also used to determine how far away a prefix is. The more autonomous systems that need to be crossed, the further away that prefix is to a router.
Observe the following:
The illustration shows a scenario wherein AS 1 is originating a prefix and sending it to AS 8. The router that sends the NLRI towards AS 8 will set the AS-path attribute. When the NLRI is received in AS 8, the AS-path attribute will only have 1 value, AS 1.
When AS 8 advertises the prefix to AS 52, the router in AS 8 sending the Update message to a BGP speaking router in AS 52 will update the AS-path again. The AS-path attribute list will be prepended with the BGP speakers own AS number, in this case 8.
The same thing happens in AS 52. When the prefix that was originated in AS 1 leaves AS 52, the AS-path attribute will be updated again. AS 52 will prepend it’s own AS number to the list and send the NLRI to the next AS.