关于 bgp 邻居基础

网络工程 bgp
2021-07-27 03:23:21

对于邻居关系,来自路由器 R1 的更新源 IP 必须与路由器 R2 上的邻居命令匹配,反之亦然

为了测试上面的内容,我用 R1 和 R2 设置了我的实验室来测试上面的内容。(参考下图)

R1#sho ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            1.1.1.1         YES manual up                    up
FastEthernet0/1            unassigned      YES unset  administratively down down
Loopback0                  11.11.11.11     YES manual up                    up
R1#
R1#
R1#sho run | sec router bgp
router bgp 1
 no synchronization
 bgp log-neighbor-changes
 neighbor 22.22.22.22 remote-as 2
 neighbor 22.22.22.22 ebgp-multihop 2
 no auto-summary
R1#


R1#sho ip route 22.22.22.22
Routing entry for 22.0.0.0/8
  Known via "static", distance 1, metric 0
  Routing Descriptor Blocks:
  * 1.1.1.2
      Route metric is 0, traffic share count is 1

R1#sho ip bgp summary | b Neighbor
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
22.22.22.22     4     2      13      12        0    0    0 00:26:10 Active

对于 R2,我有

R2#sho ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  administratively down down
FastEthernet0/1            1.1.1.2         YES manual up                    up
Loopback0                  22.22.22.22     YES manual up                    up

R2#sho run | sec router bgp
router bgp 2
 no synchronization
 bgp log-neighbor-changes
 neighbor 11.11.11.11 remote-as 1
 neighbor 11.11.11.11 ebgp-multihop 2
 no auto-summary
R2#



R2#sho ip route 11.11.11.11
Routing entry for 11.0.0.0/8
  Known via "static", distance 1, metric 0
  Routing Descriptor Blocks:
  * 1.1.1.1
      Route metric is 0, traffic share count is 1

R2#sho ip bgp summary | b Neighbor
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.11.11.11     4     1       6       7        0    0    0 00:17:27 Active
R2#

Q1:正如你看到的,我的BGP邻居关系是停留在活跃state.From我了解,R1预计从R2的邻居关系报文的源IP22.22.22.22 如果你这样做sho ip route了11.11.11.11在R2上,你看到它是通过教训1.1.1.1作为static route因此,来自 R2 的 bgp 邻居数据包将使用此出口源 ip( 1.1.1.2) 请确认我的理解是否正确

Q2:我在 R2 上添加了以下内容。

R2(config)#router bgp 2
R2(config-router)#ne
R2(config-router)#nei
R2(config-router)#neighbor 11.11.11.11 up
R2(config-router)#neighbor 11.11.11.11 update-source lo
R2(config-router)#neighbor 11.11.11.11 update-source loopback 0
R2(config-router)#end
R2#
*Mar  1 00:56:26.211: %SYS-5-CONFIG_I: Configured from console by console
R2#sho ip bgp summary | b Neighbor
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.11.11.11     4     1       6       7        0    0    0 00:35:17 Active
R2#
*Mar  1 00:56:37.107: %BGP-5-ADJCHANGE: neighbor 11.11.11.11 Up
R2#

bgp 邻居现在出现了。我的问题是 - 为什么在第一种情况下没有出现邻居? 在此处输入图片说明

Q3:现在我公布了一个从 R2 到 R1 的不同环回,如下所示

R2(config-router)#do sho run int lo2
Building configuration...

Current configuration : 61 bytes
!
interface Loopback2
 ip address 222.222.222.222 255.255.0.0
end

R2(config)#router bgp 2
R2(config-router)#network 222.222.0.0 mask 255.255.0.0

然后在 R1 上,我看到收到的前缀

R1#sho ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

C    1.0.0.0/8 is directly connected, FastEthernet0/0
S    22.0.0.0/8 [1/0] via 1.1.1.2
C    11.0.0.0/8 is directly connected, Loopback0
B    222.222.0.0/16 [20/0] via 22.22.22.22, 00:04:53
R1#

问:R1 正在学习222.222.0.0,下一跳为22.22.22.22为什么是22.22.22.22下一跳?

2个回答

好的 - 所以这里发生了一些事情,我将尝试按大致顺序解决它们。

  1. BGP 有两个子变体 - 内部 (iBGP) 和外部 (eBGP)。在 iBGP 的情况下,两个对等方的 ASN 是相同的。在 eBGP 的情况下,两个 ASN 是不同的。在您的示例中,您使用的是 eBGP。我提到这一点是因为 eBGP 和 iBGP 之间的许多规则是不同的。

  2. 典型的eBGP 会话发生在直接连接的接口之间。在您的示例中,这意味着 R1 和 R2 将分别作为 1.1.1.1 和 1.1.1.2 相互对等(即 R1 对 1.1.1.2 有邻居声明,R2 对 1.1.1.1 有其声明)。这是有效的,因为每个路由器都可以通过直接连接的路由到达另一个路由器。如果您删除了更新源和静态路由,并简单地在它们直接连接的接口上对等路由器,则对等体将在没有任何进一步配置的情况下出现。另外 - 顺便说一句,如果您有点对点链接,请使用 /30 或 /31 前缀而不是 /8。

  3. 可以配置什么所谓的多跳eBGP。这意味着对等两个未直接连接的路由器接口。这需要另一个路由需要到位,以便接口能够传递数据包。当您将会话源更改为环回时,您需要适当的静态路由以允许会话出现。通常,对等会话将需要一个额外的语句来指定会话的最大 IP 跃点数,但由于在这种情况下它们仅相隔一个跃点,因此可能没有必要(尽管过去是这样)。这也称为递归路由 - 因此,通过远程路由器环回的下一跳接收到的路由实际上将使用静态路由作为解析给定数据包将采用的接口的一种方式(在本例中为 1.1.1. X)。

  4. 默认情况下,eBGP 路由将使用对等地址的下一跳进行通告(除非通过旋钮或路由映射特别更改)。这是与 iBGP 的不同之处之一,除非配置为其他行为,否则下一跳地址通常在对等方之间保持不变。

当您想在具有环回接口的 BGP 中创建邻居时。您应该将更新源更改为环回 IP 地址。做什么的?

因为当您使用环回接口创建邻居时,您没有更改源 IP 地址。两个路由器都尝试与出口端口的源 IP 建立 TCP 会话。然后router2收到消息说源IP是1.1.1.1,目的IP是22.22.22.22。但它希望在接收来自 1.1.1.1 的消息时与 11.11.11.11 成为邻居。

问题 3:在 BGP 中,您应该执行递归查找以找到到达目的地的路由。例如在 B 222.222.0.0/16 [20/0] via 22.22.22.22, 00:04:53 首先,你找到 22.22.22.22 然后你应该看到 22.22.22.22 的路由表。即: S 22.0.0.0/8 [1/0] 通过 1.1.1.2 所以,你的数据包从 1.1.1.2 到目的地。祝你好运