Configuring BGP Peers
Context
During the configuration of BGP peers, if the AS number of the specified peer is the same as the local AS number, an IBGP peer is configured. If the AS number of the specified peer is different from the local AS number, an EBGP peer is configured. To enhance the stability of BGP connections, you are advised to use the reachable loopback interface addresses to establish BGP connections.
When loopback interface addresses are used to establish a BGP connection, run the peer connect-interface command on both ends of the BGP connection to ensure the correctness of interfaces and addresses on the TCP connection. If the command is run on only one end, the BGP connection may fail to be established.
When loopback interface addresses are used to establish an EBGP connection, the peer ebgp-max-hop command with hop-count greater than or equal to 2 must be run. Otherwise, the EBGP connection cannot be established.
To perform the same configuration on a large number of peers, configure a BGP peer group according to (Optional) Configuring a BGP Peer Group to reduce the configuration workload.
Procedure
- Run system-view
The system view is displayed.
- Run bgp { as-number-plain | as-number-dot }
The BGP view is displayed.
- Run peer { ipv4-address | ipv6-address } as-number as-number
The BGP peer is created.
By default, no BGP peer is created.
- (Optional) Run peer ipv4-address connect-interface { interface-type interface-number [ ipv4-source-address ] | ipv4-source-address }
Or run peer ipv6-address connect-interface interface-type interface-number [ ipv6-source-address ]
A source interface and a source IP address are specified for the peer to establish a TCP connection.
By default, BGP uses the interface that is directly connected to the peer to establish a TCP connection.After peer connect-interface is configured for an EBGP peer, the supernet routes received from the EBGP peer are all in inactive state.
When an IP address of a loopback interface or a sub-interface is used to establish a BGP connection, run the peer connect-interface command at both ends of the connection to ensure that the connection is correctly established. If this command is run on only one end, the BGP connection may fail to be established.
- (Optional) Run peer { ipv4-address | ipv6–address | group-name } tcp-mss tcp-mss-number
The TCP MSS value used when the local device establishes TCP connections with a peer or peer group is configured.
You can run the peer tcp-mss command to configure a TCP MSS value used for TCP connection establishment so that it is used to encapsulate BGP packets when the path MTU is unavailable. Such configuration improves network performance.
- (Optional) Run peer { ipv4-address | ipv6-address } ebgp-max-hop [ hop-count ]
The maximum number of hops allowed for the establishment of an EBGP connection is set.
By default, the maximum number of hops allowed for an EBGP connection is 1. That is, an EBGP connection must be established on a directly connected physical link.
- (Optional) Run peer { ipv4-address | ipv6-address } description description-text
The description of the peer is configured.
If a BGP peer is configured on an IPv4 unicast network, steps 8 and 9 are not required. If a BGP peer is configured on an IPv4 multicast network and an IPv6 unicast network, steps 8 and 9 are required.
- (Optional) Run the following commands as required.
- Run ipv4-family multicast
The BGP-IPv4 multicast address family view is displayed.
- Run ipv6-family [ unicast ]
The BGP-IPv6 unicast address family view is displayed.
- Run ipv4-family multicast
- (Optional) Run peer { ipv4-address | ipv6-address } enable
MP-BGP is enabled on the BGP peers to configure them as MP-BGP peers.
- Run commit
The configuration is committed.