HCIP-IERS deployment of enterprise-level routing and switching network - BGP (Border Gateway Protocol) Border Gateway Protocol - Knowledge Points

Table of contents

BGP (Border Gateway Protocol) Border Gateway Protocol

BGP Knowledge Points

BGP router ID (Router ID)

How BGP works

BGP neighbor establishment status

Common three states Idle, Active, Established

BGP loop prevention mechanism

Configuring BGP load balancing


BGP (Border Gateway Protocol) Border Gateway Protocol

BGP Knowledge Points

BGP basic configuration, BGP 5 types of packets, 6 types of neighbor states, 4 categories and 10 types of attributes, IBGP EBGP (loopback physical interface) to establish neighbors, BGP authentication, fake-as, routing transfer principles, IBGP loop prevention , EBGP anti-loop, RR anti-loop, BGP route automatic aggregation, manual aggregation (detail-suppressed, suppress-policy, attribute-policy, origin-policy), BGP 5 community attributes, BGP route selection, BGP federation, route reflector , BGP route filtering, importing, and delegating the default route

Border Gateway Protocol BGP (Border Gateway Protocol) is an advanced path vector routing protocol that realizes the reachability of routes between autonomous systems AS (Autonomous System) and selects the best route.

The three early release versions are BGP-1 (RFC1105), BGP-2 (RFC1163) and BGP-3 (RFC1267), BGP-4 (RFC1771) was used in 1994, and the version used by unicast IPv4 networks after 2006 It is BGP-4 (RFC4271), and the version used by other networks (such as IPv6, etc.) is MP-BGP (RFC4760).

MP-BGP is an extension of BGP-4 to achieve the purpose of application in different networks. The original message mechanism and routing mechanism of BGP-4 have not changed. The application of MP-BGP on the IPv6 unicast network is called BGP4+, and the application of MP-BGP on the IPv4 multicast network is called MBGP (Multicast BGP).
To facilitate the management of a growing network, the network is divided into different autonomous systems. In 1982, the Exterior Gateway Protocol (EGP) was used to dynamically exchange routing information between ASs.

However, the design of EGP is relatively simple. It only publishes the routing information reachable by the network without optimizing the routing information. At the same time, it does not consider issues such as loop avoidance. It will soon fail to meet the requirements of network management.
BGP is another Exterior Gateway Protocol designed to replace the original EGP. Different from the original EGP, BGP can optimize routes, avoid routing loops, transmit routes more efficiently and maintain a large amount of routing information.

Although BGP is used to transmit routing information between ASs, not all ASs need to run BGP to transmit routing information. For example, on the egress of the data center connected to the Internet, in order to avoid the impact of massive Internet routes on the internal network of the data center, the device uses static routes instead of BGP to communicate with the external network.

BGP guarantees the security, flexibility, stability, reliability and efficiency of the network from many aspects:
1. BGP adopts authentication and GTSM to ensure the security of the network.
2. BGP provides rich routing strategies, which can flexibly select routes.
3. BGP provides route aggregation and route attenuation functions to prevent route oscillation and effectively improve network stability.
4. BGP uses TCP as its transport layer protocol (port number is 179), and supports the linkage between BGP and BFD, which improves the reliability of the network.

BGP is divided into EBGP (External/Exterior BGP) and IBGP (Internal/Interior BGP) according to the operation mode.
1. EBGP:
BGP running between different ASs is called EBGP. To prevent loops between ASs, when a BGP device receives a route sent by an EBGP peer, it discards the route with the local AS number.
2. IBGP:
BGP running inside the same AS is called IBGP. To prevent loops in the AS, the BGP device does not advertise routes learned from IBGP peers to other IBGP peers, and establishes full connections with all IBGP peers. In order to solve the problem of too many connections between IBGP peers, BGP designs route reflectors and BGP confederations (see below for details).
If a BGP device in an AS needs to transmit the route to other ASs through another BGP device after receiving a route sent by an EBGP neighbor, it is recommended to use IBGP.


BGP router ID (Router ID)

The BGP Router ID is a 32-bit value used to identify a BGP device, usually in the form of an IPv4 address, and carried in the Open packet sent when a BGP session is established.
When establishing a BGP session between peers, each BGP device must have a unique router ID; otherwise, BGP connections cannot be established between peers.
The router ID of BGP must be unique in the BGP network. It can be manually configured or automatically selected by the device.
By default, BGP selects the IPv4 address of the loopback interface on the device as the BGP router ID. If no loopback interface is configured on the device, the system will select the largest IPv4 address in the interface as the BGP router ID

How BGP works

There are mainly 5 types of messages, 6 types of state machines, 4 types of attributes, and 5 principles in the interactive process of establishing, updating, and deleting BGP peers.

BGP message
BGP peers interact through the following five types of messages, among which Keepalive messages are sent periodically, and other messages are sent triggered: 1.
Open message:
used to establish a BGP peer connection.
2. Update message:
used to exchange routing information between peers. Only the network in BGP will have the Update message
3. Notification (notification) message:
used to interrupt the BGP connection.
4. Keepalive message:
used to maintain the BGP connection.
5. Route-refresh (refresh) message:
used to request the peer to resend routing information after changing the routing policy. Only BGP devices that support the route-refresh capability will send and respond to this packet.
You can capture the route-refresh message
refresh bgp all import

reset BGP
reset bgp all

Modify the timer, the default is 60, 180
bgp 100
timer keepalive 5 hold 15


BGP neighbor establishment status

idle: the initial state
connect: BGP waits for the establishment of the TCP connection
active: the TCP connection fails, and the TCP connection is re-established
opensent: the TCP is established successfully, and an open packet is sent
openconfirm: the correct OPEN packet is received
established: the BGP neighbor is successfully established

1. The Idle state is the initial state of BGP.
In the Idle state, BGP rejects connection requests sent by neighbors. Only after receiving the Start event of this device, BGP starts to try to establish TCP connections with other BGP peers, and turns to the Connect (connection) state. The Start event is caused by an operator configuring a BGP process, or resetting an existing process, or by router software resetting a BGP process.
After receiving Error events such as Notification (notification) messages or TCP link disconnection notifications in any state, BGP will transfer to the Idle state.
 
2. In the Connect state, BGP starts the connection retransmission timer (Connect Retry) and waits for TCP to complete the connection.
If the TCP connection is successful, BGP sends an Open message to the peer and goes to the OpenSent state.
If the TCP connection fails, then BGP goes to the Active state.
If the connection retransmission timer expires and BGP still does not receive a response from the BGP peer, then BGP will continue to try to establish TCP connections with other BGP peers and stay in the Connect state.
 
3. In the Active state, BGP is always trying to establish a TCP connection.
If the TCP connection is successful, BGP sends an Open message to the peer, closes the connection retransmission timer, and turns to the OpenSent state.
If the TCP connection fails, then BGP stays in the Active state.
If the connection retransmission timer expires and BGP still does not receive a response from the BGP peer, then BGP turns to the Connect state.
 
4. In the OpenSent state, BGP waits for the peer's Open message, and checks the AS number, version number, authentication code, etc. in the received Open message.
If the received Open message is correct, BGP sends a Keepalive message and turns to the OpenConfirm state.
If it is found that the received Open message is wrong, BGP sends a Notification message to the peer and turns to the Idle state.
 
5. In the OpenConfirm state, BGP waits for the Keepalive or Notification message. If it receives a Keepalive message, it goes to the Established state, and if it receives a Notification message, it goes to the Idle state.
 
6. In the Established state, BGP can exchange Update, Keepalive, Route-refresh messages and Notification messages with peers.
If a correct Update or Keepalive message is received, BGP considers the peer end to be in normal operation and will maintain the BGP connection.
If an incorrect Update or Keepalive message is received, BGP sends a Notification message to notify the peer, and turns to the Idle state.
Route-refresh packets will not change the BGP state.
If the Notification message is received, BGP will go to the Idle state.
If a TCP disconnection notification is received, BGP disconnects and goes to the Idle state.

Common three states Idle, Active, Established

Interaction principles between BGP peers

The BGP device adds the optimal route to the BGP routing table to form a BGP route.
After a BGP device establishes a neighbor relationship with a peer, it adopts the following interaction principles:

1. The BGP route obtained from an IBGP peer is only advertised to its EBGP peer by a BGP device.
2. The BGP route obtained from the EBGP peer, the BGP device advertises to all its EBGP and IBGP peers.
3. When there are multiple effective routes to the same destination address, the BGP device only advertises the optimal route to the peer.
4. When the route is updated, the BGP device only sends the updated BGP route.
5. The BGP device will receive the routes sent by all peers.

BGP attribute
4 types of attributes, 10 types

Atomtic_aggregate is a recognized optional attribute, which is only equivalent to an early warning flag, and does not carry any information. When a router receives a BGP route update and finds that the route carries the Atomtic_aggregate attribute, it knows that the path attribute of this route may be lost. At this time, when the router advertises this route to other peers, it needs to keep Atomtic_aggregate property of the route. In addition, if the router that receives the route update fails, the route will be specified again.

Aggregator is an optional transitional attribute used to mark which AS and which BGP router the route summarization takes place on.

BGP loop prevention mechanism

IBGP loop prevention:
Route entries received by a router from one of its BGP peers will not pass the router to other IBGP peers. This principle is called BGP split horizon

Anti-loop of the route reflector: Originator_id, Cluster_list
Originator_id is an optional non-transitional attribute, generated by RR, encapsulated in the Update message, using the value of router-id to identify the originator of the route, and used to prevent routing loops in the cluster.
Cluster_list is an optional non-transition attribute, which records the Cluster_id of each cluster that the route passes through, and is used to avoid loops between clusters.

EBGP loop prevention:
When a router receives a BGP route from an EBGP neighbor, if the AS_Path of the route contains its own AS number, the route will be discarded directly.

=========

BGP is the core routing protocol currently running on the Internet backbone network, and it is also one of the most widely deployed routing protocols. In the past few decades, the rapid development of the Internet and the continuous emergence of new applications have put forward higher requirements for the reliability and scalability of the Internet network. As the basis for the stable operation of the entire Internet, BGP has introduced many advanced features in order to adapt to the development trend of the Internet.

fake-as

RTB:
bgp 2000
peer 1.1.1.1 fake-as 200

==========

Configuring BGP load balancing

In a large network, there are usually multiple valid routes to the same destination, but BGP only advertises the optimal route to peers, which often causes a lot of unbalanced traffic loads. By configuring BGP load balancing, traffic load can be balanced to reduce network congestion.
Generally, only when the first eight attributes described in "BGP route selection policy" are identical, can BGP routes be equivalent to each other and implement BGP load balancing.

bgp 100
maximum load-balancing 2

After the configuration is complete, check the global ip routing table.
There are two next entries for the same BGP routing entry.

In the BGP routing table, still only one entry is preferred

Guess you like

Origin blog.csdn.net/weixin_57099902/article/details/132467892