Knowledge of BPG Border Gateway Protocol (1)

Dynamic routing protocol

According to the autonomous system, it is divided into the
IGB internal gateway protocol. The routing protocol running in the AS mainly solves the selection problem within the AS. It is found that the routing calculation
mainly includes: RIP1/2, OSPF, ISIS, EIGRP

EBG external gateway routing protocol, a routing protocol running between AS and AS, to solve the problem of choosing between ASs.
Mainly include: BGP

Classified by protocol type
Distance vector routing protocol: RIP1/2, BGP path vector protocol, EIGRP advanced distance vector protocol
Routers do not fully understand the topology of the entire network

Link state routing protocol: OSPF, ISIS
routers have a complete understanding of the whole network topology

Basic concepts of BGP

BGP (Border Gatway protocol) is a distance vector routing protocol that realizes the reachability of routes between ASs and selects the best route.
AS refers to a collection of some routers that are managed by the same technical management organization and uses a unified routing strategy.
Each AS in the BGP network is assigned a unique AS number to distinguish different ASs. The
AS number is divided into 2 characters. Section AS number and 4-byte AS number. The 2-byte AS number ranges from 1 to 65535, and 1-64511 is a publicly registered AS number on the Internet, similar to a public IP address. 64512-65535 are private AS numbers, similar to private IP addresses. The 4-byte AS number ranges from 1 to 4294967295. Devices that support 4-byte AS numbers can be compatible with devices that support 2-byte AS numbers.
TANA is an Internet digital distribution Agency, responsible for the distribution of AS numbers

Features of BGP routing protocol

1. BGP can carry large quantities of routing information and can support large-scale networks.
2. BGP can use TCP as its transport layer protocol and monitor port 179, which improves the reliability of the protocol.
3. BGP is an external routing protocol used in AS Data transfer between the two requires high stability. Therefore, the high reliability of the TCP protocol is used to ensure the stability of the BGP protocol.
4. The BGP peers must be logically connected and have a TCP connection. The destination port number is 179, the local port number is arbitrary
5. BGP peers are different from IGP peers. BGP peers refer to the two ends of the connection that use TCP instead of directly connected neighbors with the same concept as IGP, as long as TCP can Establishing a connection does not necessarily require a direct connection.
6. BGP itself is only responsible for routing control, data forwarding still relies on static or IGP routing
7. BPG supports classless inter-domain routing CIDR
8. When routing updates, BGP only sends updated routes, which greatly reduces The bandwidth occupied by BGP propagation routes is suitable for the propagation of a large amount of routing information on the Internet.
9. BGP is an enhanced vector routing protocol, which is designed to avoid loops.
10. Between ASs, BGP carries AS -Path information marks the path of the AS, and the route with the local AS number will be discarded, thus avoiding loops between domains.
11. AS internal: The routes learned by BGP in the AS will not be advertised to the neighbors in the AS. To generate loops in the AS.
12. BGP provides a wealth of routing strategies, which can achieve flexible filtering and selection of
routes. 13. BGP provides a mechanism to prevent routing oscillations (route attenuation), which effectively improves the stability of the Internet network.
14. BGP It is easy to expand and can adapt to the new development of the network (ipv4 single/multicast, vpv4 single/multicast). Mainly through TLV expansion

BGP classification

BGP is divided into EBGP and IBGP according to the operation mode

EBGP—BGP running between different ASs is called EBGP. In order to prevent loops between ASs, when the BGP device accepts routes sent by EBGP peers, it discards the routes with the local AS number

IBGP—BGP running in the same AS is called EBGP. In order to prevent loops in the AS, the BGP device does not advertise the routes learned from IBGP peers to other IBGP peers, and establishes all IBGP peers Connection, in order to solve the problem of too many connections of IBGP peers, BGP designed route reflector and BGP alliance

Election of BGP router number Router-ID

●BGP router-id is a 32-bit value used to identify a BGP device, usually in the form of an IPV4 address. It is carried in the open message sent when a BGP session is established. When a BGP session is established between peers, each BGP devices 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 configured manually or the device can be automatically elected. Save time, ●BGP selects the IPV4 address of the LOOPBACK interface on the device as the router-id of BGP. If the loop back interface is not configured on the device, the system will select the largest IP4 address in the interface as the router-id of BGP. If the router-id is output, unless an event such as interface address deletion occurs, the original router-id will remain even if a larger address is configured

IBGP split horizon rules

1. The loop prevention of BGP routes between ASs depends on the AS-PATH path attribute. When the router receives the BGP route and finds that its own AS number appears in the AS-PATH attribute carried by the route, the router considers it If there is a routing loop, it will ignore the route.
2. The AS-path attribute will only be changed when the route leaves the AS, while the BGP route is transmitted within the AS, the AS-path attribute value of the route will not change. In this way, the loop prevention of IBGP routes cannot rely on the AS-path.
3. In order to prevent loops in the transmission of BGP routes within the AS, BGP requires that routers cannot pass the routes learned from IBGP peers to others. IBGP peers, this is the IBGP split horizon rule
4. Because of the existence of the IBGP split horizon principle, BGP requires the AS to ensure the full interconnection of IBGP peer relationships, because only in this way can it be ensured that every router can learn routes

How BGP works

BGP peers interact through the following five types of messages. Among them, keep alive messages are sent periodically, and the rest are triggered messages.
●Open messages: used to negotiate various parameters of BGP peers. It mainly includes BGP version (V4), AS number and other information, and establishes BGP peer connection. Open is the first message sent after the TCP connection is established

●Update message: used to exchange routing information between peers.
After the connection is established, when a route needs to be sent or the route changes, an Update is sent to notify the peer end to be reachable or to withdraw the route information and path attributes.

●Notification message: used to interrupt BGP connection.
When BGP finds an error during operation, it sends a Notification message to notify the BGP peer, and then the neighbor relationship related to it will be closed.

●Keepalive packets: used to maintain BGP connections.
Keepalive packets are sent regularly to maintain the validity of the BGP peer relationship. Respond to the correct Open message received

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

BGP six states

There are 6 state machines in the interaction process of BGP peers: Idle, Connect, Active, Open message sent (OpenSent), Open message confirmed (OpenConfirm) and connection established (Established).
In the process of BGP peer establishment, the three states that are usually visible are: Idle, Active, and Established.

① 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 a TCP connection with other BGP peers and transfer to the Connect state.

② In the Connect state, BGP starts the Connect Retry timer and waits for TCP to complete the connection.
●If the TCP connection is successful, then BGP sends an Open message to the peer and transfers to the OpenSent state.
●If the TCP connection fails, then BGP switches to the Active state and tries to connect repeatedly.
●If the connection retransmission timer expires and BGP still does not receive a response from the BGP peer, then BGP continues to try to establish TCP connections with other BGP peers and stays in the Connect state.

③ 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 transfers 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 will switch to the Connect state.

④ In the OpenSent state, BGP waits for the Open message from the peer, and checks the AS number, version number, authentication code, etc. in the received Open message.
●If the received Open message is correct, then BGP sends a Keepalive message and transfers to the OpenConfirm state.
●If an error is found in the 0pen message received, BGP sends a Notification message to the peer and transfers to the Idle state.

⑤ In the OpenConfirm state, BGP waits for Keepalive or Notification messages.
●If a Keepalive message is received, it will go to the Established state.
● If a Notification message will be received, it will go to the Idle state.

⑥ In the Established state, BGP can exchange Update, Keepalive, Route-refresh and Notification messages with its peers.
●If the correct Update or Keepalive message is received, then BGP considers that the opposite end is in a normal operating state and will maintain the BGP connection.
●If an incorrect Update or Keepalive message is received, BGP sends a Notification message to notify the opposite end, and transfers to the Idle state.
●If a Notification message is received, then BGP transfers to the Idle state.
●If the TCP disconnect notification is received, then BGP disconnects and transfers to the Idle state.
●Route-refresh messages will not change the BGP state.

Nine principles of interaction 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, the following interaction principles are adopted:
① BGP routes obtained from IBGP peers, BGP devices only advertise to its EBGP peers

② BGP routes obtained from EBGP peers, BGP equipment advertises to all its EBGP and IBGP peers

③When there are multiple effective routes to the same destination address, the BGP device only advertises the optimal route to the peer

④ When the route is updated, the BGP device only sends the updated BGP route

⑤All routes sent by EBGP peers will be received by BGP devices

⑥The next hop of all EBGP peers changes during the transfer process

⑦The next hop of all IBGP peers remains unchanged during the transmission process

⑧The TTL value is 1 when the default EBGP transmission is

⑨The default TTL value for IBGP delivery is 255

Points to note when establishing peers

● Points to note when
establishing peers in direct connection When establishing IBGP peers, make the next hop reachable. IBGP peers at the border need to point the next hop to themselves so that IBGP peers can be established.

●The points to note when establishing neighbors with loopback network ports need
to modify the update source. The default update source is a physical interface, which needs to be modified to a loopback network port. When establishing IBGP peers, ensure that the next hop is reachable and the IBGP at the border The peer needs to point the next hop to itself so that the IBGP peer can be established. When the EBGP peer is
established, EBGP can only transmit one hop. When establishing the EBGP peer, the number of hops of the EBGP multi-hop must be modified to 2 Above (two hops when looping back to the opposite end, one hop by default)

●As for why the loopback network port is used to establish neighbors
, the loopback network port is stable. As long as the router is started, the loopback network port will not be down, and the physical link may be affected by the line or interface and other factors, causing peering There is a problem with the relationship between the parties, so generally BGP peers are established through loopback network ports.

BGP configuration commands

[R1]bgp number——#Create bgp number
[R1-bgp]router-id xxxx ——#Configure BGP Router ID
[R1-bgpl peer xxxx as-number 1 Number——#Specify the loopback network port of the peer IP address and its AS number
[R1-bgp]peer xxxx connect-interface LoopBack0 ——#Update the interface that sends bgp packets to Loopback0 interface
[R1-bgp]peer xxxx next-hop-local——#ASBR from ebgp When the route learned by the neighbor is passed to the ibgp neighbor, modify the command
[R1-bgp]peer xxxx ebgp-max-hop 2——#The maximum hop of their neighbors to be built between two ASs using loopback network ports The number is changed to 2, and the default is 1 (because it is not a direct connection but a Loopbacko interface, it needs to go through 2 routes, and the default TTL value is 1 for EBGP delivery)

[R1-bgp]network xxxx anti-mask——#Announce the specified IGP, static, and default routes into the BGP process

[R1]ip route-static xxxx xxxx xxxx——#The ebgp peers between the two ASs need to establish a tcp connection, here static is used for the underlying addressing, or IGP routing can be used to build the underlying addressing (such as RIP)

[R1-bgp] network xxxx reverse mask——#ebgp The network segment or IP used to configure static routing or IGP routing needs to be announced at both ends of ebgp

③View command
1, display bgp peer ###View bgp peer information Established is successfully established
2, display bgp routing-table ##View bgp routing table information

Guess you like

Origin blog.csdn.net/Dark_Tk/article/details/112552817