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的路由明细


相关推荐
晚秋大魔王4 小时前
windwos与linux环境下Iperf3带宽测试工具的安装、使用
网络·iperf3·带宽测试
多敲代码防脱发4 小时前
Spring框架基本使用(Maven详解)
java·网络·后端·spring·maven
wssswsss5 小时前
docker容器网络配置及常用操作
网络·docker·容器
RFID舜识物联网5 小时前
RFID测温技术:电力设备安全监测的新利器
网络·人工智能·嵌入式硬件·物联网·安全
靖节先生6 小时前
Wireshark详解
网络·测试工具·wireshark
技术小齐8 小时前
网络运维学习笔记 021 HCIA-Datacom新增知识点02 SDN与NFV概述
运维·网络·学习
ZachOn1y10 小时前
计算机网络:应用层 —— 域名系统 DNS
网络·计算机网络·应用层·408考研·知识积累·域名系统dns
给生活加糖!11 小时前
智能交通系统(Intelligent Transportation Systems):智慧城市中的交通革新
网络·人工智能·智慧城市
人间打气筒(Ada)11 小时前
ubuntu网络及软件包管理
网络·ubuntu·php
明达技术12 小时前
工控自动化领域:数字量信号与模拟量信号的差异解析
网络