使用 FRRouting 配置具有本地首选项的 BGP

使用 FRRouting 配置具有本地首选项的 BGP

我想配置一个多宿主 BGP 路由器,并优先选择一家 ISP。我的实际设置将仅接收默认路由,而不是来自上游 ISP 的完整 BGP 反馈。但在此测试设置中,我的网络设置如下,我的目标是优先选择 R4 而不是 R2 来处理来自 R1 的流量。 网络设置

这 4 个路由器是来自GNS3 市场。它们的配置相同。所有路由器的配置都相同,只有 IP 地址根据图所示有所变化。

R1# show running-config 
Building configuration...

Current configuration:
!
frr version 7.3.1
frr defaults traditional
hostname R1
service integrated-vtysh-config
!
router bgp 1
 neighbor 192.168.1.2 remote-as 2
 neighbor 192.168.4.1 remote-as 4
 !
 address-family ipv4 unicast
  network 10.1.0.0/16
 exit-address-family
!
line vty
!
end

第一个问题是我没有看到所有路由器上的所有路径。两个路由器各有 7 条路径,而另外两个各有 5 条路径。如果这有任何意义的话,那两个有 7 条路径的路由器是第一个和最后一个配置的。

R1:

R1# show ip bgp
BGP table version is 5, local router ID is 192.168.4.2, vrf id 0
Default local pref 100, local AS 1
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.0.0/16      0.0.0.0                  0         32768 i
*  10.2.0.0/16      192.168.4.1                            0 4 3 2 i
*>                  192.168.1.2              0             0 2 i
*  10.3.0.0/16      192.168.4.1                            0 4 3 i
*>                  192.168.1.2                            0 2 3 i
*> 10.4.0.0/16      192.168.4.1              0             0 4 i
*                   192.168.1.2                            0 2 3 4 i

Displayed  4 routes and 7 total paths

R2:

R2# show ip bgp 
BGP table version is 4, local router ID is 192.168.2.1, vrf id 0
Default local pref 100, local AS 2
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.0.0/16      192.168.1.1              0             0 1 i
*> 10.2.0.0/16      0.0.0.0                  0         32768 i
*> 10.3.0.0/16      192.168.2.2              0             0 3 i
*  10.4.0.0/16      192.168.1.1                            0 1 4 i
*>                  192.168.2.2                            0 3 4 i

Displayed  4 routes and 5 total paths

R3:

R3# show ip bgp 
BGP table version is 4, local router ID is 192.168.3.1, vrf id 0
Default local pref 100, local AS 3
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  10.1.0.0/16      192.168.3.2                            0 4 1 i
*>                  192.168.2.1                            0 2 1 i
*> 10.2.0.0/16      192.168.2.1              0             0 2 i
*> 10.3.0.0/16      0.0.0.0                  0         32768 i
*> 10.4.0.0/16      192.168.3.2              0             0 4 i

Displayed  4 routes and 5 total paths

R4:

R4# show ip bgp 
BGP table version is 5, local router ID is 192.168.4.1, vrf id 0
Default local pref 100, local AS 4
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.0.0/16      192.168.4.2              0             0 1 i
*                   192.168.3.1                            0 3 2 1 i
*  10.2.0.0/16      192.168.4.2                            0 1 2 i
*>                  192.168.3.1                            0 3 2 i
*  10.3.0.0/16      192.168.4.2                            0 1 2 3 i
*>                  192.168.3.1              0             0 3 i
*> 10.4.0.0/16      0.0.0.0                  0         32768 i

Displayed  4 routes and 7 total paths

除了 BGP 路径列表不同之外,一切看起来都很好。我可以 ping 各个路由器,并且 traceroute 符合预期。

R1:~# traceroute -s 10.1.0.1 10.2.0.1
traceroute to 10.2.0.1 (10.2.0.1) from 10.1.0.1, 30 hops max, 46 byte packets
 1  10.2.0.1 (10.2.0.1)  1.473 ms  1.430 ms  1.328 ms
R1:~# traceroute -s 10.1.0.1 10.3.0.1
traceroute to 10.3.0.1 (10.3.0.1) from 10.1.0.1, 30 hops max, 46 byte packets
 1  192.168.1.2 (192.168.1.2)  1.377 ms  1.466 ms  1.356 ms
 2  10.3.0.1 (10.3.0.1)  3.149 ms  1.462 ms  1.033 ms
R1:~# traceroute -s 10.1.0.1 10.4.0.1
traceroute to 10.4.0.1 (10.4.0.1) from 10.1.0.1, 30 hops max, 46 byte packets
 1  10.4.0.1 (10.4.0.1)  0.556 ms  1.243 ms  1.271 ms

R3:~# traceroute -s 10.3.0.1 10.1.0.1
traceroute to 10.1.0.1 (10.1.0.1) from 10.3.0.1, 30 hops max, 46 byte packets
 1  192.168.2.1 (192.168.2.1)  0.468 ms  1.461 ms  1.135 ms
 2  10.1.0.1 (10.1.0.1)  3.038 ms  3.332 ms  3.734 ms

偏好設定: 我希望从 R1 发出的流量通过 R4 而不是 R2,因此我在 R1 上将从 R4 获知的路径的本地优先级设置为 300。R1:

frr(config)# ip prefix-list allow_all_pref seq 10 permit any
frr(config)# route-map rmap permit 10
frr(config-route-map)# match ip address prefix-list allow_all_pref
frr(config-route-map)# set local-preference 300
frr(config-route-map)# exit
frr(config)# router bgp 1
frr(config-router)# address-family ipv4 unicast
frr(config-router-af)# neighbor 192.168.4.1 route-map rmap in
frr(config-router-af)# do show ip bgp
BGP table version is 8, local router ID is 192.168.4.2, vrf id 0
Default local pref 100, local AS 1
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.0.0/16      0.0.0.0                  0         32768 i
*> 10.2.0.0/16      192.168.4.1                   300      0 4 3 2 i
*                   192.168.1.2              0             0 2 i
*> 10.3.0.0/16      192.168.4.1                   300      0 4 3 i
*                   192.168.1.2                            0 2 3 i
*> 10.4.0.0/16      192.168.4.1              0    300      0 4 i
*                   192.168.1.2                            0 2 3 4 i

Displayed  4 routes and 7 total paths

但现在一切都崩溃了。我无法再 ping 通 R2 和 R3。当我从 R1 ping 通 R2 时,我可以通过 wireshark 看到回应请求通过 R4 到达 R3,但 R3 和 R2 之间的流量没有显示。

Wireshark R4-R3 Wireshark R3-R2

traceroute to 10.2.0.1 (10.2.0.1) from 10.1.0.1, 30 hops max, 46 byte packets
 1  192.168.4.1 (192.168.4.1)  1.480 ms  1.514 ms  1.499 ms
 2  *  *  *
 3  *  *  *
 4  *  *  *

其他路由器的 show ip bgp 输出如下。R2:

R2# show ip bgp 
BGP table version is 4, local router ID is 192.168.2.1, vrf id 0
Default local pref 100, local AS 2
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.0.0/16      192.168.1.1              0             0 1 i
*> 10.2.0.0/16      0.0.0.0                  0         32768 i
*  10.3.0.0/16      192.168.1.1                            0 1 4 3 i
*>                  192.168.2.2              0             0 3 i
*  10.4.0.0/16      192.168.1.1                            0 1 4 i
*>                  192.168.2.2                            0 3 4 i

Displayed  4 routes and 6 total paths

R3:

R3# show ip bgp 
BGP table version is 4, local router ID is 192.168.3.1, vrf id 0
Default local pref 100, local AS 3
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  10.1.0.0/16      192.168.3.2                            0 4 1 i
*>                  192.168.2.1                            0 2 1 i
*> 10.2.0.0/16      192.168.2.1              0             0 2 i
*> 10.3.0.0/16      0.0.0.0                  0         32768 i
*> 10.4.0.0/16      192.168.3.2              0             0 4 i

Displayed  4 routes and 5 total paths

R4:

R4# show ip bgp 
BGP table version is 5, local router ID is 192.168.4.1, vrf id 0
Default local pref 100, local AS 4
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.0.0/16      192.168.4.2              0             0 1 i
*                   192.168.3.1                            0 3 2 1 i
*> 10.2.0.0/16      192.168.3.1                            0 3 2 i
*> 10.3.0.0/16      192.168.3.1              0             0 3 i
*> 10.4.0.0/16      0.0.0.0                  0         32768 i

Displayed  4 routes and 5 total paths

当我从 R4 ping R2 时,数据包按预期从 R3 移动到 R2。

任何帮助都将不胜感激。我是网络新手,对 BGP 的理解可能存在缺陷。如果我做错了什么,请指出。

答案1

似乎这个问题是 FRRouting 特有的。使用 IOS 的本地偏好和精确设置可以获得所需的结果。将使用更多版本的 FRRouting 进行测试,看看问题是否仍然存在。

相关内容