「Huawei VRP」- 配置 BGP 协议

  CREATED BY JENKINSBOT

配置案例

[Huawei] bgp <AS-NUMBER>
[bgp] router-id x.x.x.x
[bgp] peer <IP-ADDRESS> as-number <AS-NUMBER>
[bgp] peer <IP-ADDRESS> connect-interface <lo0>                                 # 当使用回环接口时,需要指定使用该接口
[bgp] network <router-entity>

<R1>display bgp peer
...

<R1>display bgp routing-table
... 

启用调试:

<Huawei> terminal monitor
<Huawei> terminal debugging
<Huawei> debugging bgp event
<Huawei> debugging bgp packet
<Huawei> reset bgp all                                                          # ** 不要随便执行该命令

常用命令

启动 BGP 进程:启动 BGP,指定本地 AS 编号,并进入 BGP 视图。使用 router-id 命令配置 BGP 的 Router ID,建议将 BGP Router ID 配置为设备 Loopback 接口的地址;

[Huawei] bgp { as-number-plain | as-number-dot }
[Huawei-bgp] router-id ipv4-address

// 如果没有配置 Router ID,则 BGP 会自动选取系统视图下的 Router ID 作为 BGP 协议的 Router ID。系统视图下的 Router ID 选择规则,请参见命令 router-id 中的描述;

配置 BGP 对等体:创建 BGP 对等体,指定对等体地址以及 AS 号;

[Huawei-bgp] peer { ipv4-address | ipv6-address } as-number { as-number-plain | as-number-dot }

配置建立对等体使用的源地址、EBGP 对等体最大跳数

[Huawei-bgp] peer ipv4-address connect-interface interface-type interface-number [ ipv4-source-address ]
[Huawei-bgp] peer ipv4-address ebgp-max-hop [ hop-count ]

// 指定发送 BGP 报文的源接口,并可指定发起连接时使用的源地址;
// 指定建立 EBGP 连接允许的最大跳数。缺省情况下,EBGP 连接允许的最大跳数为 1,即只能在物理直连链路上建立 EBGP 连接;

refresh bgp 10.1.2.2 import # 软清

reset bpg 10.1.2.2 # 硬清

对等体表

<R1>display bgp peer
 BGP local router ID : 10.0.1.1
 Local AS number : 100
 Total number of peers : 1                Peers in established state : 1

  Peer              V         AS  MsgRcvd  MsgSent  OutQ      Up/Down            State           PrefRcv

10.0.12.2         4         100    25719    25714        0          0428h32m     Established           1

在设备上通过 display bgp peer 命令查看 BGP 对等体表。BGP 对等体表的作用为列出本设备的 BGP 对等体,以及对等体的状态等信息;

其中主要参数含义:
Peer:对等体地址
V:version,版本号
AS:对等体 AS 号
MsgRcvd 、MsgSent:从对等体收到的报文个数,向对等体发送的报文个数;
OutQ:out queue,对外发送报文队列中排队的个数,一般为 0;
Up/Down:该对等体已经存在 up 或者 down 的时间
State:对等体状态,这里显示的为 BGP 状态机的状态
PrefRcv:prefix received,从该对等体收到的路由前缀数目

路由表

在设备上通过 display bgp routing-table 查看 BGP 路由表:

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

列出本设备发现的所有 BGP 路由,如果到达同一个目的地存在多条路由,则将路由都进行罗列,但每个目的地只会优选一条路由;
Network:路由的目的网络地址以及网络掩码
NextHop:下一跳地址

查看详细的路由信息

通过 display bgp routing-table <ipv4-address> { mask | mask-length} 命令,会将匹配的 BGP 路由信息详细展示:

<R1>display bgp routing-table 10.0.45.0 24
 BGP local router ID : 10.0.1.1
 Local AS number : 100
 Paths:   2 available, 1 best, 1 select
 BGP routing table entry information of 10.0.45.0/24:
 From: 10.0.2.2 (10.0.2.2)                                                      # 标明路由来源
 Route Duration: 06h19m44s 
 Relay IP Nexthop: 10.0.12.2
 Relay IP Out-Interface: GigabitEthernet0/0/0
 Original nexthop: 10.0.4.4                                                     # 路由下一跳地址
 Qos information : 0x0
 AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 2    #路径属性、是否被优选
 Originator:  10.0.4.4
 Cluster list: 10.0.2.2
 Not advertised to any peer yet
 BGP routing table entry information of 10.0.45.0/24:
 From: 10.0.3.3 (10.0.3.3)
 Route Duration: 05h17m56s 
 Relay IP Nexthop: 10.0.12.2
 Relay IP Out-Interface: GigabitEthernet0/0/0
 Original nexthop: 10.0.4.4
 Qos information : 0x0
 AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, valid, internal, pre 255, IGP cost 2, not preferred for peer address
 Originator:  10.0.4.4
 Cluster list: 10.0.3.3
 Not advertised to any peer yet

在其中有关于该 BGP 路由的详细信息,如:路由始发者、下一跳地址、路由的路径属性等;