With regards to the restrictions, could you elaborate on the last two please?
→ If the AS path contains the AS number of the eBGP neighbor then it won’t be removed.
→ If there are confederations, BGP only removes private AS numbers after the confederation part in the AS path.
Concerning this first restriction, take a look at the following post:
Now having said that, it turns out that in newer versions of IOS such as release 15SY, this is no longer a restriction as you can see from page two of the following Cisco documentation:
When confederations are involved, the AS path will consist of a list of AS’es and sub-AS’es. The sub AS’es are denoted in the path in brackets. Within the BGP packet, these are denoted using the AS_CONFED_SEQUENCE segment type. Here is an example of a Wireshark capture of a BGP advertisement that contains a path attribute of 65000 which is marked as a segment type of AS_CONFED_SEQUENCE, which means it is a sub AS.
What this restriction is saying is that any AS path that contains private AS’es will have those private AS’es removed only if they come after the AS_CONFED_SEQUENCE section of the path (if it exists).
I was wondering why this is the case, but I was unable to find any information about this. I’m sure there’s a reason for it, but I’m not sure what it is . I can share this with Rene, and see if he has any insight as to why…
A quick question about Remove-Private-AS All and Remote-Private-AS All Replace.
Removing the private AS number(s) will only work if there are no public AS numbers in the AS path. To demonstrate this I will add extra AS numbers on the update from R1.
In what kind of situation in the real world would there be multiple ASes in the AS Path field that are both Private and Public? This means that the traffic would have to pass not only a private AS but also a public AS.
If there is a scenario, then when should we use Remove-Private-AS All Replace and when Remove-Private-AS All?
We often think about BGP exclusively as the routing protocol on the Internet. Remember, it is also extensively used on internal enterprise networks as well as on edge networks. As such, there are several situations in which you would have both private and public ASes in the AS Path. Take a look at this post concerning this fact.
Specifically, in the real world, you might encounter multiple ASes in the AS Path field that are both Private and Public in scenarios where an organization has multiple branches with their own private AS, and they are connected to the internet (public AS) through their ISP.
In such scenarios, the Remove-Private-AS All command can be used when you want to remove all occurrences of private AS numbers from the AS path, irrespective of their position in the path. This is generally done to hide the internal AS path details when advertising routes to external peers.
On the other hand, the Remove-Private-AS All Replace command replaces all occurrences of private AS numbers with the local AS number. This is useful when you want to maintain the length of the AS path while still hiding the private AS numbers.
This is an excellent question! I have created a NetworkLessons note that explains the reasoning behind this. Take a look at the note found here for more information. If you have any further questions, let us know!
I understand the use case of remove-private-as all /replace-as commands from the explanations. Basically it’s to hide your private-as to the outside world I assume. When the AS path on R3 shows 2 2 1 2 11 2 111 i, R3 thinks that the route to 1.1.1.1 originated from the AS 111, isn’t it? So any packets destined to 1.1.1.1 would be sent to R2 as the next hop in R3 BGP table is 192.168.23.2.
Once the packet arrives in R2, the AS path will be 2 1 2 11 2 111 i, I believe? Or would it be just 64512 i, as the extra AS numbers etc was added via route-map outbound to R3 to influence the AS path and routing decisions and all these remove-private-as commands don’t have any effect on the incoming packets?
Also, if R3 has another route somehow via a different ISP (R4) back to R1 which uses the remove-private-as all command instead of the replace-as, the AS path length would be shorter and will be the preferred path, isn’t it?
Sorry if this is a dumb question. In real world, small things can still cause loops or degraded routing performance.
When R3 receives the AS path 2 2 1 2 11 2 111, it reads the path from left to right for the order of ASes, and indeed, the rightmost AS is 111, so R3 interprets AS 111 as the originating AS for the 1.1.1.1/32 route. From R3’s perspective, this path looks completely normal and public. It has no visibility into the fact that R2 used replace-as to mask private ASes (64512, 64513, 64514) by swapping each one for AS 2.
This is where we need to separate the BGP control plane from the data plane.
The AS path is a BGP attribute. It exists in BGP updates and in the BGP table, but it is not carried inside the actual IP packet. So when a packet arrives at R2, the packet itself does not have an AS path of 2 1 2 11 2 111 or 64512.
R2 simply receives the packet, checks its routing/forwarding table, and forwards the packet toward the destination, 1.1.1.1. R2’s BGP table contains the unmodified path as it received it from R1. The remove-private-as commands operate exclusively on outbound updates, not on what R2 stores internally in its own BGP table. So when R2 receives the route from R1 with the original prepended AS path 64512 1 64513 11 64514 111, that’s exactly what R2 keeps in its BGP table unchanged.
If such a path existed, and it was indeed shorter, it would be preferred based on the BGP best path algorithm (assuming all previous attributes are equal), regardless of whether or not any remove private AS commands were used. If the result is a shorter AS path, then that path would be chosen based on the AS Path Length attribute.
You are indeed correct that small things do cause loops or degrated routing performance, so no, your questions are not dumb, they’re well thought out and important. I hope they have been cleared up, and if not, let us know!