Understanding of BGP

BGP exterior gateway protocol

BGP is a distance vector routing protocol that realizes the reachability of routes between ASs in autonomous systems and selects the best route.

table of Contents

BGP exterior gateway protocol

Autonomous System AS

AS number

Features of BGP

Classification of BGP

How BGP works

Five types of messages

Six state machines

Peer Interaction Principle

BGP path attributes

BGP path selection

Principles of path selection

Path selection method


Autonomous System AS

Autonomous system AS refers to a collection of routes managed by the same technical management organization and using a unified routing strategy.

AS number

Each AS in the BGP network is assigned a unique AS number, which is used to distinguish different ASs. The AS number is divided into a 2-byte AS number and a 4-byte AS number. The 2-byte AS number ranges from 1 to 65535, where 1 to 64511 are public AS numbers registered on the Internet, similar to public IP addresses; 64512 ~ 65535 is a private AS number, similar to a private network address. IANA (Internet Number Distribution Agency) is responsible for the distribution of AS numbers.

Features of BGP

  1. BGP can carry large quantities of routing information and can support large-scale networks.
  2. BGP has used TCP as its transport layer protocol (port number 179) to improve reliability.
  3. BGP is an external routing protocol used to transfer data between ASs and has very high requirements for stability. Therefore, the reliability of the TCP protocol ensures the stability of BGP.
  4. The BGP peers must be logically connected and have a TCP connection. The destination port is 179 and the local port is arbitrary.
  5. BGP peers are different from IGP peers. BGP peers refer to the two ends that use TCP to establish a connection, rather than directly connected neighbors with the same concept as IGP. Only TCP can establish a connection, not necessarily Direct connection.
  6. BGP itself is only responsible for controlling routing, and data forwarding still relies on static or IGP routing.
  7. BGP supports CIDR for classless inter-domain routing.
  8. When routing updates, BGP only sends updated routes, which greatly reduces the bandwidth occupied by BGP to propagate routes, and is suitable for propagating a large amount of routing information on the Internet.
  9. BGP is an enhanced distance vector routing protocol, which avoids loops by design.
  10. Between ASs: BGP passes the AS that carries the AS Path information to mark the route, and the route with the local AS number will be discarded, thereby avoiding loops between domains.
  11. Inside the AS: The routes learned by BGP in the AS will not be advertised to BGP neighbors in the AS to avoid loops in the AS.
  12. BGP provides a wealth of routing strategies, which can implement flexible filtering and selection of routes.
  13. BGP provides a mechanism to prevent route oscillations (route attenuation), which effectively improves the stability of the Internet network.
  14. BGP is easy to expand and can adapt to new developments in the network. Mainly expand through TLV.

Classification of BGP

According to the operation mode, it is divided into EBGP and IBGP.

 EBGP: BGP running between different ASs is called EBGP. To prevent loops between ASs, when a BGP device receives routes sent by EBGP peers, it discards the routes with the local AS number.

 IBGP: BGP running in the same AS is called IBGP. To prevent loops within the AS, BGP devices do not advertise routes learned from IBGP peers to other IBGP peers, and establish full connections with all IBGP peers. In order to solve the problem of too many connections between IBGP peers, BGP designed a route reflector and BGP alliance.

How BGP works

Five types of messages

 1. Open message: is the first message sent by TCP to establish a connection

Negotiate various parameters of BGP peers, including information such as version and AS number, and establish BGP peer connections.

 2. Update message: exchange routing information between peers.

After the connection is established, when a route needs to be sent or the route changes, an Update message is sent to notify the peer end to reach or withdraw the routing information and path.

 3. Notification message: used to interrupt the BGP connection.

When BGP finds an error, it sends a message to notify the BGP peer, and then the neighbors related to it will be closed.

4. Keepalive packets: used to maintain BGP connections.

Keepalive messages are sent regularly to keep the BGP peer relationship effective and respond to correct Open messages.

 5. Route-refresh message: used to soft reset the BGP routing table after changing the routing policy to request the peer to resend routing information. Only BGP devices that support Route-refresh capability will send and respond to this message.

Six state machines

  1. Idle status
  2. Conenect status
  3. Active state
  4. OpenSent status
  5. OpenConfirm status
  6. Established state

 

Peer Interaction Principle

  1. The BGP route obtained from the peer is only passed by the BGP device to its EBGP peer
  2. The BGP route obtained from the EBGP peer is passed by the BGP device to all its EBGP and IBGP peers (the peer can only transmit one hop if the peer is IBGP, and there is no restriction if the peer is EBGP)
  3. When there are multiple valid routes to the same destination address, the BGP device only advertises the optimal route to the peer
  4. When routing updates, BGP devices only send updated BGP routes
  5. BGP devices will receive the routes sent by all peers
  6. All IBGP peers remain unchanged at the next hop of delivery
  7. The next hop of all EBGP peers changes during transmission
  8. The default TTL value for EBGP transmission is 1
  9. The default TTL value is 255 for IBGP transmission

BGP path attributes

Recognized attributes

 Recognized and obeyed: All BGP devices can recognize this type of attribute, and it must be present in the Update message.

 Recognized and consciously: All BGP devices can recognize such attributes, but they are not required to exist in Update messages.

Optional attributes

 Optional delivery: The BGP device may not recognize this type of attribute. If the BGP device does not recognize this type of attribute, it will still receive this type of attribute and advertise it to other peers.

 Optional non-transitive: The BGP device may not recognize this type of attribute. If the BGP device does not recognize this type of attribute, the attribute will be ignored and will not be advertised to other peers.

BGP path selection

Principles of path selection

  1. If the next hop of this route is unreachable, ignore this route
  2. The route with a large Preferred_value is preferred
  3. Routes with high Local_preference value take precedence
  4. Aggregated routes take precedence over non-aggregated routes
  5. Local manually aggregated routes have higher priority than local automatically aggregated routes
  6. The priority of the routes imported by the local network command is higher than that of the routes imported by the import-route command.
  7. The path with the shortest length of As_path takes precedence
  8. Comparing the origin attribute, IGP takes precedence over EGP, and EGP takes precedence over Incomplete
  9. Choose a route with a smaller MED
  10. EBGP route priority and IBGP
  11. BGP preferentially selects the path with the lowest IGP metric to the next hop of BGP
  12. When the above are all the same, it is an equal-cost route, which can be load-shared (As_path must be the same. For load-sharing, the following three items are invalid)
  13. Compare the length of the Cluster_List, the shorter one takes precedence
  14. Compare Originator_ID (if not, compare Router-ID), choose a smaller path
  15. Compare the IP of the peer and choose a smaller path

Path selection method

  1. Control routing according to Local_preference (the bigger the better)
  2. Use the As_path attribute to control routing (the less the better)
  3. Control routing through MED attributes (the smaller the better)

Guess you like

Origin blog.csdn.net/Alen686/article/details/113667288
BGP