Configuring the AS_PATH attribute

Permitting local AS number to appear in routes from a peer or peer group

In general, BGP checks whether the AS_PATH attribute of a route from a peer contains the local AS number. If yes, it discards the route to avoid routing loops.

In certain network environments (for example, a Hub&Spoke network in MPLS L3VPN), however, the AS_PATH attribute of a route from a peer must be allowed to contain the local AS number. Otherwise, the route cannot be advertised correctly.

To permit the local AS number to appear in routes from a peer or peer group and specify the appearance times (IPv4):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Enter BGP IPv4 unicast address family view or BGP-VPN IPv4 unicast address family view.

address-family ipv4 [ unicast ]

N/A

4. Permit the local AS number to appear in routes from a peer or peer group and specify the appearance times.

peer { group-name | ip-address } allow-as-loop [ number ]

By default, the local AS number is not allowed in routes from a peer or peer group.

To permit the local AS number to appear in routes from a peer or peer group and specify the appearance times (IPv6):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Enter BGP IPv6 unicast address family view or BGP-VPN IPv6 unicast address family view.

address-family ipv6 [ unicast ]

N/A

4. Permit the local AS number to appear in routes from a peer or peer group and specify the appearance times.

peer { group-name | ipv6-address } allow-as-loop [ number ]

By default, the local AS number is not allowed in routes from a peer or peer group.

Disabling BGP from considering AS_PATH during best route selection

To disable BGP from considering AS_PATH during best route selection (IPv4):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Enter BGP IPv4 unicast address family view or BGP-VPN IPv4 unicast address family view.

address-family ipv4 [ unicast ]

N/A

4. Disable BGP from considering AS_PATH during best route selection.

bestroute as-path-neglect

By default, BGP considers AS_PATH during best route selection.

To disable BGP from considering AS_PATH during best route selection (IPv6):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Enter BGP IPv6 unicast address family view or BGP-VPN IPv6 unicast address family view.

address-family ipv6 [ unicast ]

N/A

4. Disable BGP from considering AS_PATH during best route selection.

bestroute as-path-neglect

By default, BGP considers AS_PATH during best route selection.

Advertising a fake AS number to a peer or peer group

After you move a BGP router from an AS to another AS (from AS 2 to AS 3 for example), you have to modify the AS number of the router on all its EBGP peers. To avoid such modifications, you can configure the router to advertise a fake AS number 2 to its EBGP peers so that the EBGP peers still think that Router A is in AS 2.

To advertise a fake AS number to a peer or peer group (IPv4):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Advertise a fake AS number to a peer or peer group.

peer { group-name | ip-address } fake-as as-number

By default, no fake AS number is advertised to a peer or peer group.

This command applies to only EBGP peers or EBGP peer groups.

To advertise a fake AS number to a peer or peer group (IPv6):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Advertise a fake AS number to a peer or peer group.

peer { group-name | ipv6-address } fake-as as-number

By default, no fake AS number is advertised to a peer or peer group.

This command applies to only EBGP peers or EBGP peer groups.

Configuring AS number substitution


[IMPORTANT: ]

IMPORTANT:

Do not configure AS number substitution in normal circumstances. Otherwise, routing loops might occur.


To use BGP between PE and CE in MPLS L3VPN, VPN sites in different geographical areas should have different AS numbers. Otherwise, BGP discards route updates containing the local AS number. If two CEs connected to different PEs use the same AS number, you must configure AS number substitution on each PE to replace the AS number in route updates originated by the remote CE as its own AS number before advertising them to the connected CE.

Figure 58: AS number substitution configuration (in an IPv4 network)

For example, as shown in Figure 58, CE 1 and CE 2 use the same AS number 800. To implement bidirectional communication between the two sites, configure AS number substitution on PE 2 to replace AS 800 as AS 100 for the BGP route update originated from CE 1 before advertising it to CE 2, and perform the same configuration on PE 1.

To configure AS number substitution for a peer or peer group (IPv4):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Configure AS number substitution for a peer or peer group.

peer { group-name | ip-address } substitute-as

By default, AS number substitution is not configured.

To configure AS number substitution for a peer or peer group (IPv6):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Configure AS number substitution for a peer or peer group.

peer { group-name | ipv6-address } substitute-as

By default, AS number substitution is not configured.

Removing private AS numbers from updates sent to an EBGP peer or peer group

Private AS numbers are typically used in test networks, and should not be transmitted in public networks. The range of private AS numbers is from 64512 to 65535.

To remove private AS numbers from updates sent to an EBGP peer or peer group (IPv4):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Enter BGP IPv4 unicast address family view or BGP-VPN IPv4 unicast address family view.

address-family ipv4 [ unicast ]

N/A

4. Configure BGP to remove private AS numbers from the AS_PATH attribute of updates sent to an EBGP peer or peer group.

peer { group-name | ip-address } public-as-only

By default, this feature is not configured.

This command is only applicable to EBGP peers or peer groups.

To remove private AS numbers from updates sent to an EBGP peer or peer group (IPv6):

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view or BGP-VPN instance view.

  • Enter BGP view:bgp as-number

  • Enter BGP-VPN instance view:

    1. bgp as-number

    2. ip vpn-instance vpn-instance-name

N/A

3. Enter BGP IPv6 unicast address family view or BGP-VPN IPv6 unicast address family view.

address-family ipv6 [ unicast ]

N/A

4. Configure BGP to remove private AS numbers from the AS_PATH attribute of updates sent to an EBGP peer or peer group.

peer { group-name | ipv6-address } public-as-only

By default, this feature is not configured.

This command is only applicable to EBGP peers or peer groups.

Ignoring the first AS number of EBGP route updates

By default, BGP checks whether the first AS number in the AS_PATH attribute of a route update received from a peer is the AS number of that peer. If not, BGP discards the route update.

To ignore the first AS number of EBGP route updates:

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enter BGP view.

bgp as-number

N/A

3. Configure BGP to ignore the first AS number of EBGP route updates.

ignore-first-as

By default, BGP checks the first AS number of EBGP route updates.