配置BGP与IGP交互示例
配置BGP和IGP的交互,可以丰富协议路由表。
组网需求
通信业务的发展,要求能够在广泛的区域实现互访,并且数据传输可靠,中断时间短,这就要求路由的传播区域广,收敛速度快。BGP可以实现路由的高效广泛传播,但是BGP自身不会计算路由。IGP可以实现路由的快速收敛,但是IGP的路由传播效率低,范围小。配置BGP与IGP交互后,IGP路由可以被引入到BGP路由表进行高效广泛的传播,BGP路由也可以被引入到IGP路由表,实现对其他AS的访问。
如图1所示,用户将网络划分为AS65008和AS65009,在AS65009内,使用IGP协议来计算路由(该例使用OSPF做为IGP协议)。为了实现两个AS之间的互访,可以在AS之间配置BGP协议,在AS边缘路由器上配置BGP与IGP交互,这样既可以利用BGP高效的把路由传递到其他AS,也可以把AS外部的路由引入到IGP,实现对AS外部的访问。
配置思路
采用如下的思路配置BGP与IGP交互:
1、在DeviceB和DeviceC上配置OSPF协议。
2、在DeviceA和DeviceB上配置EBGP连接。
3、在DeviceB上配置BGP与OSPF互相引入,查看路由信息。
4、在DeviceB上配置BGP路由聚合,简化BGP路由表。
数据准备
为完成此配置例,需准备如下的数据:
1、DeviceA的Router ID以及所在AS号。
2、DeviceB、DeviceC的Router ID以及所在AS号。
操作步骤
1、配置各接口的IP地址
2、配置OSPF
# 配置DeviceB。
1 2 3 4 5 6 | [~DeviceB] ospf 1 [*DeviceB-ospf-1] area 0 [*DeviceB-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [*DeviceB-ospf-1-area-0.0.0.0] commit [~DeviceB-ospf-1-area-0.0.0.0] quit [~DeviceB-ospf-1] quit |
# 配置DeviceC。
1 2 3 4 5 6 7 | [~DeviceC] ospf 1 [*DeviceC-ospf-1] area 0 [*DeviceC-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [*DeviceC-ospf-1-area-0.0.0.0] network 10.1.2.0 0.0.0.255 [*DeviceC-ospf-1-area-0.0.0.0] commit [~DeviceC-ospf-1-area-0.0.0.0] quit [~DeviceC-ospf-1] quit |
3、配置EBGP连接
# 配置DeviceA。
1 2 3 4 5 6 | [~DeviceA] bgp 65008 [*DeviceA-bgp] router-id 1.1.1.1 [*DeviceA-bgp] peer 172.16.1.1 as -number 65009 [*DeviceA-bgp] ipv4-family unicast [*DeviceA-bgp-af-ipv4] network 192.168.1.0 255.255.255.0 [*DeviceA-bgp-af-ipv4] commit |
# 配置DeviceB。
1 2 3 4 | [~DeviceB] bgp 65009 [*DeviceB-bgp] router-id 2.2.2.2 [*DeviceB-bgp] peer 172.16.1.2 as -number 65008 [*DeviceB-bgp] commit |
4、配置BGP与IGP交互
# 在DeviceB上配置BGP引入OSPF路由。
1 2 3 4 5 | [~DeviceB-bgp] ipv4-family unicast [*DeviceB-bgp-af-ipv4] import-route ospf 1 [*DeviceB-bgp-af-ipv4] commit [~DeviceB-bgp-af-ipv4] quit [~DeviceB-bgp] quit |
# 查看DeviceA的路由表。
# 在DeviceB上配置OSPF引入BGP路由。
1 2 3 4 | [~DeviceB] ospf [*DeviceB-ospf-1] import-route bgp [*DeviceB-ospf-1] commit [~DeviceB-ospf-1] quit |
显示DeviceC路由表
5、配置路由自动聚合
# 配置DeviceB
1 2 3 4 | [~DeviceB] bgp 65009 [*DeviceB-bgp] ipv4-family unicast [*DeviceB-bgp-af-ipv4] summary automatic [*DeviceB-bgp-af-ipv4] commit |
# 显示DeviceA的BGP路由表。
使用ping进行验证
使用loopback口建立BGP peer
建立对等体时,当所指定的对等体的IP地址为Loopback接口地址和子接口IP地址时,需要在对等体两端同时配置命令peer connect-interface,以保证两端连接的正确性。
EBGP对等体之间不是直连的物理链路时,则必须使用peer ebgp-max-hop命令允许它们之间经过多跳建立TCP连接。
1、配置各个接口以及loopback接口地址(略)
2、OSPF配置
R4
1 2 3 4 5 | # ospf 1 area 0.0.0.0 network 10.1.1.1 0.0.0.0 # |
R1
1 2 3 4 5 6 7 | # ospf 1 area 0.0.0.0 network 1.1.1.1 0.0.0.0 network 10.1.1.2 0.0.0.0 network 10.1.3.1 0.0.0.0 # |
R2
1 2 3 4 5 6 7 | # ospf 1 area 0.0.0.0 network 2.2.2.2 0.0.0.0 network 10.1.3.2 0.0.0.0 network 10.1.2.1 0.0.0.0 # |
R3
1 2 3 4 5 | # ospf 1 area 0.0.0.0 network 10.1.2.0 0.0.0.255 # |
3、BGP配置
R1
1 2 3 4 5 6 7 8 9 10 11 | # bgp 65008 router-id 1.1.1.1 peer 2.2.2.2 as -number 65009 peer 2.2.2.2 ebgp-max-hop 255 peer 2.2.2.2 connect- interface LoopBack1 # ipv4-family unicast undo synchronization peer 2.2.2.2 enable # |
R2
1 2 3 4 5 6 7 8 9 10 11 12 | # bgp 65009 router-id 2.2.2.2 peer 1.1.1.1 as -number 65008 peer 1.1.1.1 ebgp-max-hop 255 peer 1.1.1.1 connect- interface LoopBack1 # ipv4-family unicast undo synchronization peer 1.1.1.1 enable # return |
在R2上看BGP建立状态
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2020-12-13 SpringBoot(十四)-----异常处理