BGP的基本配置

一、实验内容

  1. BGP基本配置
    2.使用loopback接口地址配置BGP
    3.配置BGP对等体组

实验任务一 BGP基本配置
实验拓扑图
在这里插入图片描述
实验步骤及要求
1.配置各台路由器的IP地址,并且使用Ping命令确认各路由器的直连口的互通性。

2.在R1、R2和R3配置BGP路由协议,具体配置如下:
R1(config)#router bgp 64512
//启用AS 64512自动系统的BGP路由
R1(config-router)#neighbor 172.16.255.2 remote-as 64512
//确定邻居以及邻居的AS号,配置邻居的AS号的目的,是为了与本地路由器所在AS号进行比较,确定需要创建是iBGP还是eBGP的邻居。
R1(config-router)#network 172.16.255.0 mask 255.255.255.252
//向BGP中注入带有具体长度的直连网络路由。
R1(config-router)#network 172.16.0.0 mask 255.255.255.0
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

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
//由于指定的10.1.255.2路由器的AS号与地址不同,所以此邻居将被识别为eBGP的邻居对等体关系。
R2(config-router)#network 172.16.255.0 mask 255.255.255.252
R2(config-router)#network 10.1.255.0 mask 255.255.255.252

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
R3(config-router)#network 192.168.1.0
R3(config-router)#network 192.168.2.0
R3(config-router)#network 192.168.3.0
//向BGP中注入直连路由,不带子网掩码的配置方法。

3.查看BGP的邻居关系。
R1#show ip bgp neighbors
BGP neighbor is 172.16.255.2, remote AS 64512, internal link
//指出当前的BGP的对等体的route id,以及对等体所处的AS编号,及邻居关系为iBGP关系。
BGP version 4, remote router ID 172.16.255.2
BGP state = Established, up for 00:29:25 //邻居关系的状态。
Last read 00:00:24, hold time is 180, keepalive interval is 60 seconds
//HoldTime和Keepalive计时器,其主要的作用是维持邻居关系。
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 4
Keepalives: 32 32
Route Refresh: 0 0
Total: 34 37
// BGP的几种数据包的发送接收数量。
Default minimum time between advertisement runs is 5 seconds
…………

4.查看简洁BGP汇总信息。
R2#show ip bgp summary
BGP router identifier 172.16.255.2, local AS number 64512
BGP table version is 19, main routing table version 19
10 network entries using 1010 bytes of memory
11 path entries using 528 bytes of memory
3 BGP path attribute entries using 180 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 1742 total bytes of memory
BGP activity 14/4 prefixes, 16/5 paths, scan interval 60 secs

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.255.2 4 64513 47 49 19 0 0 00:10:15 5
172.16.255.1 4 64512 42 45 19 0 0 00:37:53 4
BGP的对等体列表。目前State列显示数字,表示从此对等体学习到路由的数量。
其中State一列还会出现:
IDLE,ACTIVE状态。
IDLE状态表示,对等体关系尚未建立。
ACTIVE状态邻居关系表示BGP协议正在处于邻居创建过程中,但此时邻居关系尚未完成创建。

5.查看R1的路由表。
R1#show ip 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, FastEthernet0/0
C 172.16.0.0/24 is directly connected, Loopback0
C 172.16.1.0/24 is directly connected, Loopback0
C 172.16.2.0/24 is directly connected, Loopback0
C 172.16.3.0/24 is directly connected, Loopback0
10.0.0.0/30 is subnetted, 1 subnets
B 10.1.255.0 [200/0] via 172.16.255.2, 00:48:22
B 192.168.0.0/24 [200/0] via 10.1.255.2, 00:22:27
B 192.168.1.0/24 [200/0] via 10.1.255.2, 00:22:27
B 192.168.2.0/24 [200/0] via 10.1.255.2, 00:22:27
B 192.168.3.0/24 [200/0] via 10.1.255.2, 00:22:27
//BGP学习的路由。

6.在R1、R2和R3上配置BGP邻居身份验证
以R1为例,命令如下:
R1(config)#router bgp 64512
R1(config-router)#neighbor 172.16.255.2 password cisco123
R2和R3配置BGP邻居身份验证命令。

查看R1的路由表。

7.其他命令。
R1#clear ip bgp *
//清除BGP的路由表,邻居关系重置。
R1#clear ip bgp 172.16.255.2
//仅针对172.16.255.2对等体的BGP会话进行重置。
R1#clear ip bgp * soft
//软清除命令。本条命令可以直接刷路由表,而不重置BGP的邻居关系,即不会重置TCP的连接关系。

实验任务二 使用loopback接口地址配置BGP
实验拓扑图
在这里插入图片描述
实验步骤及要求
1.配置各台路由器的IP地址,并且使用Ping命令确认各路由器的直连口的互通性。。

2.在R1和R2上使用回环口创建邻居关系,配置如下
R1(config)#router bgp 64512
R1(config-router)#network 172.16.0.0 mask 255.255.255.0
R1(config-router)#network 172.16.1.0 mask 255.255.255.0
R1(config-router)#network 172.16.255.0 mask 255.255.255.252
R1(config-router)#neighbor 172.16.16.1 remote-as 64512
//创建BGP对等体,使用R2回环口的地址。
R2(config)#router bgp 64512
R2(config-router)#network 172.16.255.0 mask 255.255.255.252
R2(config-router)#network 10.1.255.0 mask 255.255.255.252
R2(config-router)#neighbor 172.16.0.1 remote-as 64512
//使用R1的回环口地址创建邻居关系

3.查看R1和R2的BGP Summary信息。
R1#show ip bgp summary

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
172.16.16.1 4 64512 0 0 0 0 0 never Active
//Active状态指出此时BGP正在尝试创建邻居关系

R2#show ip bgp summary

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
172.16.0.1 4 64512 0 0 0 0 0 never Active

原因1:no route,即没有路由可以到达邻居的回环口,无法进行TCP的三次握手。

  1. 配置RIP路由协议
    由于R1和R2是同一个自治系统,所以我们使用RIPv2协议来解决路由不可达的问题
    R1(config)#router rip
    R1(config-router)#version 2
    R1(config-router)#network 172.16.0.0
    R1(config-router)#no auto-summary
    R2(config)#router rip
    R2(config-router)#version 2
    R2(config-router)#network 172.16.0.0
    R2(config-router)#no auto-summary
    查看R1和R2的BGP Summary信息,此时还是Active状态。
    原因2:发送方路由器的更新源地址要和接收方路由器neighbor命令所指定的地址相同,路由器默认的更新源地址是路由器到达邻居的出接口地址,不是loopback接口地址,所以不一致,BGP邻居无法建立。
    R1(config)#router bgp 64512
    R1(config-router)#neighbor 172.16.16.1 update-source loopback 0
    指定更新源地址,使用本地回环口创建邻居关系。
    R2(config)#router bgp 64512
    R2(config-router)#neighbor 172.16.0.1 update-source loopback 0
    再次查看R1的BGP Summary信息
    R1#sh ip bgp summary
    Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
    172.16.16.1 4 64512 5 5 6 0 0 00:00:20 2
    已经成功的创建对等体关系。
    5.配置R2与R3使用回环口创建eBGP邻居关系。
    R2(config)#router bgp 64512
    R2(config-router)#neighbor 192.168.0.1 remote-as 64513
    R2(config-router)#neighbor 192.168.0.1 update-source loopback 0
    R2(config-router)#neighbor 192.168.0.1 ebgp-multihop 2
    //配置eBGP多跳
    R2(config-router)#exit
    R2(config)#ip route 192.168.0.1 255.255.255.255 10.1.255.2
    //由于R2与R3处于不同的自治系统中,所以建立配置静态路由。
    R3(config)#router bgp 64513
    R3(config-router)#neighbor 172.16.16.1 remote-as 64512
    R3(config-router)#neighbor 172.16.16.1 update-source loopback 0
    R3(config-router)#neighbor 172.16.16.1 ebgp-multihop 2
    R3(config-router)#network 192.168.0.0
    R3(config-router)#network 192.168.1.0
    R3(config-router)#network 10.1.255.0 mask 255.255.255.252
    R3(config-router)#exit
    R3(config)#ip route 172.16.16.1 255.255.255.255 10.1.255.1
    在R2上观察BGP的邻居关系状态。
    R2#show ip bgp summary
    Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
    172.16.0.1 4 64512 19 20 9 0 0 00:14:11 2
    192.168.0.1 4 64513 5 6 9 0 0 00:00:10 3
    6.在R2上配置下一跳。
    R2(config)#router bgp 64512
    R2(config-router)#neighbor 172.16.0.1 next-hop-self 配置下一跳为自己,即对从EBGP邻居传入的路由,在通告给IBGP邻居时,强制使路由器通告自己是发送BGP更新的下一跳,而不是EBGP邻居。因为当路由通过EBGP注入到AS时,从EBGP获得下一跳地址会被不变地在IBGP中传递。
    7.查看R1的路由表。
    R1#show ip route

实验任务三 配置BGP对等体组
对上面拓扑图进行修改,新增路由器R4,将R4连接到R1,地址自行规划,将R2到R1对等体的BGP配置删除,通过对等体组来实现
R2(config)#router bgp 64512
R2(config-router)#neighbor cisco peer-group 创建对等体组,对等体组名称cisco
R2(config-router)#neighbor cisco remote-as 64512 定义对等体组策略
R2(config-router)#neighbor cisco update-source loopback 0
R2(config-router)#neighbor cisco next-hop-self
R2(config-router)#neighbor 172.16.0.1 peer-group cisco 将邻居172.16.0.1加入对等体组
将邻居R4加入对等体组,命令_____________________________________________。
查看对等体组的信息。
R2#show ip bgp peer-group cisco

查看R1的路由表。

  • 1
    点赞
  • 67
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值