我怎样才能准确地找出正在使用的传出接口?

网络工程 思科 cisco-nexus
2022-02-15 19:11:00

我需要确定某个目标地址使用的传出接口。 show ip route告诉我几个到这个目的地的 BGP 路由,我怎样才能准确地找出将使用哪个交换机的接口?如果我没记错的话,ECMP 在这种情况下扮演了一些角色。

pd01-ilf-005# sh ip route a.b.c.d/32
IP Route Table for VRF "default"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%<string>' in via output denotes VRF <string>

a.b.c.d/32, ubest/mbest: 2/0
    *via 10.0.1.4, [20/0], 19w5d, bgp-4200020005, external, tag 4200000002
    *via 10.0.1.132, [20/0], 19w5d, bgp-4200020005, external, tag 4200000002
pd01-ilf-005# sh forw 1.2.3.4

slot  1
=======


IPv4 routes for table default/base

------------------+-----------------------------------------+----------------------+-----------------+-----------------
Prefix            | Next-hop                                | Interface            | Labels          | Partial Install
------------------+-----------------------------------------+----------------------+-----------------+-----------------
*a.b.c.d/32     10.0.1.4                                  Ethernet1/49
                     10.0.1.132                                Ethernet1/50

BGP routing table entry for a.b.c.d/32, version 485974
Paths: (2 available, best #2)
Flags: (0x8008001a) (high32 00000000) on xmit-list, is in urib, is best urib route, is in HW
Multipath: eBGP

  Path type: external, path is valid, not best reason: newer EBGP path, multipath, no labeled nexthop, in rib
  AS-Path: 4200000002 4200020006 , path sourced external to AS
    10.0.1.4 (metric 0) from 10.0.1.4 (10.0.27.125)
      Origin incomplete, MED not set, localpref 100, weight 0

  Advertised path-id 1
  Path type: external, path is valid, is best path, no labeled nexthop, in rib
  AS-Path: 4200000002 4200020006 , path sourced external to AS
    10.0.1.132 (metric 0) from 10.0.1.132 (10.0.27.126)
      Origin incomplete, MED not set, localpref 100, weight 0

  Path-id 1 advertised to peers:
    10.0.98.173        10.0.98.189
1个回答

基本上,ECMP 路径是相等的。一个给定的数据包采用可能的路由之一,看似随机。路由器根据接口负载、队列深度、普通循环、...

可能有一些政策偏爱一条路由而不是其他路由(基于源地址、L4 协议、L4 端口号、会话......),但没有标准(据我所知)。通常,“ECMP”实际上在实践中更像是 PBR。