8 mins read

BGP – advertise-peer-as

1. The default

In the Juniper documentation we have the following statement: by default, Junos OS does not advertise the routes learned from one EBGP peer back to any EBGP peers that are in the same AS as the originating peer.

Let’s explore this feature and put it to the test. The text book scenario for this feature is the following:

advertise-peer-as

As we can see, R6 and R8 have the same AS number, so there is an as-path loop. In Junos, R7 will see the as-path loop, and in order to optimize BGP advertisements, it will not even exchange the prefixes between R6 and R8. R7 will accepts the prefixes form R6 and R8, but it will not advertise those prefixes back to the AS65535:

  • R7 will not advertise 192.168.66.0/24 to R8
  • R7 will not advertise 192.168.88.0/24 to R6

This may seem strange to you if you come from Cisco. If we are to make a comparison, R7 with Cisco IOS will advertise the prefixes back to R6 and R8, and it will be on R6 and R8 to notice the loop and reject the prefixes.

2. Add the advertise-peer-as knob

We will change the setup a little bit.

advertise-peer-as

The documentation is talking about EBGP to EBGP advertisements, but in our new setup we have iBGP to EBGP. will that work?

As we can see, R7 will notice the as-path loop, and will optimize advertisements by not sending the prefix to R6.

Maybe not the most realistic setup, but for learning purposes we want to see the advertise-peer-as knob at work, so let’s configure that:

R7 is now advertising the prefix to R6, but R6 will discard the prefix because of the as-path loop. But we can make R6 to allow and use the prefix by configuring the loops knob. This is similar to the Cisco allow-as in.

For completeness, let’s acknowledge that in order to make this working end to end, of course we must configure the advertise-peer-as and loops combo on the R8 and R9 routers. To keep the post short, I will not show the R8 and R9 configuration here because it is identical.

3. Not applicable scenarios

At this point you may be tempted to say that “Junos doesn’t advertise the routes if the neighboring AS number is already in the AS path of the respective route”. When learning about this default behavior I was guilty of this myself. But this is not true. We have scenarios where Junos will advertise the prefix to a neighbor even if the is an as-path loop:

advertise-peer-as

We can see that R2 will advertise to R1 the prefixes from R4 and R5 even without the advertise-peer-as knob, even if the loop is there.

We can conclude that Junos will check for an as-path loop, but it will compare only the 1st AS from as-path.

In our example, it will compare AS65002 with the destination AS65535. No loop here, ignore the rest and advertise the prefix to peer.

Personal note: when I consider that some prefixes can have long AS paths, and considering the sheer number of Internet prefixes that are managed by BGP, then it makes sense not to go crazy and compare each AS from the as-path. Comparing only the 1st AS is probably a good balance and will save a lot of computing resources on the router.

4. Closing remarks

But why even allow the loop in the network? If the previous scenarios are maybe not that common, in MPLS L3VPN it is norm to use the same AS number for all VPN sites of a given Customer. If we want end to end connectivity, then we must allow as-path loops in the network, by either using the advertise-peer-as and loops combo, or the as-override feature.

A few final remarks:

  • Notice this post was more about the EBGP advertisement default behavior, and less about advertise-peer-as.
  • The default behavior: When advertising to an eBGP peer, Junos will check each prefix for as-paths loops, but will check only the 1st AS from the prefix as-path. If there is an as-path loop for 1st prefix, don’t advertise that prefix.
  • advertise-peer-as will change the default behavior by advertising the prefix to the peer. It will be on the peer to discard the prefix with the as-path loop.
  • advertise-peer-as is often used in conjunction with loops.
  • often times as-override is a better solution.

Note: enabling the AS loops feature may result in routing loops. Use this feature only for specific applications that require this type of behavior, and in situations with strict network control.


External Resources: