了解 MP-BGP 基础知识

网络工程 IPv4 BGP 虚拟现实
2022-02-28 06:37:23

我试图了解地址系列 vpnv4 和地址系列 ipv4 vrf 之间的区别

因此,为了测试场景,我将 2 个路由器(R1 和 R2)线性背靠背连接。R1 的环回为 11.11.11.11

R2 的环回地址为 22.22.22.22

在 R2 上,我有 vrf TEST22。在 R2 上,我还有一条到 vrf TEST22 中网络 100.0.0.0 的静态路由,如下所示

ip route vrf TEST22 100.0.0.0 255.0.0.0 null 0

我希望在 R1 上学习这条路线。

在 R1 上,我有 vrf TEST11。

R1 上的配置和命令输出:

R1#sho ip bgp vpnv4 all summary
BGP router identifier 11.11.11.11, local AS number 1
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
22.22.22.22     4     2      17      16        1    0    0 00:03:18        0
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#ip vrf TEST11
R1(config-vrf)#route
R1(config-vrf)#route-target im
R1(config-vrf)#route-target import 2:2
R1(config-vrf)#end
R1#
*Mar  1 00:20:32.703: %SYS-5-CONFIG_I: Configured from console by console
R1#sho ip bgp vpnv4 all summary
BGP router identifier 11.11.11.11, local AS number 1
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
22.22.22.22     4     2      19      18        1    0    0 00:04:04        0
R1#sho ip bgp vpnv4 all summary
BGP router identifier 11.11.11.11, local AS number 1
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
22.22.22.22     4     2      19      18        1    0    0 00:04:06        0

R1#
R1#sho run | sec vrf
ip vrf TEST11
 rd 1:1
 route-target import 2:2
 address-family ipv4 vrf TEST11
  no synchronization
R1#
R1#
R1#sho ip bgp vpnv4 all summary
BGP router identifier 11.11.11.11, local AS number 1
BGP table version is 3, main routing table version 3
2 network entries using 280 bytes of memory
2 path entries using 136 bytes of memory
2/1 BGP path/bestpath attribute entries using 248 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
1 BGP extended community entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 712 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 15 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
22.22.22.22     4     2      20      18        3    0    0 00:04:42        1
R1#
R1#


R1#sho ip bgp vpnv4 vrf TEST11
BGP table version is 3, local router ID is 11.11.11.11
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf TEST11)
*> 100.0.0.0        22.22.22.22            100             0 2 ?
R1#E{M'}T
R1#p}
R1#
R1#
R1#ter len 0
R1#sho run | sec bgp
router bgp 1
 bgp log-neighbor-changes
 neighbor 22.22.22.22 remote-as 2
 neighbor 22.22.22.22 ebgp-multihop 2
 neighbor 22.22.22.22 update-source Loopback0
 !
 address-family ipv4
  neighbor 22.22.22.22 activate
  no auto-summary
  no synchronization
 exit-address-family
 !
 address-family vpnv4
  neighbor 22.22.22.22 activate
  neighbor 22.22.22.22 send-community extended
 exit-address-family
 !
 address-family ipv4 vrf TEST11
  no synchronization
 exit-address-family
R1#
R1#
R1#sho run | sec vrf
ip vrf TEST11
 rd 1:1
 route-target import 2:2
 address-family ipv4 vrf TEST11
  no synchronization
R1#
R1#
R1#sho ip bgp sum
R1#sho ip bgp summary
BGP router identifier 11.11.11.11, local AS number 1
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
22.22.22.22     4     2      27      25        1    0    0 00:11:06        0
R1#


R1#sho ip bgp vpnv4 vrf TEST11 summary


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 is directly connected, FastEthernet0/0
C    11.0.0.0/8 is directly connected, Loopback0
R1#
R1#sho ip route vr
R1#sho ip route vrf TEST11

Routing Table: TEST11
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

B    100.0.0.0/8 [20/100] via 22.22.22.22, 00:07:57
R1#
R1#sho ip bgp vpn
R1#sho ip bgp vpnv4 vr
R1#sho ip bgp vpnv4 vrf TEST11
BGP table version is 3, local router ID is 11.11.11.11
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf TEST11)
*> 100.0.0.0        22.22.22.22            100             0 2 ?
R1#

R2上的配置和命令输出:

R2#
R2#
R2#sho run | sec router bgp
router bgp 2
 bgp log-neighbor-changes
 neighbor 11.11.11.11 remote-as 1
 neighbor 11.11.11.11 ebgp-multihop 2
 neighbor 11.11.11.11 update-source Loopback0
 !
 address-family ipv4
  neighbor 11.11.11.11 activate
  no auto-summary
  no synchronization
 exit-address-family
 !
 address-family vpnv4
  neighbor 11.11.11.11 activate
  neighbor 11.11.11.11 send-community extended
 exit-address-family
 !
 address-family ipv4 vrf TEST22
  redistribute static metric 100
  no synchronization
 exit-address-family
R2#
R2#
R2#sho ip bgp summ
R2#sho ip bgp summary
BGP router identifier 1.1.1.2, local AS number 2
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.11.11.11     4     1      68      70        1    0    0 00:54:37        0
R2#
R2#
R2#sho ip bgp vpn
R2#sho ip bgp vpnv4 vr
R2#sho ip bgp vpnv4 vrf TEST22
BGP table version is 4, local router ID is 1.1.1.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 2:2 (default for vrf TEST22)
*> 100.0.0.0        0.0.0.0                100         32768 ?
R2#
R2#
R2#sho run | sec vrf
ip vrf TEST22
 rd 2:2
 route-target export 2:2
 address-family ipv4 vrf TEST22
  redistribute static metric 100
  no synchronization
ip route vrf TEST22 100.0.0.0 255.0.0.0 Null0
R2#
R2#sho ip bgp vpn
R2#sho ip bgp vpnv4 al
R2#sho ip bgp vpnv4 all summ
R2#sho ip bgp vpnv4 all summary
BGP router identifier 1.1.1.2, local AS number 2
BGP table version is 4, main routing table version 4
1 network entries using 140 bytes of memory
1 path entries using 68 bytes of memory
2/1 BGP path/bestpath attribute entries using 248 bytes of memory
1 BGP extended community entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 512 total bytes of memory
BGP activity 1/0 prefixes, 1/0 paths, scan interval 15 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.11.11.11     4     1      71      73        4    0    0 00:57:28        0
R2#
R2#
R2#

Q1:如您所见,R1 在 vrf TEST11 中学习了路由 100.0.0.0。即使我没有在激活邻居,但 R1 仍然学习了该路由。如何? 作为该路线的运输承运人吗?1.1.1.1address-family ipv4 vrf <vrf name>address-family vpnv4

Q2:在另一种情况下,我从 R1 和 R2 上的 vpnv4 地址系列中删除了邻居,如下所示

在 R1 上

    R1#sho run | sec router bgp
router bgp 1
 bgp log-neighbor-changes
 neighbor 22.22.22.22 remote-as 2
 neighbor 22.22.22.22 ebgp-multihop 2
 neighbor 22.22.22.22 update-source Loopback0
 !
 address-family ipv4
  neighbor 22.22.22.22 activate
  no auto-summary
  no synchronization
 exit-address-family
 !
 address-family ipv4 vrf TEST22
  neighbor 22.22.22.22 remote-as 2
  neighbor 22.22.22.22 ebgp-multihop 2
  neighbor 22.22.22.22 update-source Loopback0
  neighbor 22.22.22.22 activate
  no synchronization
 exit-address-family
 !
 address-family ipv4 vrf TEST11
  no synchronization
 exit-address-family
R1#sho ip bgp vpnv4 vrf TEST22 summary | b Neighbor
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
22.22.22.22     4     2       0       0        0    0    0 never    Active
R1#
R1#sho run | sec vrf
ip vrf TEST11
 rd 1:1
 route-target import 2:2
ip vrf TEST22
 rd 1:2
 route-target import 2:2
 address-family ipv4 vrf TEST22
  neighbor 22.22.22.22 remote-as 2
  neighbor 22.22.22.22 ebgp-multihop 2
  neighbor 22.22.22.22 update-source Loopback0
  neighbor 22.22.22.22 activate
  no synchronization
 address-family ipv4 vrf TEST11
  no synchronization
R1#

R1#sho ip bgp vpnv4 vrf TEST22 summary | b Neighbor
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
22.22.22.22     4     2       0       0        0    0    0 never    Active
R1#

R1#sho ip bgp vpnv4 vrf TEST22

R1#

在 R2 上:

R2#sho run | sec bgp
router bgp 2
 bgp log-neighbor-changes
 neighbor 11.11.11.11 remote-as 1
 neighbor 11.11.11.11 ebgp-multihop 2
 neighbor 11.11.11.11 update-source Loopback0
 !
 address-family ipv4
  neighbor 11.11.11.11 activate
  no auto-summary
  no synchronization
 exit-address-family
 !
 address-family ipv4 vrf TEST22
  redistribute static metric 10
  neighbor 11.11.11.11 remote-as 1
  neighbor 11.11.11.11 ebgp-multihop 2
  neighbor 11.11.11.11 update-source Loopback0
  neighbor 11.11.11.11 activate
  no synchronization
 exit-address-family
R2#
R2#sho run | i null
R2#sho run | i route
ip route 11.0.0.0 255.0.0.0 FastEthernet0/0
ip route vrf TEST22 100.0.0.0 255.0.0.0 Null0
R2#
R2#
R2#sho ip bgp vpnv4 vrf TEST22 summary | b Neighbor
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.11.11.11     4     1       0       0        0    0    0 never    Active
R2#sho ip bgp summ
R2#sho ip bgp summary | b Neigh
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.11.11.11     4     1     203     205        1    0    0 00:01:42        0
R2#

如您所见,在 R1 上,到 100.0.0.0 的路由不再存在。此外,BGP vrf 对等互连处于活动状态。为什么会这样?address-family vpnv4之间有什么关系address-family ipv4 vrf <vrf name>吗?是否必须为address-family vpnv4要交换的 vrf 路由激活邻居?

2个回答
  1. VPNv4 是“传输”。您的 VRF 路由目标在两台设备上匹配。长话短说,RT 是在 BGP 更新中通过 VPNv4 会话发送的 extcommunity。如果本地导入 RT 之一与接收到的 extcommunity 匹配,则在配置了此 RT 的 VRF 中导入路由。实际上 VPNv4 相当复杂,完整的解释超出了本站的范围。

  2. 为了在 VRF 中运行路由协议,不需要VPNv4 。思科称其为 VRF-lite。Active在这里的状态问题与路由有关。

    address-family ipv4
     neighbor 11.11.11.11 activate
     no auto-summary
     no synchronization
    exit-address-family
    !
    address-family ipv4 vrf TEST22
     redistribute static metric 10
     neighbor 11.11.11.11 remote-as 1
     neighbor 11.11.11.11 ebgp-multihop 2
     neighbor 11.11.11.11 update-source Loopback0
     neighbor 11.11.11.11 activate
     no synchronization
    exit-address-family
    

IPv4 和 IPv4 vrf TEST22 地址系列都以 Lo0 作为源。只要 IPv4 邻接是Established我假设 Lo0不在 VRF 中这会使您的 BGP 源无法访问。

这真是一团糟。当我们在这里谈论 MP-BGP 时,我们需要掌握正确的基础知识。

首先,vpnv4 = ipv4 + RD + RT。

只要一个VRF(NAME)下没有接口,就不能在AF ipv4 vrf(NAME)的neighbor语句中调用。

BGP 只与一个 IP 形成一个会话,与 AF 无关。您可以在全球范围内拥有您的 IP 11.11.11.11,您可以决定可以交换路由的 AF,它可以在 IPV4 AF 或 VPNV4 AF 中,但不能在 ipv4 vrf(NAME) 中。

如果您要发布 VPNV4 路由,则需要全局配置“vrf 定义”,其中您可以在 AF IPV4 和 VPNV4 下设置邻居语句。如果您的意图只是运行 VRF-Lite,那么您可以全局配置“ip vrf”。

注意:如果您要使用“vrf 定义”,请留意 BGP 的全局声明“no bgp default ipv4-unicast”。

干杯,

拉吉。