BGP基本配置

一、知识补充

1、BGP

BGP是Border Gateway Protocol(边界网关协议)的缩写。它是用于在互联网中交换路由信息的一种协议。BGP被广泛应用于大规模的自治系统(AS)之间,用于实现跨网络的路由选择和交换。

BGP的主要功能是在不同的自治系统之间传递路由信息,帮助确定最佳的路径来转发数据包。它使用一系列的路由策略和属性来选择和优化路由,以确保数据能够有效地从源地址到目的地址进行传输。

BGP协议具有以下特点:

  1. 可靠性:BGP通过使用TCP协议建立可靠的连接来交换路由信息,并确保路由的稳定性和可达性。
  2. 可扩展性:BGP支持大规模网络的路由交换,能够处理成千上万个路由器和自治系统之间的复杂路由关系。
  3. 灵活性:BGP允许网络管理员根据自己的需求配置路由策略,以实现特定的路由选择和控制机制。
  4. 多路径选择:BGP可以同时维护多条到达相同目的地的路由路径,并根据各种属性选择最佳路径。

2、IBGP水平分割原则

IBGP水平分割原则

在AS内部,也有可能环路的

在R1、R2、R3、R4内部运行IBGP协议,R1将1.1.1.1传递给R2,R2传递给R3,R3传递R4,R4传递给R1,这样在AS100内部就形成了环路。

AS内部防环

设计了IBGP的水平分割原则,一个路由器从它的IBGP邻居学习到的路由,不会再传递给下一个IBGP邻居

R1通过EBGP学习到了RA的路由,R2通过IBGP学习到了R1的路由,但是R2不能把从R1学到的路由传递给R3。因为R1、R2、R3在同一个AS内,基于IBGP水平分割原则:一个路由器从它学到的IBGP邻居学到的路由,不能再传给下一个IBGP邻居。IBGP水平分割在AS内虽然防止了环路,但是带来新问题,就是路由无法传递

一般把边界路由器配置成路由反射器,以防止BGP路由黑洞,防止水平分割

二、配置需求及拓扑图

  • loopback 0地址为x.x.x.x/32(x为设备号)
  • R2、R3间运行OSPF协议,进程号为1,归属区域0,需要发布loopback地址。
  • R2、R3间部署IBGP,AS号为100,使用Loopback接口建立邻居关系。
  • R1和R2间运行EBGP,R1使用AS号为200,R2的AS号为100,使用互联接口建立邻居关系
  • R3和R4间运行EBGP,R4使用AS号为300,R3的AS号为100,使用互联接口建立邻居关系
  • 实现全网互通

三、配置步骤

1、OSPF配置

R2

tex 复制代码
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
Change router-id and update OSPF process! [yes/no]:y 
R2(config-router)#network 102.1.1.0 0.0.0.255 area 0
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0
R2(config-router)#exit

R3

tex 复制代码
R3(config)#router ospf 1 
R3(config-router)#router-id 3.3.3.3    
Change router-id and update OSPF process! [yes/no]:y
R3(config-router)#network 3.3.3.3 0.0.0.0 area 0
R3(config-router)#network 102.1.1.0 0.0.0.255 area 0
R3(config-router)#exit
验证-查看邻居关系的建立

2、BGP配置

R1

tex 复制代码
R1(config)#router bgp 200
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 101.1.1.2 remote-as 100       
R1(config-router)#exit

R3

tex 复制代码
R2(config)#router bgp 100
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 101.1.1.1 remote-as 200
R2(config-router)#neighbor 3.3.3.3 remote-as 100
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0
R2(config-router)#exit

R3

tex 复制代码
R3(config)#router bgp 100
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 103.1.1.2 remote-as 300
R3(config-router)#neighbor 2.2.2.2 remote-as 100
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0
R3(config-router)#exit

R4

tex 复制代码
R4(config)#router bgp 300
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#neighbor 103.1.1.1 remote-as 100
R4(config-router)#exit
验证-R2上查看BGP的邻居

3、路由引入

宣告网段的两种方式

  • BGP中引入直连路由
  • BGP中Network宣告接口

这里使用引入直连路由

R1

tex 复制代码
R1(config)#router bgp 200 
R1(config-router)#redistribute connected 
R1(config-router)#exit

R2

tex 复制代码
R2(config)#router bgp 100
R2(config-router)#redistribute connected 
R2(config-router)#exit

R3

tex 复制代码
R3(config)#router bgp 100 
R3(config-router)#redistribute connected 
R3(config-router)#exit

R4

tex 复制代码
R4(config)#router bgp 300 
R4(config-router)#redistribute connected 
R4(config-router)#exit
验证-在R1上查看BGP路由明细
验证-在R4上查看BGP路由明细

4、最后分析

可以发现,R1学习不到R3的loopback地址,R4学习不到R2的loopback地址,是因为BGP的水平分隔的问题。可以将OSPF路由引入到BGP中来解决这个问题

R2

tex 复制代码
R2(config)#router bgp 100
R2(config-router)#redistribute ospf 1
R2(config-router)#exit

R3

tex 复制代码
R3(config)#router bgp 100
R3(config-router)#redistribute ospf 1
R3(config-router)#exit
验证-在R1和R4上查看BGP的路由明细


相关推荐
pemper_1 小时前
怎么操作使http变成https访问?
网络·网络协议·http·https·ssl
蒙奇·D·路飞-2 小时前
古诗词四首鉴赏
网络
Run_Snails2 小时前
hcia-openEuler V1.0师资题库-试卷3
运维·服务器·网络
学java的小菜鸟啊3 小时前
第五章 网络编程 TCP/UDP/Socket
java·开发语言·网络·数据结构·网络协议·tcp/ip·udp
新手嵌入式学习3 小时前
网络协议头分析
网络·网络协议
运维Z叔5 小时前
云安全 | AWS S3存储桶安全设计缺陷分析
android·网络·网络协议·tcp/ip·安全·云计算·aws
weixin_456732595 小时前
网络-内核是如何与用户进程交互
网络·交互
爱吃涮毛肚的肥肥(暂时吃不了版)5 小时前
计算机网络34——Windows内存管理
网络·计算机网络·udp
码哝小鱼6 小时前
firewalld封禁IP或IP段
linux·网络
sec0nd_6 小时前
1网络安全的基本概念
网络·安全·web安全