1、为确保BGP路由争取加入到全局路由表中,首先需要确保BGP路由有效,其次要确保能够在和通过其他路由协议学到的路由比较中优选。

2、查看BGP 邻居状态

        2.1 如果没有BGP路由表中,未能查询到相匹配的路由信息,需要查看BGP邻居状态是否正常

# 查看对等体的信息。

<Huawei> display bgp peer
 Status codes: * - Dynamic
 BGP Local router ID : 10.2.3.4
 local AS number : 10
 Total number of peers : 2                 
 Peers in established state : 1

 Total number of dynamic peers : 1
  Peer        V    AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  10.1.1.1    4   100        0        0     0 00:00:07        Idle       0
  10.2.5.6    4   200       32       35     0 00:17:49 Established       0

        2.2  查看路由表,确认BGP邻居是否可达,查看邻居配置是否正确

# 显示当前路由表的概要信息,查看BGP邻居的IP地址是否存在匹配的路由。

<Huawei> display ip routing-table
Route Flags:
R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 8        Routes : 9

   Destination/Mask  Proto  Pre  Cost  Flags   NextHop   Interface

        10.1.1.1/32   Static  60     0     D    0.0.0.0    NULL0
                     Static  60     0     D    192.168.0.2  GigabitEthernet1/0/0
      192.168.0.0/24   Direct   0     0     D    192.168.0.1  GigabitEthernet1/0/0
      192.168.0.1/32   Direct   0     0     D    127.0.0.1  GigabitEthernet1/0/0
    192.168.0.255/32   Direct   0     0     D    127.0.0.1  GigabitEthernet1/0/0
      127.0.0.0/8    Direct   0     0     D    127.0.0.1  InLoopBack0
      127.0.0.1/32   Direct   0     0     D    127.0.0.1  InLoopBack0
127.255.255.255/32   Direct   0     0     D    127.0.0.1  InLoopBack0
255.255.255.255/32   Direct   0     0     D    127.0.0.1  InLoopBack0

        2.3 查看BGP邻居配置是否正确

<Huawei> display current-configuration | include BGP
BGP 65520
 undo synchronization
 peer6.6.6.6 as-number 65520

        2.4 查看BGP路由是否存在,主要是确认BGP路由表中是否存在相关路由

# 查看BGP的所有路由信息。

<Huawei> display bgp routing-table
 BGP Local router ID is 10.1.1.2
 Status codes: * - valid, > - best, d - damped, h - history,
               i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete
 Total Number of Routes: 4
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *    10.1.1.0/24        10.1.1.1        0                     0      100?
 *    10.1.1.2/32        10.1.1.1        0                     0      100?
 *>   10.1.1.0/24        10.1.1.1        0                     0      100?
 *>   10.1.1.0/24        10.1.1.1        0                     0      100?

        2.5 如果BGP路由表中未有相关路由,需要确认BGP邻居是否将相关路由发送出来,华为默认是发不出来的,所以需要看没有发布的路由。

<Huawei> display bgp routing-table peer 1.1.1.1 no-advertise 3.3.3.4 32
 BGP routing table entry information of 3.3.3.4/32:
 From: 1.1.1.1 (10.1.1.1)
 Route Duration: 22h36m17s  
 Relay IP Nexthop: 10.1.1.1
 Relay IP Out-Interface: GigabitEthernet1/0/0
 Original nexthop: 1.1.1.1
 Qos information : 0x0
 AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 1
 No advertise without config reflect-client

        2.6 查看BGP路由表信息,确认BGP路由表中相关路由是否有效

# 查看BGP的所有路由信息。

<Huawei> display bgp routing-table
 BGP Local router ID is 10.1.1.2
 Status codes: * - valid, > - best, d - damped, h - history,
               i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete
 Total Number of Routes: 4
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *    10.1.1.0/24        10.1.1.1        0                     0      100?
 *    10.1.1.2/32        10.1.1.1        0                     0      100?
 *>   10.1.1.0/24        10.1.1.1        0                     0      100?
 *>   10.1.1.0/24        10.1.1.1        0                     0      100?

        2.7 确认BGP路由的下一跳是否存在匹配的路由

# 显示当前路由表的概要信息,查看BGP邻居的IP地址是否存在匹配的路由。

<Huawei> display ip routing-table
Route Flags:
R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 8        Routes : 9

   Destination/Mask  Proto  Pre  Cost  Flags   NextHop   Interface

        10.1.1.1/32   Static  60     0     D    0.0.0.0    NULL0
                     Static  60     0     D    192.168.0.2  GigabitEthernet1/0/0
      192.168.0.0/24   Direct   0     0     D    192.168.0.1  GigabitEthernet1/0/0
      192.168.0.1/32   Direct   0     0     D    127.0.0.1  GigabitEthernet1/0/0
    192.168.0.255/32   Direct   0     0     D    127.0.0.1  GigabitEthernet1/0/0
      127.0.0.0/8    Direct   0     0     D    127.0.0.1  InLoopBack0
      127.0.0.1/32   Direct   0     0     D    127.0.0.1  InLoopBack0
127.255.255.255/32   Direct   0     0     D    127.0.0.1  InLoopBack0
255.255.255.255/32   Direct   0     0     D    127.0.0.1  InLoopBack0

        2.8 查看路由表中,BGP路由是否被选中,或者说相关路由是否有BGP学习到的。

# 显示当前路由表的概要信息,查看BGP邻居的IP地址是否存在匹配的路由。

<Huawei> display ip routing-table 10.1.1.2/32
Route Flags:
R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 1        Routes : 1

   Destination/Mask  Proto  Pre  Cost  Flags   NextHop   Interface

        10.1.1.2/32   OSPF  60     0     D    10.1.1.1   S1/1/0

        2.9 查看路由配置信息,确认在路由表中选中的路由所属的路由协议的优先级

<Huawei> display current-configuration | include ospf
ospf 10 router-id 3.3.3.3
  prefernce  ase 190
area 0.0.0.0
  network 10.10.10.220 0.0.0.255            
 

-----------------------------------------------------

<Huawei> display current-configuration | include bgp

bgp 65520
  router-id 2.2.2.2
  prefernce  170 170 170
  network 10.10.20.220 0.0.0.255

        2.10 查看BGP属性,确认BGP是否优选到正确的路由

# 查看指定无效的BGP路由的详细信息。
<Huawei> display bgp routing-table 1.1.1.1
 BGP local router ID : 10.1.1.1
 Local AS number : 100
 Paths:   2 available, 0 best, 0 select
 BGP routing table entry information of 1.1.1.1/32:
 From: 10.1.1.2 (10.1.1.2)
 Route Duration: 00h01m31s  
 Relay IP Nexthop: 0.0.0.0
 Relay IP Out-Interface: 
 Original nexthop: 20.1.1.2
 Qos information : 0x0
 AS-path 200, origin incomplete, MED 0, localpref 100, pref-val 0, internal, pre 255, invalid for IP unreachable
 Not advertised to any peer yet

 BGP routing table entry information of 1.1.1.1/32:
 From: 2.2.2.2 (10.1.1.2)
 Route Duration: 00h00m51s  
 Relay IP Nexthop: 0.0.0.0
 Relay IP Out-Interface: 
 Original nexthop: 20.1.1.2
 Qos information : 0x0
 AS-path 200, origin incomplete, MED 0, localpref 100, pref-val 0, internal, pre 255, invalid for IP unreachable
 Not advertised to any peer yet

3、小结

        3.1、首先先查邻居状态,在查BGP路由表,查看路由是否存在,是否有效,是否优先,最后查看BGP的属性;最后在查看是否优选了正确的路由

        3.2 常用BGP属性比较顺序:1、比较Locprf属性大小,2、比较AS-Path的长短,3、比较Origin属性,i由于?,4、比较MED属性大小,5、优先选择从EBGP邻居学来的路由