Configuration procedure

You can configure BGP route attributes to influence BGP route selection.

Follow these steps to configure BGP route attributes.

To do...

Use the command...


Enter global configuration context


Enter BGP context

bgp as-number  

Configure preferences for external, internal, local routes

preference {external-preference internal-preference local-preference}

Optional. The default preferences of external, internal, and local routes are 20, 200, and 200 respectively.

Configure weight to be assigned to received routes from a peer

neighbor {ip-address} weight {weight}


Specify the router as the next hop of routes sent to a peer

neighbor {ip-address} next-hop-self

Optional. By default, advertisements to an eBGP peer take the router as the next hop, while advertisements to an iBGP peer do not take the local router as the next hop.

Configure the AS_PATH attribute:    

Configure repeating times of local AS number in routes from a peer

neighbor {ip-address} allow-as-in [number]

Optional. The local AS number cannot be repeated in routes from the peer.

Specify a fake AS number for a peer

neighbor {ip-address} local-as as-number

Optional. Not specified by default This command is only applicable to an eBGP peer.

Substitute local AS number for the AS number of a peer in the AS_PATH attribute

neighbor {ip-address} as-override

Optional. The substitution is not configured by default.

Configure BGP to not keep private AS numbers in the AS_PATH attribute of updates to a peer

neighbor {ip-address} remove-private-as

Optional. By default, BGP updates carry private AS numbers.

  • Using a routing policy can set preferences for routes matching it. Routes not matching it use the default preferences.

  • If other conditions are identical, the route with the smallest MED value is selected as the best external route.

  • Using the neighbor next-hop-self command can specify the router as the next hop for routes sent to a peer. If BGP load balancing is configured, the router specifies itself as the next hop for routes sent to a peer regardless of whether the neighbor next-hop-self command is configured.

  • In a “third party next hop” network, that is, a BGP router has two eBGP peers in a common broadcast subnet, the BGP router does not specify itself as the next hop for routes sent to such an eBGP peer, unless the neighbor next-hop-self command is configured.

  • BGP checks if the AS_PATH attribute of a route from a peer contains the local AS number. If so, it discards the route to avoid routing loops.

  • You can specify a fake AS number to hide the real one. The fake AS number applies to routes sent to eBGP peers only, that is, eBGP peers in other ASs can only find the fake AS number.

  • The neighbor as-override command is used only in specific networking environments. Inappropriate use of the command may cause routing loops.