阻止特定路径上的 BGP 路由

网络工程 思科 路由 BGP
2022-02-02 12:48:46

网络图:

Site A (.85)----172.24.0.84/30---- (.86)Site B
    |(.66)                              |(.102)
    |                                   |
    |(172.24.0.64/30)                   |(172.24.0.100/30)
    |(.65)                              |(.101)
    -------------- Site C ---------------

路由器配置和跟踪路由结果:

site_a:

interface FastEthernet0/0
 ip address 172.24.0.85 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 172.24.0.65 255.255.255.252
 duplex auto
 speed auto
!
router bgp 900
 no synchronization
 bgp router-id 172.24.0.65
 bgp log-neighbor-changes
 network 172.24.0.64 mask 255.255.255.252
 network 172.24.0.84 mask 255.255.255.252
 timers bgp 1 3
 neighbor 172.24.0.66 remote-as 100
 neighbor 172.24.0.66 soft-reconfiguration inbound
 neighbor 172.24.0.86 remote-as 1200
 neighbor 172.24.0.86 soft-reconfiguration inbound
 neighbor 172.24.0.86 route-map site_b_only in
 no auto-summary
!
ip as-path access-list 1 permit ^[0-9]+_[0-9]+$
!
route-map site_b_only permit 10
 match as-path 1

_____________________________________
site_b:

interface FastEthernet0/0
 ip address 172.24.0.86 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 172.24.0.102 255.255.255.252
 duplex auto
 speed auto
!
router bgp 1200
 no synchronization
 bgp router-id 172.24.0.86
 bgp log-neighbor-changes
 network 172.24.0.84 mask 255.255.255.252
 network 172.24.0.100 mask 255.255.255.252
 timers bgp 1 3
 neighbor 172.24.0.85 remote-as 900
 neighbor 172.24.0.85 soft-reconfiguration inbound
 neighbor 172.24.0.85 route-map site_a_only in
 neighbor 172.24.0.101 remote-as 100
 neighbor 172.24.0.101 soft-reconfiguration inbound
 no auto-summary
!
ip as-path access-list 1 permit ^900_[0-9]*$
!
route-map site_a_only permit 10
 match as-path 1

__________________________________________
site_c:

interface FastEthernet0/0
 ip address 172.24.0.66 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 172.24.0.101 255.255.255.252
 duplex auto
 speed auto
!
router bgp 100
 no synchronization
 bgp router-id 192.168.255.2
 bgp log-neighbor-changes
 network 172.24.0.64 mask 255.255.255.252
 network 172.24.0.100 mask 255.255.255.252
 timers bgp 1 3
 neighbor 172.24.0.65 remote-as 900
 neighbor 172.24.0.65 soft-reconfiguration inbound
 neighbor 172.24.0.102 remote-as 1200
 neighbor 172.24.0.102 soft-reconfiguration inbound
 no auto-summary

_________________________________________________________
site_c#show ip bgp  
BGP table version is 4, local router ID is 192.168.255.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
*  172.24.0.64/30   172.24.0.65              0             0 900 i
*>                  0.0.0.0                  0         32768 i
*  172.24.0.84/30   172.24.0.102             0             0 1200 i
*>                  172.24.0.65              0             0 900 i
*  172.24.0.100/30  172.24.0.102             0             0 1200 i
*>                  0.0.0.0                  0         32768 i
site_c#traceroute 172.24.0.85

Type escape sequence to abort.
Tracing the route to 172.24.0.85

  1 172.24.0.65 28 msec 16 msec 20 msec
site_c#traceroute 172.24.0.86

Type escape sequence to abort.
Tracing the route to 172.24.0.86

  1 172.24.0.65 24 msec 20 msec 24 msec
  2 172.24.0.86 [AS 900] 16 msec 36 msec 24 msec

如果流量来自站点 C,我怎么能强制流量不在站点 A 和站点 B 之间路由?我只想要站点 C -> 站点 A、站点 C -> 站点 B;但是站点 A 和站点 B 必须通过它们的 p2p 链接进行通信

如果你检查从站点 C 到 172.24.0.86 的 traceroute 结果,它仍然通过站点 A,这是错误的。

最终部署将在运行 Quagga 的 Linux 下进行,这只是在我的实验室环境中运行 IOS 的模拟。

2个回答

由于您正在通过 BGP 学习路由,因此您需要了解它如何选择首选路径。使用 BGP,它会根据必须通过的 AS 数量进行选择。由于该网络是从两者学习的并且具有相同的跳数,因此两者都是可行的路由并且相等。如您的路由表所示。

您需要修改另一个指标才能更改路径选择。有多种选择。我会留给你决定的。

查看http://packetlife.net/media/library/1/BGP.pdf以获取包含路径选择信息的备忘单。

有几种方法允许使用管理标准进行流量管理。这些标准称为本地首选项和前置。如果必须减少来自站点的流量,则必须在 AS 路径中放置一个或两个前置。因此,AS 路径是使用 1-2 AS 人为扩展的,使您的网络看起来像是有人宣布的,位于距离我们更远的 1-2 自治系统。结果,先前认为通过该上行链路的路径为最佳路径的部分路由器将选择其他路径。因此,可以平衡传入链路的负载。

控制流量的另一种方法是用特殊标志标记您的公告 - 社区,它告诉提供商的路由器在哪里以及如何宣布您的网络。例如,“到站点 A 带有三个前置,通常到站点 B”。没有标准的社区标志集,这就是为什么需要与您的 ISP 的管理员一起规定它们的原因。通常,这些标志在自治系统的描述中表示,可以在 RIPE 数据库的注释字段中找到。

为了学习如何做到这一点,了解如何在大型 Internet 的组成部分之间执行路由以及什么是BGP 路由至关重要。