BGP protocol (two)

table of Contents

1. Some minor issues with BGP

1.1 BGP routing black hole

1.2 BGP loop prevention mechanism

2. Basic configuration


1. Some minor issues with BGP

1.1 BGP routing black hole

Since the BGP protocol can establish a neighbor relationship in a non-direct connection, when two BGP neighbors have devices that do not run the BGP protocol, routing entries may propagate normally on the control plane, but the data plane traffic will be transmitted when passing through the devices that do not run the BGP protocol. Unreachable phenomenon appears, this is the routing black hole of BGP

solve:

  1. Physical link fully connected
  2. Neighbors are fully connected, and all devices run BGP
  3. Redistribute BGP routing entries to the IGP protocol
  4. Best: MPLS, multi-protocol label switching : https://blog.csdn.net/weixin_43997530/article/details/104501875

1.2 BGP loop prevention mechanism

1. Split horizon of EBGP

Use the AS-path attribute in the BGP entry, which records all the passed AS numbers; if there is a local AS number in the AS-path in the received routing entry, it will be rejected.

2. Split horizon of IBGP

Based on the characteristics of AS-BY-AS, the attributes of default BGP routing entries do not change when they are transmitted in the same AS; IBGP split horizon: BGP stipulates that the routes learned from one IBGP neighbor shall not be transmitted to other local IBGP neighbors .

Because the BGP protocol has the ability to establish neighbors through non-direct connections, as long as the BGP protocol runs within an AS, there must be an EBGP neighbor relationship (connected to other ASs); IBGP horizontal split leads to all devices running BGP within an AS , It is necessary to establish an IBGP neighbor relationship to transfer routing entries normally, which also makes the BGP neighbor relationship rise exponentially.

Resolution: Route reflector and federation

2. Basic configuration

[R1]bgp 1                             //启动时定义真实AS号,没有多进程概念;
[R1-bgp]router-id 1.1.1.1             //建议配置route-id,若手工不配置,将自动生成,其生成规则同OSPF一致;

[1] Neighbor relationship configuration

1. Directly connected EBGP neighbors directly use the IP address of the directly connected physical interface as the source and destination addresses;

[R1-bgp]peer 12.1.1.2 as-number 2          //对端接口IP地址,及所在的AS号

2. Establishment of IBGP neighbor relationship

Since IBGP neighbors are in the same AS, there will be a large number of backup paths. It is recommended to use the loopback interfaces of both parties as the source and destination IP addresses to establish neighbor relationships.

[R2-bgp]peer 3.3.3.3 as-number 2
[R2-bgp]peer 3.3.3.3 connect-interface LoopBack 0    //切记:一旦使用环回接口作为目标接口,同时本地的更新源也需要修改为环回

3. There are multiple links between EBGP neighbors. For stability and reliability, it is still recommended to use loopback ports to establish neighbors.

(1) Static routing is recommended for IP reachability issues

[R5]ip route-static 4.4.4.0 24 45.1.1.1
[R5]ip route-static 4.4.4.0 24 54.1.1.1

(2) Manually establish neighbor relationships

[R4]bgp 2 
[R4-bgp]peer 5.5.5.5 as-number 3
[R4-bgp]peer 5.5.5.5 connect-interface LoopBack 0

(3) Note: In the BGP protocol, the TTL value between IBGP neighbors is 255, and the EBGP neighbor is 1. Therefore, when loopback is used to establish EBGP neighbors, the TTL value must be modified.

[R4-bgp]peer 5.5.5.5 ebgp-max-hop 2        //修改跳数为2跳

[2] After configuring the neighbor relationship at both ends, first establish a TCP session through the TCP three-way handshake; after the TCP session is established, the BGP protocol sends and receives an Open message once, establishes the neighbor relationship, and generates the neighbor table ;

[R1]display tcp status                //查看tcp会话状态
[R2]display bgp peer                  //查看邻居表
 BGP local router ID : 2.2.2.2
 Local AS number : 2
 Total number of peers : 2                Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent   OutQ  Up/Down       State    PrefRcv

  3.3.3.3         4           2        0        0     0      00:00:10        Idle       0
  12.1.1.1        4           1       14       14     0      00:12:07  Established      0

[3] Announcement of routing entries: The establishment of neighbor relationships in BGP and the announcement of routing entries are carried out separately.

BGP needs to announce the routing entries in the local routing table one by one , no matter how these entries are generated, as long as they are in the local routing table and can be announced; when announcing, the content of the entry must be exactly the same as that in the local routing table; the local routing once The sending and receiving of entries generates the B GP table ; this table records all entry information received and transmitted locally;

[R1-bgp]network 1.1.1.1            //宣告路由条目
[R1]display bgp routing-table      //查看BGP路由表
 BGP Local router ID is 1.1.1.1 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.1/32         0.0.0.0         0                     0      i
 *>   12.1.1.0/24        0.0.0.0         0                     0      i
 状态    网络号                           属性
*标识条目可用      >标识条目优秀     i本地通过IBGP邻居关系学习

Note: If the entry is not optimal, it cannot be loaded into the local routing table, nor can it be passed to any neighbors; invalid routes must not be optimal; because of the rules of AS-BY-AS, the attributes are unchanged when transmitted within an AS, which may lead The next hop is unreachable and the path is not optimal; the next hop will be automatically changed to local when routing routes between EBGP neighbor relationships. If there is a synchronization problem in BGP, the entries cannot be optimized (Cisco and HUAWEI both disable synchronization by default).

[r2-bgp]peer 3.3.3.3 next-hop-local      //将路由传递给该邻居时,下一跳修改为本地;

 

Guess you like

Origin blog.csdn.net/weixin_43997530/article/details/108421756