BGP basic configuration

The following configuration tasks are described as required or optional.

Task Remarks
Configuring BGP connection Required
Controlling route distribution and reception Configuring BGP route redistribution Optional
Configuring BGP route distribution filtering policies Optional
Configuring BGP route reception filtering policies Optional
Routemap filtering and route modifications Optional
Configuring BGP route attributes Optional
Tuning and optimizing BGP networks   Optional
Configuring BGP community Optional
Configuring BGP GR Optional

Configuring a BGP connection


[NOTE: ]

NOTE: Since BGP runs on TCP, you must specify the IP addresses of the peers in order to establish a BGP session. The peers may not be directly connected.

IP addresses of loopback interfaces can be used to improve the stability of BGP connections.


Prerequisites

The neighboring nodes must be accessible to each other at the network layer.

Creating a BGP connection

  • A router ID is the unique identifier of a BGP router in an AS.

  • To ensure the uniqueness of a router ID and enhance network reliability, you can specify in BGP configuration context the IP address of a local loopback interface as the router ID.

  • If no router ID is specified in BGP context, the global router ID is used.

  • If the global router ID is used and then it is removed, the system will select a new router ID.

  • Unconfiguring the router ID in BGP context can make the system select a new router ID.

Follow these steps to create a BGP connection:

To do... Use the command... Remarks
Enter global configuration context configuration  
Enter BGP context router bgp as-number Not enabled by default
Enable BGP enable  
Specify a BGP Router ID bgp router-id ip-address Optional. By default, the global router ID is used.
Specify a neighbor and its AS number neighbor {ip-address} remote-as as-number Required
Configure a description for a neighbor neighbor {ip-address} description description-text Optional. Not configured by default

[CAUTION: ]

CAUTION: Since a router can reside in only one AS, the router can run only one BGP process.


Specifying the source interface for TCP connections

BGP uses TCP as the transport layer protocol. By default, BGP uses the output interface of the optimal router to a peer as the source interface for establishing TCP connections to the peer. If a BGP router has multiple links to a peer, when the source interface fails, BGP has to reestablish TCP connections, causing network oscillation. Therefore, it is recommended to use a loopback interface as the source interface to enhance stability of BGP connections.

Follow these steps to specify the source interface of TCP connections:

To do... Use the command... Remarks
Enter global configuration context configuration  
Enter BGP context bgp as-number  
Specify the source interface for establishing TCP connections to a neighbor. neighbor {ip-address} update-source {ip-address} Required. By default, BGP uses the outbound interface of the best route to the BGP peer as the source interface for establishing a TCP connection to the peer.

Establishing MD5 authentication for TCP connections

BGP requires TCP as the transport protocol. To enhance security, you can configure BGP to perform MD5 authentication when establishing a TCP connection. The two parties must have the same password configured to establish TCP connections. BGP MD5 authentication is not for BGP packets, but for TCP connections. If the authentication fails, no TCP connection can be established.

To do... Use the command... Remarks
Enter system view system-view  
Enter BGP view bgp as-number  
Enable MD5 authentication when establishing a TCP connection to the peer/peer group

peer [[group-name] | [ip-address]] password [[cipher] | [simple]] password

Optional. Not enabled by default.

Allowing establishment of an eBGP connection to a non-directly connected peer

In general, direct physical links should be available between eBGP peers. If not, you can use the neighbor ip-address ebgp-multihop command to establish a TCP connection over multiple hops between two peers.

Follow these steps to allow establishment of eBGP connection to a non-directly connected peer.

To do... Use the command... Remarks
Enter global configuration context configuration  
Enter BGP context bgp as-number  
Allow the establishment of eBGP connection to a non-directly connected peer neighbor ip-address ebgp-multihop [hop-count] Optional. hop-count is 1 by default for eBGP peers

Controlling route distribution, reception and advertisement

Prerequisites

Before configuring this task, you should have completed the BGP basic configuration.

Configuring BGP Route Redistribution

You can redistribute IGP routes into BGP. During route redistribution, BGP can filter routing information from specific routing protocols.

To do... Use the command... Remarks
Enter global configuration context configuration  
Enter BGP context router bgp as-number  
Redistribute from other protocols redistribute static | connected | ospf | rip {route-map route-map-name} Redistributes other protocol routes into BGP

[NOTE: ]

NOTE: The ORIGIN attribute of routes redistributed using the import-route command is Incomplete.

The ORIGIN attribute of networks advertised into the BGP routing table with the network command is IGP. These networks must exist in the local IP routing table. Using a routing policy makes route control more flexible.


Configuring BGP route inbound and outbound filtering policies

Follow these steps to configure BGP route reception filtering policies:

To do... Use the command... Remarks
Enter global Configuration context configuration  
Enter BGP context bgp as-number  
Apply filter policy on the inbound or the outbound for each peer neighbor ip-address route-map route-map-name [in | out]  

[CAUTION: ]

CAUTION: Only routes permitted by the specified filtering policies can be installed into the local BGP routing table.


Configuring BGP route attributes

Prerequisites

Before configuring this task, you should have configured BGP basic functions.

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... Remarks
Enter global configuration context configuration  
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} Optional
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.

[CAUTION: ]

CAUTION:

  • 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.




Tuning and optimizing BGP networks

Prerequisites

BGP connections have been created.

Configuring a BGP keepalive interval and holdtime

After establishing a BGP connection, two routers send keepalive messages periodically to each other to keep the connection. If a router receives no keepalive or update message from the peer within the holdtime, it breaks the connection.

If two parties have the same timer assigned with different values, the smaller one is used.

Follow these steps to configure BGP keepalive interval and holdtime.

To do... Use the command... Remarks
Enter global configuration context configuration  
Enter BGP context bgp as-number  
Configure the global keepalive interval and holdtime timers {keepalive-time} {hold-time}  
Configure the keepalive interval and holdtime for a peer neighbor {ip-address} timers {keepalive-time} {hold-time} Optional. By default, the keepalive interval is 60 seconds, and holdtime is 180 seconds.

[CAUTION: ]

CAUTION:

  • The maximum keepalive interval should be one third of the holdtime and no less than 1 second. The holdtime is no less than 3 seconds unless it is set to 0.

  • Intervals set with the neighbor timers command are preferred to those set with the timers command.

  • If the router has established a neighbor relationship with a peer, you need to reset the BGP connection to validate the new set timers.




Configuring a large scale BGP network

In a large-scale BGP network, configuration and maintenance become difficult due to large numbers of BGP peers. To facilitate configuration in this case, you can configure community or route reflector as needed.

Prerequisites

A BGP community must be configured. Follow these steps.

To do... Use the command... Remarks
Enter the global configuration context configuration  
Enter the BGP context bgp as-number  
Advertise the community attribute to a peer neighbor {ip-address} send-community Enabled by default

[CAUTION: ]

CAUTION: When configuring the BGP community, you must configure a routing policy to define the community attribute, and then apply the routing policy to the route advertisement.


Configuring a BGP route reflector

Follow these steps to configure a BGP route reflector:

To do... Use the command... Remarks
Enterthe global configuration context configuration  
Enter the BGP context bgp as-number  
Configure the router as a route reflector and specify a peer as its client client-to-client-reflection Enabled by default
Enable route reflection between clients neighbor {ip-address} route-reflector-client Optional. Enabled by default.

[CAUTION: ]

CAUTION: It is not required to make clients of a route reflector fully meshed. The route reflector forwards routing information between clients. If clients are fully meshed, you can disable route reflection between clients to reduce routing costs.

A cluster has only one route reflector, and the router ID is used to identify the cluster. You can configure multiple route reflectors to improve network stability. In this case, you must specify the same cluster ID for these route reflectors to avoid routing loops.


Configuring BGP graceful restart (GR)

Perform the following configuration on the GR Restarter and GR Helper respectively.


[NOTE: ]

NOTE: A device can act as both the GR Restarter and GR Helper simultaneously.


Follow these steps to configure BGP GR.

To do... Use the command... Remarks
Enter the global Configuration context configuration  
Enable BGP, and enter its view bgp as-number  
Configure graceful restart bgp graceful-restart staleparth-time {stale-path-time} Required. Disabled by default.
Configure the maximum time allowed for the peer to reestablish a BGP session graceful-restart timer restart timer Optional. 120 seconds by default.
Configure the maximum time to wait for the End-of-RIB marker graceful-restart timer  

[NOTE: ]

NOTE: The maximum time allowed for the peer (the GR restarter) to reestablish a BGP session should be less than the Holdtime carried in the OPEN message.

The End-Of-RIB (End of Routing-Information-Base) indicates the end of route updates.