Networking

使用 FRRouting 配置具有本地首選項集的 BGP

  • June 25, 2021

我想為一個 ISP 配置一個多宿主 BGP 路由器。我的實際設置將只接收預設路由,而不是來自上游 ISP 的完整 BGP 饋送。但是在這個測試設置中,我有一個如下的網路設置,我的目標是更喜歡 R4 而不是 R2 來處理來自 R1 的流量。 網路設置

4 個路由器是來自GNS3 市場的 FRR 7.3.1 映像。它們的配置相同。所有路由器的配置都是一樣的,只是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 上的本地首選項設置為 300 到從 R4 學習的路徑。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 的理解可能存在缺陷。如果我做錯了什麼,請指出。

似乎這個問題是特定於 FRRouting 的。通過 IOS 的本地首選項獲得所需的結果,並進行精確設置。將使用更多版本的 FRRouting 進行測試,以查看問題是否仍然存在。

引用自:https://serverfault.com/questions/1067738