Home Search Center Intelligent Model Selection IP Encyclopedia

What Is BGP?

BGP is a routing protocol used to exchange network layer reachability information (NLRI) between routing domains. Such domains are often called ASs because different administrative organizations control their own routing domains. Currently, the Internet is a large-scale network consisting of multiple interconnected ASs. As an external routing protocol on the Internet, BGP is widely used between Internet service providers (ISPs).
It exchanges reachable routing information between ASs, establishes inter-AS paths, prevents routing loops, and applies routing policies between ASs. BGP has three earlier versions: BGP-1, BGP-2, and BGP-3. The currently used version is BGP-4.

Why Do We Need BGP?

Interior Gateway Protocols (IGPs) are designed to provide reachability information within a single routing domain rather than between such domains. Consequently, BGP emerged and was developed as a suitable inter-domain routing protocol.

The following types of IGPs are usually used on networks:

  • Distance-vector protocols, such as the Routing Information Protocol (RIP)
  • Link state protocols, such as Open Shortest Path First (OSPF) and Intermediate System to Intermediate System (IS-IS)

Although these protocols are designed for different purposes and have different behavior characteristics, they are all used to provide an optimal path within a routing domain, making them unsuitable for inter-domain routing. For example, an inter-domain routing protocol should be able to provide extensive policy control because different domains usually require different routing policies and management policies.

BGP is designed as an inter-domain routing protocol with the goal of policy control and scalability. However, BGP cannot replace IGP because they apply to different scenarios.

BGP is called Internal BGP (IBGP) when it runs within an AS and is called External BGP (EBGP) when it runs between ASs, as shown in Figure 1.

BGP operating modes
BGP operating modes

How Does BGP Work?

Roles in BGP Message Exchange

Speaker: A routing device that sends BGP messages is called a BGP speaker. The speaker receives or generates new routing information, and then advertises the routing information to other BGP speakers. After receiving a route from another AS, the BGP speaker compares the route with its local routes. If the route is better than its local routes or is new, the speaker advertises it to all other BGP speakers except the one that advertised the route.

Peer: BGP speakers that exchange messages with each other are called peers.

BGP Messages

BGP runs by sending five types of messages: Open, Update, Notification, Keepalive, and Route-refresh.

  • Open: It is the first message sent after a TCP connection is set up. This type of message is used to set up a BGP peer relationship. After a peer receives an Open message and the negotiation between the local device and peer succeeds, the peer sends a Keepalive message to confirm and maintain the peer relationship. Then, the peers can exchange Update, Notification, Keepalive, and Route-refresh messages.

  • Update: This type of message is used to exchange routing information between peers. An Update message can advertise multiple reachable routes with the same attributes and can also be used to delete multiple unreachable routes.

  • Notification: If BGP detects an error, it sends a Notification message to its peers. The BGP connections are then torn down immediately.

  • Keepalive: BGP periodically sends Keepalive messages to peers to ensure the validity of BGP connections.

  • Route-refresh: This type of message is used to request that peers re-send all reachable routes to the local device.

BGP Processing

Because BGP uses TCP as the transport layer protocol, peers must first establish a TCP connection before they can establish a BGP peer relationship. Then, to establish a BGP peer relationship, the peers negotiate parameters by exchanging Open messages. After the peer relationship is established, BGP peers exchange BGP routing tables. BGP sends Keepalive messages to maintain BGP connections between peers. It does not periodically update routing tables, but updates them incrementally through Update messages when BGP routes change. If BGP detects an error (for example, it receives an error message), it sends a Notification message to report the error, and the BGP connection is torn down accordingly. Figure 1 shows the process of establishing a peer relationship.

Peer relationship establishment process
Peer relationship establishment process

BGP Finite State Machine

The BGP Finite State Machine (FSM) has six states: Idle, Connect, Active, Open-Sent, Open-Confirm, and Established.

Among them, Idle, Active, and Established are common states during the establishment of BGP peer relationships.

  • In the Idle state, BGP denies all connection requests. Idle is the initial state of BGP.

  • In the Connect state, BGP decides subsequent operations after a TCP connection is established.

  • In the Active state, BGP attempts to establish a TCP connection. Active is an intermediate state of BGP.

  • In the Open-Sent state, BGP waits for an Open message from a peer.

  • In the Open-Confirm state, BGP waits for a Notification or Keepalive message.

  • In the Established state, BGP peers can exchange Update, Route-refresh, Keepalive, and Notification messages.

A BGP peer relationship can be established only when both BGP peers are in the Established state. Both peers send Update messages to exchange routing information.

BGP Attributes

BGP attributes (also called BGP route attributes) are a set of parameters that describe specific BGP routes, and BGP can filter and select routes based on these attributes. BGP route attributes are classified into four types:

  • Well-known mandatory: This type of attribute can be identified by all BGP devices and must be carried in Update messages. Without this attribute, errors occur in routing information.

  • Well-known discretionary: This type of attribute can be identified by all BGP routers. It is optional and, therefore, is not necessarily carried in Update messages.

  • Optional transitive: This indicates the transitive attribute between ASs. Even if a BGP device does not support this type of attribute, the device will still receive messages carrying it and advertise such messages to other peers.

  • Optional non-transitive: If a BGP device does not support this type of attribute, the device ignores it and does not advertise messages carrying it to other peers.

Some common BGP route attributes are as follows:

  • Origin is a well-known mandatory attribute. It defines the origin of path information and identifies how a route becomes a BGP route. The Origin attribute value can be IGP, EGP, or Incomplete.

  • AS_Path is a well-known mandatory attribute. It records the numbers of all ASs through which a route passes from the local end to the destination in the vector order.

  • Next_Hop is a well-known mandatory attribute.

  • Multi-Exit-Discriminator (MED) is an optional non-transitive attribute. It is transmitted only between two neighboring ASs. The AS that receives the MED attribute will not advertise it to any third AS.

  • Local_Pref is a well-known discretionary attribute that indicates the preference of a BGP route on a routing device. It is valid only between IBGP peers and is not advertised to other ASs.

How Does BGP Process Routes?

The following figure shows how BGP processes routes. BGP routes can be imported from other protocols or learned from BGP peers. BGP route summarization can be configured to reduce the size of routing tables. In addition, routing policies can be configured and apply to route import, receipt, or advertisement in order to filter routes or modify route attributes.

BGP route processing
BGP route processing

Route Import

BGP itself cannot discover routes. Therefore, it needs to import routes from other routing protocols, such as IGP routes or static routes, and then store them in the BGP routing table. Imported routes can be transmitted within an AS or between ASs.

BGP can import routes in either Import or Network mode. The Import mode enables BGP to import routes by protocol type, such as RIP, OSPF, IS-IS, static, and direct routes. The Network mode imports a route with the specified prefix and mask into the BGP routing table, and is more precise than the Import mode.

Route Selection

When multiple routes to the same destination are available, BGP selects routes using routing policies. For example, BGP prefers routes that do not recurse to an SRv6 TE Policy in the Graceful Down state (the SRv6 TE Policy is in the delayed deletion state), routes in descending order of Valid, Not Found, and Invalid after BGP origin AS validation results are applied to route selection in scenarios where the device is connected to a Resource Public Key Infrastructure (RPKI) server, and routes without bit errors.

Route Summarization

The size of the BGP routing table typically increases as the scale of a network grows. To reduce the size, route summarization can be used.

Route summarization summarizes multiple routes into a summary route. After route summarization, BGP advertises to BGP peers only the summary route rather than all the specific routes.

BGP supports two types of route summarization:
  • Automatic summarization: takes effect on the routes imported by BGP. After automatic summarization is configured, the specific routes that participate in summarization are suppressed. BGP summarizes routes by natural network segment (for example, routes 10.1.1.1/32 and 10.2.1.1/32 are summarized into 10.0.0.0/8, which is a Class A address) and then sends only the summary route to BGP peers.
  • Manual summarization: takes effect on the local BGP routes. Manual summarization enables you to control the attributes of the summary route and determine whether the device advertises specific routes.

IPv4 supports both automatic and manual summarization, whereas IPv6 supports only manual summarization.

BGP Route Advertisement

BGP adopts the following policies to advertise routes:
  • When there are multiple valid routes, a BGP speaker advertises only the optimal route to its peers.
  • A BGP speaker advertises the routes learned from EBGP peers to other BGP peers, including EBGP peers and IBGP peers.
  • A BGP speaker does not advertise the routes learned from an IBGP peer to other IBGP peers.
  • Whether a BGP speaker advertises the routes obtained from an IBGP peer to its EBGP peers depends on the BGP-IGP synchronization state.
  • Once a connection is established, a BGP speaker advertises to the new peer the optimal BGP routes that can be advertised.

What Extensions Does BGP Support?

BGP-4 manages only IPv4 unicast routing information, and has limited functions in applications using other network layer protocols, such as IPv6 and multicast protocols.

To support multiple types of network layer protocols, the Internet Engineering Task Force (IETF) defined Multi-protocol Extensions for Border Gateway Protocol (MP-BGP), extending BGP-4. MP-BGP enables routers supporting BGP extension to communicate with routers that do not support BGP extension.

As an enhancement of BGP-4, MP-BGP provides routing information for various protocols, such as IPv6 (BGP4+) and multicast.

  • MP-BGP maintains both unicast and multicast routing information. It stores the information in different routing tables to separate unicast routing information from multicast routing information.
  • MP-BGP supports unicast and multicast, and constructs different network topologies for them.
  • Most unicast routing policies and configuration methods supported by BGP-4 can be applied to multicast, and unicast and multicast routes can be maintained according to these routing policies.

BGP uses address families to distinguish different network layer protocols. For the values of address families, see relevant standards. MP-BGP supports multiple extensions, such as those for VPN and for IPv6, each of which is configured in its corresponding address family view.

  • The BGP-IPv4 unicast address family maintains public network BGP peers and transmits public network IPv4 routing information. It also transmits public network labeled IPv4 routes. This function is mainly used in inter-AS BGP/MPLS IP VPN Option C or inter-AS BGP/MPLS IPv6 VPN Option C scenarios.
  • The BGP-IPv6 unicast address family maintains public network IPv6 BGP peers and transmits public network IPv6 routing information. It also transmits labeled IPv6 routes in 6PE scenarios.
  • Multicast-related address family views, such as the BGP-IPv4 multicast address family view, BGP-MVPN address family view, BGP-IPv6 MVPN address family view, and BGP-MDT address family view, can transmit inter-AS routing information. These views are mainly applied to MBGP, BIER, NG MVPN, BIERv6, and Rosen MVPN.
  • VPN-related address family views, such as the BGP-VPNv4 address family view, BGP-VPNv6 address family view, BGP-VPN instance view, BGP multi-instance VPN instance view, BGP-L2VPN-AD address family view, and BGP-L2VPN-AD address family view, are mainly applied to BGP/MPLS IP VPN, VPWS, and VPLS.
  • Address family views related to Ethernet Virtual Private Network (EVPN), such as the BGP-EVPN address family view and BGP multi-instance EVPN address family view, are mainly used to configure BGP EVPN peers. These views apply to EVPN VPLS, EVPN VPWS, and EVPN L3VPN. EVPN, a VPN technology used for Layer 2 network interworking, is similar to BGP/MPLS IP VPN. It employs a new type of NLRI, EVPN NLRI, which defines new types of BGP EVPN routes to implement MAC address learning and advertisement between different sites on a Layer 2 network.
  • The BGP IPv4 SR Policy address family view and BGP IPv6 SR Policy address family view are mainly applied to Segment Routing MPLS (SR-MPLS) and Segment Routing IPv6 (SRv6).
  • Flow-related address family views, such as the BGP-Flow address family view, BGP-Flow VPNv4 address family view, BGP-Flow VPNv6 address family view, BGP-Flow VPN instance IPv4 address family view, and BGP-Flow VPN instance IPv6 address family view, are mainly used to defend against DoS/DDoS attacks. These views help improve network security and availability.
  • The BGP-labeled address family view and BGP-labeled-VPN instance IPv4 address family view are mainly used for carrier configuration using the BGP label distribution solution.
  • The BGP-LS address family view is mainly used to summarize the topology information collected using IGP and send the information to the upper-layer controller.
About This Topic
  • Author: Wang Shishi
  • Updated on: 2023-07-20
  • Views: 4774
  • Average rating:
Share link to