BGP Loop AS Prevention
BGP Loop AS Prevention
com/bgp-as-loops/
Introduction
In BGP loop prevention rules, routers should prune routes in phase two of
path selection where their AS is already apart of the the AS_PATH BGP
attribute. This causes an interesting problem for service providers providing
L3VPNs to customers via two independent eBGP connections
Topology
Default behavior
Juniper, by default, will not advertise routes from an ASN back to the same
ASN. Therefore, when CE1 sends routes to PE2 and those routes get reflected
from RR1 to PE4, we will not see PE4 attempt to send them to CE2
PE4 RIB-ADJ-OUT
And now we can check the router to see if it is advertising the route
PE4 ADJ-RIB-OUT
If the AS_PATH attribute of a BGP route contains an AS loop, the BGP route should be
excluded from the Phase 2 decision function.
root@CE2> show route receive-protocol bgp 100.69.0.4
CE2 ADJ-RIB-IN
To make the receiving router accept looped routes, we need to configure loops
set protocols bgp group ebgp neighbor 100.69.0.4 family inet unicast loops 2
CE2 ADJ-RIB-IN
We are now accepting the route. By saying loops 2, we tell the router to allow 1
loop and discard any routes having 2 loops or more. Additionally, the looped
routes will be marked as such in the router outputs as seen below.
CE2 RIB-LCL
Solution 2 (as-override)
If you're looking for a one-stop-shop method, you could lie to your CE router
about the AS_PATH by using as-override
... Compare the AS path of an incoming advertised route with the AS number of
the BGP peer under the group and replace all occurrences of the peer AS
number in the AS path with its own AS number before advertising the route
to the peer ...
PE4 RIB-ADJ-OUT
And the CE router is happy with that without making any changes
CE1 RIB-LCL
Conclusion
This one got me good. AS_PATH loops aren't my first thought when customers
are not receiving their routes correctly, but now I know!