内部BGP邻居

系列文章

外部BGP配置

BGP实战拓扑

BGP基本配置

BGP基础知识

实验目的

通过对内部IBGP邻居的配置,学习到内部BGP邻居建立的特点,以及内部BGP防环机制和IBGP下一跳问题。同时也将通过实验和学习BGP同步。

实验拓扑

在这里插入图片描述
本次实验由四台路由器完成,其中R1,R2属于AS1,并且内部运行EIGRP作为IGP使用,而R4处于AS2中。其中每台路由器都拥有地址为X.X.X.X/24的环回口。

实验步骤

  1. 首先配置好R1,R2以及R3的接口IP地址,并且保证直连接口的可达性。然后在R1,R2和R3的域内配置好EIGRP 协议,使得相互能够学习到各自的环回口。但注意,R3和R4的直连接口不能加入EIGRP协议中。
  2. 由于IBGP邻居往往存在一个管理域内,而同一个管理域内拥有共同的IGP,所以IBGP邻居关系为了便于稳定,通常采用环回口建立。因此,这里我们让R1和R3建立IBGP邻居关系,并且通过环回口建立。

步骤1的配置

IP地址的配置

R1:
R1#configure  terminal 
R1(config)#int e0/0 
R1(config-if)#ip add 10.10.12.1 255.255.255.0 
R1(config-if)#no sh
R1(config-if)#int loo0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#no sh
R2:
R2#configure terminal 
R2(config)#int e0/1
R2(config-if)#ip add 10.10.12.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int e0/0 
R2(config-if)#ip add 10.10.23.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int loo0
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#no sh
R3:
R3#configure terminal 
R3(config)#int e0/1
R3(config-if)#ip add 10.10.23.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int e0/0
R3(config-if)#ip add 10.10.34.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int loo0
R3(config-if)#ip add 3.3.3.3 255.255.255.0
R3(config-if)#no sh
R4:
R4#configure terminal
R4(config)#int e0/1
R4(config-if)#ip add 10.10.34.4 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int loo0
R4(config-if)#ip add 4.4.4.4 255.255.255.0
R4(config-if)#no sh

EIGRP的配置:

R1R1(config-if)#router eigrp 1
R1(config-router)#no auto-summary 
R1(config-router)#network 1.1.1.0 0.0.0.255 
R1(config-router)#network 10.10.12.0 0.0.0.255
R2R2(config-if)#router eigrp 1
R2(config-router)#no auto-summary 
R2(config-router)#network 2.2.2.0 0.0.0.255 
R2(config-router)#network 10.10.12.0 0.0.0.255
R2(config-router)#network 10.10.23.0 0.0.0.255
R3R3(config-if)#router eigrp 1
R3(config-router)#no auto-summary 
R3(config-router)#network 3.3.3.0 0.0.0.255   
R3(config-router)#network 10.10.23.0 0.0.0.255
R3(config-router)#network 10.10.34.0 0.0.0.255
R4R4(config)#router eigrp 1  
R4(config-router)#no auto-summary 
R4(config-router)#network 4.4.4.4 

步骤2的配置

R1R1(config-router)#router bgp 1		//本地AS号码为1
R1(config-router)#bgp router-id 1.1.1.1		//指定RID为1.1.1.1
R1(config-router)#neighbor 3.3.3.3 remote-as 1		//邻居的AS号码也为1
R1(config-router)#neighbor 3.3.3.3 update-source lo0		//由于采用环回口建立邻居关系,因此需要更改新能源地址,否则TCP连接无法建立
R1(config-router)#exit
R3R3(config-router)#router bgp 1
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 1.1.1.1 remote-as 1 
R3(config-router)#neighbor 1.1.1.1 update-source lo0
R3(config-router)#exit

上面的配置对比EBGP邻居配置,少了EBGP多跳,因为IBGP之间发送的数据包的默认的TTL值设置的较大,不需要对TTL值进行更改。
稍等片刻,则出现R1和R3之间邻居建立的日志。
*Mar 1 02:24:56.171: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 Up
*Mar 1 02:24:56.391: %BGP-5-ADJCHANGE: neighbor 1.1.1.1 Up

对IBGP邻居关系进行查看:

R1#sh ip bgp summ
BGP router identifier 1.1.1.1, local AS number 1
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
3.3.3.3         4     1      10      10        1    0    0 00:06:52        0

由于出现的邻居关系3.3.3.3的AS号一致,因此为IBGP邻居。

R1#sh ip bgp neighbors 3.3.3.3
BGP neighbor is 3.3.3.3,  remote AS 1, internal link
  BGP version 4, remote router ID 3.3.3.3
  BGP state = Established, up for 00:10:15
  Last read 00:00:15, last write 00:00:15, 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

上面是通过命令show ip bgp neighbor 3.3.3.3 显示的部分输出。也能够通过标记部分明确邻居3.3.3.3是内部BGP邻居关系。

步骤3的配置

  1. 在R3和R4之间建立EBGP邻居关系,采用直连接口建立。之后在R4上将R4的环回口路由加入到BGP进程中。
R3R3(config)#router bgp 1
R3(config-router)#neighbor 10.10.34.4 remote-as 2
R3(config-router)#exit
R4R4(config)#router bgp 2   
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#neighbor 10.10.34.3 remote-as 1
R4(config-router)#network 4.4.4.0 
R4(config-router)#network 4.4.4.0 mask 255.255.255.0 
R4(config-router)#exit

之后在R3的BGP表,显示如下:

R3#show ip bgp 
BGP table version is 2, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 4.4.4.0/24       10.10.34.4               0             0 2 i

从上面的内容可以看到,R3已经学习到R4通告过来的关于其环回口的路由,并且被使用为最佳路由。同时该路由的下一跳为10.10.34.4,说明外部BGP发送更新时,下一跳属性为发出接口的IP地址。同时AS-PATH属性显示为2,说明该路由从AS 2产生。

对于 AS-PATH属性而言,有两个主要作用:
| 如果在路由器进行选择时,优先考虑AS-PATH属性短的。代表该路由穿越的AS区域少。
| 同时对于EBGP而言,AS-PATH属性还能够防环。如果某BGP路由器从EBGP邻居收到某条路由,并且AS-PATH属性中包含自己本地AS的话,那么该路由将会被拒收。AS-PATH属性只有在离开AS时才会由边缘BGP路由写入。在AS内部传递时不更改。

那么在AS内部BGP如何防止环路?
查看R1的BGP表项。

R1#sh ip bgp  
BGP table version is 2, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i4.4.4.0/24       10.10.34.4               0    100      0 2 i

我们可以看到在R1上虽然收到了来于R3所告知的4.4.4.0/24的路由,但是该路由器并没有将本条路由作为’best".

R1:
R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 remote-as 1
R1(config-router)#neighbor 2.2.2.2 update-source lo0
R1(config-router)#exit
R2R2(config-router)#router bgp 2 
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 1.1.1.1 remote-as 1   
R2(config-router)#neighbor 1.1.1.1 update-source lo0
R2(config-router)#exit

然后再次查看R2的BGP表项:

R2#show ip bgp

R2#

R2此时表项为空,说明R1并没有把关于R4的路由发给R2。

回到R1显示的BGP表项,我们发现下一跳属性为10.10.34.4,和在R3上的属性一致。这说明IBGP邻居之间发送路由更新时不会更改下一跳属性。
而对于R1而言,10.10.34.4这个地址不可达,因此这条下一跳不可达的路由不能成为“best”。

对于这种情况,往往我们可以在IBGP邻居建立时显示的更改这个行为。使得IBGP发送更新时将下一跳属性更改为自己,这样就不会出现下一跳不可达的现象了。
我们在R3上,对R2发送更新时下一跳更改为自己。

R3(config)#router bgp 1
R3(config-router)#neighbor 1.1.1.1 next-hop-self	//更改下一跳为自己
R3(config-router)#exit

然后再次回到R1的BGP表,结果如下:

R1#show ip bgp 
BGP table version is 3, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i4.4.4.0/24       3.3.3.3                  0    100      0 2 i

这里可以看到,R1将到R4的路由显示为“best”。下一跳属性也相应更改。

接着在R2上的BGP表示查看。

R2#show ip bgp

R2#

依然为空。
这里需要注意两个重要的问题:

  • BGP路由器只会发送最优路由给邻居,不管是EBGP还是IBGP。
  • 由于BGP内部没有相关属性能防止环路,因此为了避免BGP路由在域内产生环路,所以BGP路由器不会将IBGP路由发给另一个IBGP路由器。

在本例中,R1从IBGP邻居R3上学习到的R4路由,所以它为了防止环路,不会将该路由再次发给另一个IBGP路由器,即R2.所以R2上收不到关于R4的路由。

步骤4的配置

  1. 现在我们再来关注下R1到达R4的情况。
    我们首先将R1的环回口一样加入到BGP进程中,使得R4也能学习到1.1.1.0/24的路由。
R1(config)#router bgp 1
R1(config-router)#network 1.1.1.0 mask 255.255.255.0
R1(config-router)#exit

在这里插入图片描述
现在R1和R4相互有对方的路由。我们在R1上使用1.1.1.1去ping4.4.4.4,验证连通性。

R1#ping 4.4.4.4 source lo0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1 
UUUUU
Success rate is 0 percent (0/5)
R1#

得到的结果是目标不可达。
分析原因,虽然R1,R3都知道如何到达4.4.4.4,但是中间的R2却没有关于4.4.4.0/24的路由。因此当ping包发送至R2时,R2由于找不到如何去往4.4.4.4,所以选择丢包。

我们在R1上做上述改动。

R1(config)#router bgp 1
R1(config-router)#synchronization	//开启BGP同步
R1(config-router)#exit
R1(config)#

然后再重置下R1的BGP连接。
在这里插入图片描述
接着查看R1的BGP表项:

R1#show ip bgp
BGP table version is 2, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.0/24       0.0.0.0                  0         32768 i
* i4.4.4.0/24       3.3.3.3                  0    100      0 2 i

此时R4的路由已经去除了“best”标记。

这就是著名的BGP同步。
BGP同步的概念是:不会把来自于IBGP对1路由作为最优,除非该路由已经通过IGP学习到了或者已经存在 在路由表中。

由于R1开启了同步,因此R4的路由无法作为“bset”使用。这样也就使得R1根本无法再路由表中插入R4的路由。
结合之前在R2上丢包的实验,这种路由黑洞将不会发送,如果同步开启的话。

同步的作用就是防止发生上述的路由黑洞。
但往往现在我们默认是关闭的,因此为了避免路由黑洞,我们对于IBGP邻居必须要进行全互连。

最后我们将R1的同步关闭,然后使得AS 1域内的IBGP连接达到全互连。即添加上R2和R3的IBGP连接。

R1R1(config)#router bgp 1
R1(config-router)#no synchronization
R1(config-router)#exit
R2R2(config)#router bgp 1
R2(config-router)#neighbor 3.3.3.3 remote-as 1
R2(config-router)#neighbor 3.3.3.3 update-source lo0
R2(config-router)#exit
R3R3(config)#router bgp 1
R3(config-router)#neighbor 2.2.2.2 remote-as 1
R3(config-router)#neighbor 2.2.2.2 update-source lo0
R3(config-router)#neighbor 2.2.2.2 next-hop-self	//更改下一跳命令
R3(config-router)#exit

在一切完成后,接着再在R1上使用1.1.1.1去ping4.4.4.4,查看连通性。
在这里插入图片描述
此时就已经能够正常通信了。

  • 31
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 21
    评论
评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

牧鸯人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值