BGP – as-override
1. Intro
Compare the AS path of an route with the AS number of the BGP peer in the group, and replace all occurrences of the peer AS number in the AS path with its own AS number before re-advertising the route to the peer.
This is essentially an alternate solution to the advertise-peer-as and loops combo that we’ve seen in the previous post. So, we will use the same setup.

### Same basic config:
set protocols bgp group AS65535 peer-as 65535
set protocols bgp group AS65535 neighbor 17.8.14.1
set protocols bgp group iBGP type internal
set protocols bgp group iBGP neighbor 17.8.17.2
### As already covered in the previous post, nothing is being advertised to R6, because of the as-path loop:
root@R7# run show route advertising-protocol bgp 17.8.14.1
[edit]
root@R7#
### Let's fix this with the as-override feature:
root@R7# set protocols bgp group AS65535 as-override
[edit]
root@R7# show | compare
[edit protocols bgp group AS65535]
+ as-override;
[edit]
root@R7# commit
commit complete
### Now the prefix is advertised to R6:
root@R7# run show route advertising-protocol bgp 17.8.14.1
inet.0: 31 destinations, 31 routes (31 active, 0 holddown, 0 hidden)
Prefix Nexthop MED Lclpref AS path
* 172.16.99.0/24 Self 64100 I
### We can see the updated as-path, AS65535 was replaced with 64100:
root@R7# run show route advertising-protocol bgp 17.8.14.1 extensive
inet.0: 31 destinations, 31 routes (31 active, 0 holddown, 0 hidden)
* 172.16.99.0/24 (1 entry, 1 announced)
BGP group AS65535 type External
Nexthop: Self
AS path: [64100] 64100 I
### R6 has the prefix with the updated as-path.
### The original as-path was '64100 65535 I', but we see that 65535 was replaced by 64100:
root@R6# run show route protocol bgp extensive
inet.0: 21 destinations, 21 routes (21 active, 0 holddown, 0 hidden)
172.16.99.0/24 (1 entry, 1 announced)
TSI:
KRT in-kernel 172.16.99.0/24 -> {17.8.14.2}
*BGP Preference: 170/-101
Next hop type: Router, Next hop index: 654
Address: 0x7bbfae4
Next-hop reference count: 2, key opaque handle: 0x0, non-key opaque handle: 0x0
Kernel Table Id: 0
Source: 17.8.14.2
Next hop: 17.8.14.2 via ge-0/0/3.0, selected
Session Id: 322
State: <Active Ext>
Local AS: 65535 Peer AS: 64100
Age: 2:41
Validation State: unverified
Task: BGP_64100.17.8.14.2
Announcement bits (1): 0-KRT
AS path: 64100 64100 I
Accepted
Localpref: 100
Router ID: 17.0.0.7
Thread: junos-main
We can see that as-override is more straightforward, and only R7 needs to be configured. Instead of configuring 2 routers: R7 with advertise peer as, and R6 with loops. Now it is enough to add as-override to R7.
2. New setup
Let’s put more routers and more ASs in our test topology. In fact, this is the same setup from the previous post:

This time, we want to advertise the prefixes originated by R4 and R5 to R1.
By default, R2 will advertised the prefixes to R1, but R1 will discard the prefixes because of the as-path loop (you can check the previous post if not clear why).
### The prefixes are advertised to R1.
root@R2# run show route advertising-protocol bgp 17.8.0.1
inet.0: 24 destinations, 24 routes (24 active, 0 holddown, 0 hidden)
Prefix Nexthop MED Lclpref AS path
* 192.168.40.0/26 Self 65002 65535 I
* 192.168.50.0/26 Self 65002 65535 64003 I
### R1 is discarding the prefixes:
root@R1# run show route receive-protocol bgp 17.8.0.2
inet.0: 24 destinations, 24 routes (24 active, 0 holddown, 0 hidden)
### Let's see more by instructing R1 not to discard the prefixes:
root@R1# set protocols bgp group AS650001 keep all
[edit]
root@R1# commit
commit complete
### The prefixes are not discarded, but not used either; they are hidden:
[edit]
root@R1# run show route receive-protocol bgp 17.8.0.2 hidden extensive
inet.0: 26 destinations, 26 routes (24 active, 0 holddown, 2 hidden)
192.168.40.0/26 (1 entry, 0 announced)
Nexthop: 17.8.0.2
AS path: 65001 65002 65535 I (Looped: 65535)
Hidden reason: AS path loop
192.168.50.0/26 (1 entry, 0 announced)
Nexthop: 17.8.0.2
AS path: 65001 65002 65535 64003 I (Looped: 65535)
Hidden reason: AS path loop
Let’s configure as-override knob and see the impact:
### Configuring as-override:
root@R2# set protocols bgp group AS65535 as-override
[edit]
root@R2# show | compare
[edit protocols bgp group AS65535]
+ as-override;
[edit]
root@R2# commit
commit complete
[edit]
root@R2# run show route advertising-protocol bgp 17.8.0.1
inet.0: 24 destinations, 24 routes (24 active, 0 holddown, 0 hidden)
Prefix Nexthop MED Lclpref AS path
* 192.168.40.0/26 Self 65002 65001 I
* 192.168.50.0/26 Self 65002 65001 64003 I
### On R1, the prefixes are no longer hidden:
root@R1# run show route receive-protocol bgp 17.8.0.2 hidden extensive
inet.0: 26 destinations, 26 routes (26 active, 0 holddown, 0 hidden)
### Remove 'hidden' from the command:
root@R1# run show route receive-protocol bgp 17.8.0.2 extensive
inet.0: 26 destinations, 26 routes (26 active, 0 holddown, 0 hidden)
* 192.168.40.0/26 (1 entry, 1 announced)
Accepted
Nexthop: 17.8.0.2
AS path: 65001 65002 65001 I
* 192.168.50.0/26 (1 entry, 1 announced)
Accepted
Nexthop: 17.8.0.2
AS path: 65001 65002 65001 64003 I
3. Closing remarks
- As already mentioned in the previous post, this is a useful feature in common setups like MPLS L2VPNs.
- Configuring as-override is more straightforward, and doesn’t require two routers to be configured.
Note: enabling the AS as-override 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: