28. Configuring Basic BGP

1、掌握BGP的基本配置方法。 
2、掌握如何查看BGP的各种配置信息。 
 
拓扑图:

image.png


配置好各个路由器的IP地址等基本信息,测试互连可达。

 

配置BGP路由协议:

R1(config)#router bgp 64512  ---->启用AS 64512自治系统的BGP路由
R1(config-router)#neighbor 172.16.255.2 remote-as 64512   ----->确定邻居和邻居的AS号
R1(config-router)#network 172.16.255.0 mask 255.255.255.252   
R1(config-router)#network 172.16.0.0 mask 255.255.255.0   ---->向BGP中注入带有具体长度的子网络路由
R1(config-router)#network 172.16.1.0 mask 255.255.255.0
R1(config-router)#network 172.16.2.0 mask 255.255.255.0
R1(config-router)#network 172.16.3.0 mask 255.255.255.0
R1(config-router)#exit

——配置邻居AS号的目的是为了与本地路由器所在AS号比较,确定需要创建的是iBGRP还是eBPRG的邻居

R2(config)#router bgp 64512
R2(config-router)#neighbor 172.16.255.1 remote-as 64512
R2(config-router)#neighbor 10.1.255.2 remote-as 64513   ----->由于指定的路由器的AS号与地址不同,所以此邻居将被
R2(config-router)#network 172.16.255.0 mask 255.255.255.252   识别为eBGP的邻居对等体关系
R2(config-router)#network 10.1.255.0 mask 255.255.255.252
R2(config-router)#exit

 

R3(config)#router bgp 64513
R3(config-router)#neighbor 10.1.255.1 remote-as 64512
R3(config-router)#network 10.1.255.0 mask 255.255.255.252
R3(config-router)#network 192.168.0.0  ---->向BGP中注入直连路由,不带子网掩码的配置方法
R3(config-router)#network 192.168.1.0
R3(config-router)#network 192.168.2.0
R3(config-router)#network 192.168.3.0
R3(config-router)#exit

 

查看BGP的邻居关系:

R1#show ip bgp nei
BGP neighbor is 172.16.255.2,  remote AS 64512, internal link  ------->指出当前BGP的对等体的route id,以及对等体所
  BGP version 4, remote router ID 172.16.255.2             处的AS编号和邻居关系为iBGP关系    
  BGP state = Established, up for 00:12:06    ----->邻居关系的状态            

  Last read 00:00:06, last write 00:00:06, hold time is 180, keepalive interval is 60 seconds ----->两个计时器
  Neighbor capabilities:
    Route refresh: advertised and received(old & new)
    Address family IPv4 Unicast: advertised and received
  Message statistics:
    InQ depth is 0
    OutQ depth is 0
                         Sent       Rcvd
    Opens:                  1          1
    Notifications:          0          0
    Updates:                1          3
    Keepalives:            15         15
    Route Refresh:          0          0
    Total:                 17         19  ------->BGP的几种数据包的发送接收数量
  Default minimum time between advertisement runs is 5 seconds

 

查看简洁的BGP汇总信息:

R2#show ip bgp summary
BGP router identifier 172.16.255.2, local AS number 64512
BGP table version is 13, main routing table version 13
10 network entries using 1170 bytes of memory
12 path entries using 624 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 2314 total bytes of memory
BGP activity 10/0 prefixes, 12/0 paths, scan interval 60 secs

Neighbor       V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.255.2     4 64513     23    23     13    0    0 00:17:18      5
172.16.255.1    4 64512    24    26      13    0    0 00:19:52      5

BGP的对等体列表,目前State列显示数字,表示从此对等体学习到路由的数量。

其中State一列,还会出现:IDLE,ACTIVE状态,IDLE表示地等体关系还未建立。

ACTIVE状态邻居关系表示BGP协议正在处于邻居创建过程中,但此时邻居关系尚未完成创建。

 

查看R1的路由表:

R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
C       172.16.255.0/30 is directly connected, Serial0/0
C       172.16.0.0/24 is directly connected, Loopback0
C       172.16.1.0/24 is directly connected, Loopback1
C       172.16.2.0/24 is directly connected, Loopback2
C       172.16.3.0/24 is directly connected, Loopback3
     10.0.0.0/30 is subnetted, 1 subnets
B       10.1.255.0 [200/0] via 172.16.255.2, 00:24:29
B    192.168.0.0/24 [200/0] via 10.1.255.2, 00:21:51
B    192.168.1.0/24 [200/0] via 10.1.255.2, 00:21:52
B    192.168.2.0/24 [200/0] via 10.1.255.2, 00:21:52
B    192.168.3.0/24 [200/0] via 10.1.255.2, 00:21:52  ---->从BGP学习到的路由
R1#ping 192.168.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/64/100 ms

 

关于清除命令:

R1#clear ip bgp * 
  ——清除BGP的路由表,邻居关系重置
R1#clear ip bgp 172.16.255.2 
   ——仅对某一对等体的BGP会话进行重置
R1#clear ip bgp * soft

  ——软清除命令,本命令可以直接刷路由表,而不重置BGP的邻居关系,即不会重置TCP的连接关系

 


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

桂ICP备19000498号-3