这几天由于去学历考试,几天没写博客了。今天把bgp做了一下,配置比较简单,但当中有一些细节还是值得看的,好了下面就来做一下bgp的实验:
 
 
一、拓扑图:
 
二、详细配置及说明:
1
、配置各路由器的IP地址,保证直连链路的直通性,确保有TCP的连接
2
、在R1上的配置:
R1(config)#router bgp 64600 (启用bgp)
R1(config-router)#nei 172.16.255.2 remote 64600 (指定bgp 对端邻居,AS号为了区分ibgpebgp)
R1(config-router)#net 172.16.255.0 mask 255.255.255.252(注入直连网络,无类地址中带掩码发布)
R1(config-router)#net 172.16.1.0 mask 255.255.255.0
R1(config-router)#net 172.16.2.0 mask 255.255.255.0
R1(config-router)#net 172.16.3.0 mask 255.255.255.0
3、R2上的配置,由于R2有两个直连的路由,所以要指定两个邻居:
R2(config-router)#nei 172.16.255.1 remote 64600
R2(config-router)#nei 10.1.255.2 remote 64800
R2(config-router)#net 172.16.255.0 mask 255.255.255.252(无类地址带有掩码发布)
R2(config-router)#network 10.1.255.0 mask 255.255.255.252
4 、在R3上的配置:
R3(config)#router bgp 64513
R3(config-router)#neighbor 10.1.255.1 remote-as 64800
R3(config-router)#network 10.1.255.0 mask 255.255.255.252
R3(config-router)#network 192.168.0.0  (有类地址,我没有带掩码发布)
R3(config-router)#network 192.168.1.0
R3(config-router)#network 192.168.2.0
R3(config-router)#network 192.168.3.0
 
5 、在R2上查看一下bgp的路由表:
R2#sh ip route bgp
     172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
B       172.16.0.0/24 [200/0] via 172.16.255.1, 00:08:50
B       172.16.1.0/24 [200/0] via 172.16.255.1, 00:08:50
B       172.16.2.0/24 [200/0] via 172.16.255.1, 00:08:50
B       172.16.3.0/24 [200/0] via 172.16.255.1, 00:08:50
B    192.168.0.0/24 [20/0] via 10.1.255.2, 00:07:32
B    192.168.1.0/24 [20/0] via 10.1.255.2, 00:07:32
B    192.168.2.0/24 [20/0] via 10.1.255.2, 00:07:32
B    192.168.3.0/24 [20/0] via 10.1.255.2, 00:07:32
6 、查看一下简单的bgp汇总信息:
R2#sh ip bgp summary
BGP router identifier 172.16.255.2, local AS number 64600
BGP table version is 11, main routing table version 11
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 64800      33      34       11    0    0 00:28:14        5
172.16.255.1    4 64600      34      35       11    0    0 00:29:31        5(通过邻居学到的路由数量。)
7 、在BGPclear ip bgp * 会造成邻居的down 然后再up的过程。但可以用clear ip bgp *soft 软清除命令去涮新bgp路由表而不会重置邻居关系,因为BGP建立邻居是要基于TCP连接的,所以TCP连接不会重置。
R1#clear ip bgp *
R1#
*Mar  1 00:52:32.927: %BGP-5-ADJCHANGE: neighbor 172.16.255.2 Down User reset
R1#
*Mar  1 00:52:33.959: %BGP-5-ADJCHANGE: neighbor 172.16.255.2 Up     (邻居关系重置了)
 
R1#clear ip bgp * soft
R1#                               (邻居关系没有重置)
 
8、查看bgp的邻居:
R1#show ip bgp neighbors
BGP neighbor is 172.16.255.2,  remote AS 64600, internal link(指出了bgp邻居和AS号且是IBGP)
  BGP version 4, remote router ID 172.16.255.2
  BGP state = Established, up for 00:25: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:                  2          2
    Notifications:          0          0
    Updates:                3          6
    Keepalives:            67         67
    Route Refresh:          1          0
    Total:                 73         75               (bgp几种数据包发送和接收数量)
  Default minimum time between advertisement runs is 0 seconds
……………………
R1#
三、通过上面的配置,我们了解了bgp的基本配置以及如何去查看一些bgp的路由特性。