BGP Replace ASNs in the AS Path

This chapter explains how BGP replaces ASNs in the route map.

Information about BGP Replace ASNs

This document describes how using the BGP policy, any of the configured Autonomous System Numbers (ASNs) are replaced with its own ASN. You can replace one or many ASNs using the AS_PATH attribute.

Loop prevention in BGP is based on the verification of AS numbers in the AS Path. If the receiving router sees its own AS number in the AS Path of the received BGP packet, the packet is dropped. However, this may cause issue in an inter-AS Hub and Spoke, such as a central Firewall location which must advertise more specific prefixes back to the spokes so the inter-AS crossing can happen twice (back and forth). The existing set as-path command under route-map provides functionality to prepend to the as-path and set tag. This solution expands the set as-path command to allow replace a sequence of ASNs to own or local AS.

Restrictions for BGP Replace ASNs in the AS Path

  • BGP Replace ASNs in the AS Path feature supports only eBGP neighbors on a per AFI basis.

  • When configuring BGP replace ASNs on iBGP neighbors, a warning message appears saying, the route-map configuration is taken (not failed), but the set as-path replace clause is ignored.

  • The route-map with replace as-path functionality is applied to both inbound and outbound side of BGP neighbor. For inbound side, BGP replaces ASNs after the AS-PATH loop detection.

  • The set as-path replace command only operates on AS_SEQUENCE and AS_CONFED_SEQUENCE, not AS_SET and AS_CONFED_SET attributes.

  • Translate 4-byte AS number to 2 byte AS number before sending BGP messages to a BGP speaker.

  • If confederation id is configured, when talking to a peer that is outside the confederation, use confederation ID to replace the ASNs. When talking to a peer that belong to the same confederation, use member-AS number to replace the ASNs.

  • When the BGP Local-AS feature is configured, the configured Local-AS is used to replace the ASNs defined.

  • The maximum length of a command is defined by PARSEBUF, which is 256 bytes. So, the max number of ASNs that are allowed in a single is 256 bytes.

  • When multiple set as-path replace are configured, each entry is applied in a chain recursively, where the output of the current entry is the next entry in the chain.

  • If you configure both set as-path prepend and set as-path replace, BGP processes set as-path replace first, and then set as-path prepend.

Configure BGP Replace ASNs in the AS Path

To replace a sequence of ASNs to its own AS, use the set as-path replace command:

Device(config-route-map)# set as-path replace {any | as-path-string}
any replaces each AS number in the AS path with the local AS number.
Device(config-route-map)# set as-path replace {any | as-path-string}
as-path-string is a sequence of AS numbers.

Configuration Examples for BGP Replace ASNs in the AS Path

The following example shows how to replace AS numbers in the AS path. In the example, AS-Path is "67 100 65533 5 78 89 6 5 28 100 9", and locally configured ASN is 900:

Device(config)#route-map test
R1(config-route-map)# set as-path replace 100

In this configuration, all occurrences of 100 in the AS-path are replaced with a local AS. The new AS-Path will be "67 900 65533 5 78 89 6 5 28 900 9".

Device(config)#route-map test
Device(config-route-map)# set as-path replace 5 78

In this configuration, all occurrences of AS sequence "5 78" in the AS-path replaces all the ASNs in the configured AS sequence with local AS. The new AS-Path will be "67 100 65533 900 900 89 6 5 28 100 9".

The following example configures to replace multiple individual ASNs or AS sequences:

Device(config)#route-map test
Device(config-route-map)# set as-path replace 100
Device(config-route-map)# set as-path replace 6
Device(config-route-map)# set as-path replace 5 78

With this configuration, the feature finds all occurrences of 6, 100, and AS sequence "5 78" in the AS-path and replace all of them with own AS. The new AS-Path will be "67 900 65533 900 900 89 900 5 28 900 9".

The following example replaces every AS numbers in the AS-path:

Device(config)#route-map test
Device(config-route-map)# set as-path replace any

In this configuration, the new AS-Path will be "900 900 900 900 900 900 900 900 900 900 900".

Feature Information for BGP Replace ASNs in the AS Path

The following table provides release information about the feature or features described in this module. This table lists only the software release that introduced support for a given feature in a given software release train. Unless noted otherwise, subsequent releases of that software release train also support that feature.

Use Cisco Feature Navigator to find information about platform support and Cisco software image support. To access Cisco Feature Navigator, go to www.cisco.com/go/cfn. An account on Cisco.com is not required.
Table 1. Feature Information for BGP Replace ASNs in the AS Path

Feature Name

Releases

Feature Information

BGP Replace ASNs in the AS Path

Cisco IOS XE Amsterdam 17.1.1

BGP Replace Autonomous System Numbers (ASNs) feature is a BGP policy on the router that allows replacing any of the configured AS number with its own AS. Many AS numbers can be specified to allow such a replace to happen to more than one AS number using the AS_PATH attribute.

The following command has been introduced:

  • set as-path replace