配置BGP的基本功能示例
配置BGP的基本功能后可以组建BGP网络。
组网需求
某个地区拥有多个AS,AS之间有相互访问的需求,因此需要AS之间相互交换本AS内部的路由。由于AS内路由器数量众多,导致路由数量较大,路由变化频繁,如何高效率的在AS之间传递大量路由,并且不占用大量带宽成为一个难题。为解决上述问题,可以使用BGP协议。
如图1所示,DeviceA处于AS65008,DeviceB、DeviceC和DeviceD处于AS65009,并且这几个路由器的路由数量都比较大,路由表变化频繁。在这几个路由器上部署BGP协议之后,路由器之间可以相互传递路由,并且当任何一个路由器有路由更新时,只需发送路由更新信息给邻居路由器,而无须发送整个路由表,大大节约了网络带宽。
设备名称 | 接口 | IP地址 |
DeviceA | Loopback0 | 1.1.1.1/32 |
GE0/0/1 | 172.16.0.1/16 | |
GE0/0/2 | 192.168.0.1/24 | |
DeviceB | Loopback0 | 2.2.2.2/32 |
GE0/0/1 | 10.1.1.1/24 | |
GE0/0/2 | 192.168.0.2/24 | |
GE0/0/3 | 10.1.3.1/24 | |
DeviceC | Loopback0 | 3.3.3.3/32 |
GE0/0/2 | 10.1.2.1/24 | |
GE0/0/3 | 10.1.3.2/24 | |
DeviceD | Loopback0 | 4.4.4.4/32 |
GE0/0/1 | 10.1.1.2/24 | |
GE0/0/2 | 10.1.2.2/24 | |
DeviceE | GE0/0/1 | 172.16.0.2/16 |
在配置过程中,需注意以下事项
1、建立对等体时,当所指定的对等体的IP地址为Loopback接口地址或子接口的IP地址时,需要在对等体两端同时配置命令peer connect-interface,以保证两端连接的正确性。
2、EBGP对等体之间不是直连的物理链路时,则必须使用peer ebgp-max-hop命令允许它们之间经过多跳建立TCP连接。
采用如下思路配置BGP的基本功能
1、在DeviceB、DeviceC、DeviceD之间配置IBGP连接
2、在DeviceA和DeviceB之间配置EBGP连接
3、在DeviceA上通过network命令发布路由,查看DeviceA、DeviceB、DeviceC的路由表信息。
4、在DeviceB上配置BGP引入直连路由,查看DeviceA、DeviceC的路由表信息。
操作步骤
1、配置接口地址,参照如上表格
2、配置OSPF
配置DeviceB
1 2 3 4 5 6 7 8 | [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] network 10.1.3.0 0.0.0.255 [DeviceB-ospf-1-area-0.0.0.0] network 2.2.2.2 0.0.0.0 [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 8 | [DeviceC] ospf 1 [DeviceC-ospf-1] area 0 [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] network 10.1.3.0 0.0.0.255 [DeviceC-ospf-1-area-0.0.0.0] network 3.3.3.3 0.0.0.0 [DeviceC-ospf-1-area-0.0.0.0] commit [DeviceC-ospf-1-area-0.0.0.0] quit [DeviceC-ospf-1] quit |
配置DeviceD
1 2 3 4 5 6 7 8 | [DeviceD] ospf 1 [DeviceD-ospf-1] area 0 [DeviceD-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [DeviceD-ospf-1-area-0.0.0.0] network 10.1.2.0 0.0.0.255 [DeviceD-ospf-1-area-0.0.0.0] network 4.4.4.4 0.0.0.0 [DeviceD-ospf-1-area-0.0.0.0] commit [DeviceD-ospf-1-area-0.0.0.0] quit [DeviceD-ospf-1] quit |
3、配置IBGP链接
配置DeviceB
1 2 3 4 5 6 7 8 | [~DeviceB] bgp 65009 [*DeviceB-bgp] router-id 2.2.2.2 [*DeviceB-bgp] peer 3.3.3.3 as -number 65009 [*DeviceB-bgp] peer 4.4.4.4 as -number 65009 [*DeviceB-bgp] peer 3.3.3.3 connect- interface LoopBack0 [*DeviceB-bgp] peer 4.4.4.4 connect- interface LoopBack0 [*DeviceB-bgp] commit [~DeviceB-bgp] quit |
配置DeviceC
1 2 3 4 5 6 7 8 | [DeviceC] bgp 65009 [DeviceC-bgp] router-id 3.3.3.3 [DeviceC-bgp] peer 2.2.2.2 as -number 65009 [DeviceC-bgp] peer 4.4.4.4 as -number 65009 [DeviceC-bgp] peer 2.2.2.2 connect- interface LoopBack0 [DeviceC-bgp] peer 4.4.4.4 connect- interface LoopBack0 [DeviceC-bgp] commit [DeviceC-bgp] quit |
配置DeviceD
1 2 3 4 5 6 7 8 | [DeviceD] bgp 65009 [DeviceD-bgp] router-id 4.4.4.4 [DeviceD-bgp] peer 2.2.2.2 as -number 65009 [DeviceD-bgp] peer 3.3.3.3 as -number 65009 [DeviceD-bgp] peer 2.2.2.2 connect- interface LoopBack0 [DeviceD-bgp] peer 3.3.3.3 connect- interface LoopBack0 [DeviceD-bgp] commit [DeviceD-bgp] quit |
4、配置EBGP
配置DeviceA
1 2 3 4 5 | [DeviceA] bgp 65008 [DeviceA-bgp] router-id 1.1.1.1 [DeviceA-bgp] peer 192.168.0.2 as -number 65009 [DeviceA-bgp] commit [DeviceA-bgp] quit |
配置DeviceB
1 2 3 4 | [DeviceB] bgp 65009 [DeviceB-bgp] peer 192.168.0.1 as -number 65008 [DeviceB-bgp] commit [DeviceB-bgp] quit |
查看BGP的对等体状态
5、配置DeviceA发布路由172.16.0.0/16
配置DeviceA发布路由
1 2 3 4 5 6 7 | [DeviceA] bgp 65008 [DeviceA-bgp] ipv4-family unicast [DeviceA-bgp-af-ipv4] network 172.16.0.0 255.255.0.0 [DeviceA-bgp-af-ipv4] network 192.168.0.0 255.255.255.0 [DeviceA-bgp-af-ipv4] commit [DeviceA-bgp-af-ipv4] quit [DeviceA-bgp] quit |
查看DeviceA路由表信息
查看DeviceB路由表信息
查看DeviceC路由表信息
6、配置BGP引入直连路由
配置DeviceB
1 2 3 4 5 6 | [DeviceB] bgp 65009 [DeviceB-bgp] ipv4-family unicast [DeviceB-bgp-af-ipv4] import-route direct [DeviceB-bgp-af-ipv4] commit [DeviceB-bgp-af-ipv4] quit [DeviceB-bgp] quit |
查看DeviceA路由表信息
查看DeviceB路由表信息
查看DeviceC路由表信息
可以看出,到172.16.0.0的路由变为有效路由,下一跳为DeviceA的地址。
使用Ping进行验证。
命令 | 备注 |
bgp 123 router-id 1.1.1.1 peer 12.0.0.2 as-number 123 |
声明所在AS号(创建进程) 配置RID,必须唯一 配置邻居地址和AS号 |
display bgp peer | 显示BGP邻居状态 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2018-11-11 ServletContext的使用
2018-11-11 Servlet获取配置信息(ServletConfig)
2018-11-11 Servlet线程安全问题(转载)
2018-11-11 Servlet映射细节