BGP principle and application scenarios

Preface

In small networks, ospf and rip are sufficient for the number and distance of devices, but they are not enough for operators, and the BGP protocol was born. BGP is mainly used by operators and used in large-scale networks. This chapter will discuss its principles.

1. What is BGP?

Border Gateway Protocol (BGP) is an autonomous system routing protocol running on TCP. BGP is the only protocol used to handle networks the size of the Internet, and it is also the only protocol that can properly handle multiple connections between unrelated routing domains. BGP is built on the experience of EGP. The main function of the BGP system is to exchange network reachability information with other BGP systems. The network reachability information includes the listed autonomous system (AS) information. This information effectively constructs the topological map of AS interconnection and thus eliminates routing loops. At the same time, policy decisions can be implemented at the AS level.
The new version of BGP-4 was released in 1995.
Four types of packets are used in the implementation of the BGP routing protocol: open packets, update packets, keepalive packets, and notification packets.

2. Features

1. BGP features

BGP is an external or inter-domain routing protocol. The main goal of BGP is to provide guarantee for "routing information communication" between routers in different autonomous systems (AS).

BGP has no restrictions on the network topology, and its features include:

1. Realize the communication between autonomous systems (AS) and disseminate the reachable information of the network. BGP is an exterior gateway protocol that allows one autonomous system (AS) to communicate with another autonomous system (AS). BGP allows an autonomous system (AS) to advertise the reachability information of its internal network to other autonomous systems (AS), or routing information of other networks reachable through the autonomous system (AS). At the same time, the autonomous system (AS) can also learn this information from another autonomous system (AS). What BGP provides for each destination network is "next-hop node" information.

2. Coordination among multiple BGP routers. If multiple routers in an autonomous system (AS) use BGP to communicate with peer routers in other autonomous systems (AS), BGP can coordinate a series of routers so that these routers maintain the consistency of routing information.

3. BGP supports strategy-based routing. The general distance vector routing protocol will accurately advertise the routes in the local routing; while BGP can implement the strategy selected by the local administrator. BGP routers can configure different strategies for "intra-domain" and "inter-domain" network reachability.

4. Reliable transmission. The transmission of BGP routing information uses a reliable TCP (Transmission Control Protocol) protocol.

5. Path information. When BGP announces the reachability information of the destination network, in addition to processing the next hop information of the specified destination network, the announcement also includes a "path vector", that is, the autonomous system that needs to pass through to the destination network (AS) list, so that the recipient can understand the path information to the destination network.

6. Incremental update. BGP does not need to transmit complete routing database information in all routing update messages, but only needs to exchange complete information once at startup. Subsequent routing update messages only advertise network changes. This kind of network change information is called delta.

7. Route aggregation. BGP allows the sender to aggregate routing information and use one "entry" to indicate multiple related destination networks to save network bandwidth.

8. BGP also allows the receiver to authenticate and authenticate the message to verify the identity of the sender.

2. Classification

BGP is divided into EBGP (External/Exterior BGP) and IBGP (Internal/Interior BGP) according to its operation mode.

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 in 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

3 working principle

There are mainly five types of messages, six state machines, and nine principles in the interaction process of BGP peer establishment, update, and deletion.
Five types of messages
1. Open messages are used for peer parameter negotiation;

2. Keepalive messages are used to maintain peer neighbors;

3. The Update message is used to advertise reachable and unreachable routes;

4. Notification messages are used for error information notification and disconnect peer neighbors;

5. The Route-refresh message is used to request the peer to resend routing information;

All BGP packets are sent in unicast mode. Therefore, you need to manually specify the peer. It cannot automatically discover neighbors through multicast like the IGP protocol.

BGP does not need to develop confirmation messages, and provides retransmission, confirmation, and ordering functions through TCP. Therefore, a TCP connection must be established before establishing a BGP peer.
Six state machines
Idle (idle):
Idle is the first state of the BGP connection. In the idle state, BGP is waiting for a startup event. After the startup event occurs, BGP initializes resources and resets the bai connection retry timer (Connect-Retry). ), initiate a TCP connection and switch to the Connect state at the same time.

Connect:
In the Connect state, BGP initiates the first TCP connection. If the Connect-Retry timer expires, it re-initiates the TCP connection and continues to remain in the Connect state. If the TCP connection is successful, it will transfer Enter the OpenSent state. If the TCP connection fails, it will enter the Active state.

Active:
In the Active state, BGP is always trying to establish a TCP connection. If the Connect-Retry timer expires, it will return to the Connect state. If the TCP connection is successful, it will switch to the OpenSent state. If the connection fails, it will continue to remain in the Active state and continue to initiate a TCP connection.

OpenSent (open message has been sent):
In the OpenSent state, the TCP connection has been established, and BGP has sent the first Open message. For the rest, BGP is waiting for its peer to send the Open message. And check the correctness of the received Open message. If there is an error, the system will send an error notification message and return to the Idle state. If there is no error, BGP will start to send Keepalive messages, reset the Keepalive timer, and start Timing. At the same time, it enters the OpenConfirm state.

OpenConfirm (open message confirmation) state:
In the OpenConfirm state, BGP sends a Keepalive message and resets the hold timer at the same time. If a Keepalive message is received, it enters the Established phase and the BGP neighbor relationship is established. If the TCP connection is interrupted, it returns to the Idle state.

Established:
In the Established state, the BGP neighbor relationship has been established. At this time, BGP will exchange Update messages with its neighbors and reset the hold timer.
Nine principles

4 configuration

Since BGP is a protocol used in large networks, it is simply simulated on the way
Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_49172531/article/details/112756551