BGP的基本配置

一、拓扑图

二、实验过程

1.使用直连接口IP地址建立EBGP对等体关系

配置IP地址和环回:

R1

**[R1]int g0/0/0

R1-GigabitEthernet0/0/0\]ip address 12.0.0.1 24 \[R1\]int l0 \[R1-LoopBack0\]ip address 1.1.1.1 32** ![](https://i-blog.csdnimg.cn/direct/cd5ec3379b9d435dbe7402d886167fcd.png) R2: \[R2\]int g0/0/0 \[R2-GigabitEthernet0/0/0\]ip address 12.0.0.2 24 \[R2-GigabitEthernet0/0/0\]int g0/0/1 \[R2-GigabitEthernet0/0/1\]ip address 23.0.0.2 24 \[R2-GigabitEthernet0/0/1\]int l0 \[R2-LoopBack0\]ip address 2.2.2.2 32 ![](https://i-blog.csdnimg.cn/direct/b51f30f367ed403a94589a78a1c2954e.png) R3: \[R3\]INT G0/0/0 \[R3-GigabitEthernet0/0/0\]ip address 23.0.0.3 24 \[R3-GigabitEthernet0/0/0\]int g0/0/1 \[R3-GigabitEthernet0/0/1\]ip address 34.0.0.3 24 \[R3-GigabitEthernet0/0/1\]int l0 \[R3-LoopBack0\]ip address 3.3.3.3 32 ![](https://i-blog.csdnimg.cn/direct/bd963de5aa7e4f41be32083d14732449.png) R4: \[R4\]INT G0/0/0 \[R4-GigabitEthernet0/0/0\]ip address 34.0.0.4 24 \[R4-GigabitEthernet0/0/0\]int g0/0/1 \[R4-GigabitEthernet0/0/1\]ip address 45.0.0.4 24 \[R4-GigabitEthernet0/0/1\]int l0 \[R4-LoopBack0\]ip address 4.4.4.4 32 ![](https://i-blog.csdnimg.cn/direct/f3e7e5bfffc74d2c8a14d046d1bb1aaa.png) ### 启动BGP协议: R1: \[R1\]bgp 100 ---启动BGP协议 \[R1-bgp\]router-id 1.1.1.1 ---编写RID \[R1-bgp\]peer 12.0.0.2 as-number 200 ---配置BGP对等体IP地址以及对等体所在AS号 ![](https://i-blog.csdnimg.cn/direct/3db4e8369af44478b91ff33eb503f28f.png) R2: \[R2\]bgp 200 \[R2-bgp\]router-id 2.2.2.2 \[R2-bgp\]peer 12.0.0.1 as-number 100 ![](https://i-blog.csdnimg.cn/direct/7c94c5e1f0f54f98b7a228fd76ae2a16.png) ### 使用环回接口IP地址建立IGBP对等关系建立: **1.首先要先建立OSPF设置** **R1: \[R1\]ospf 1 router-id 2.2.2.2 \[R1-ospf-1\]area 0 \[R1-ospf-1-area-0.0.0.0\]network 23.0.0.2 0.0.0.0 \[R1-ospf-1-area-0.0.0.0\]network 2.2.2.2 0.0.0.0** ![](https://i-blog.csdnimg.cn/direct/caaf97b0c9e447bfb6b144fcf3a18d91.png) R2: \[R2\]ospf 1 router-id 2.2.2.2 \[R2-ospf-1\]area 0 \[R2-ospf-1-area-0.0.0.0\]network 23.0.0.2 0.0.0.0 \[R2-ospf-1-area-0.0.0.0\]network 2.2.2.2 0.0.0.0 ![](https://i-blog.csdnimg.cn/direct/95054f1ce345454791956455e3132c06.png) R3: \[R3\]ospf 1 router-id 3.3.3.3 \[R3-ospf-1\]area 0 \[R3-ospf-1-area-0.0.0.0\]network 23.0.0.3 0.0.0.0 \[R3-ospf-1-area-0.0.0.0\]network 34.0.0.3 0.0.0.0 \[R3-ospf-1-area-0.0.0.0\]network 3.3.3.3 0.0.0.0 ![](https://i-blog.csdnimg.cn/direct/928762183b3b47138cf9e9173407f73d.png) R4: \[R4\]ospf 1 router-id 4.4.4.4 \[R4-ospf-1\]area 0 \[R4-ospf-1-area-0.0.0.0\]network 4.4.4.4 0.0.0.0 \[R4-ospf-1-area-0.0.0.0\]network 34.0.0.4 0.0.0.0 ![](https://i-blog.csdnimg.cn/direct/ebfbe3a2ea994ea59c22ea15379f9f52.png) **2.开始建立IBGP对等关系** R2: \[R2\]bgp 200 \[R2-bgp\]peer 3.3.3.3 as-number 200 ---使用环回地址 \[R2-bgp\]peer 3.3.3.3 connect-interface LoopBack 0 ---将与3.3.3.3这个IP地址建邻 的连接接口设定为本地的环回0接口 \[R2-bgp\]peer 4.4.4.4 as-number 200 \[R2-bgp\]peer 4.4.4.4 connect-interface LoopBack 0 ![](https://i-blog.csdnimg.cn/direct/cfae5cca8c184614aee69ff45c43868a.png) ![](https://i-blog.csdnimg.cn/direct/32d87343da9d44149a25d2524f1c946d.png) R3: \[R3\]bgp 200 \[R3-bgp\]router-id 3.3.3.3 \[R3-bgp\]peer 2.2.2.2 as-number 200 ---双方均需要配置 **---此时无法建立邻居关系,这是因为R2和R3设备发送的TCP报文的源IP地址是物理链路IP,而对于对端 设备而言,没有相关IP地址的peer信息。故无法建立邻居关系 ---解决思路:将源IP地址修改为换回地址** \[R3-bgp\]peer 2.2.2.2 connect-interface LoopBack 0 \[R3-bgp\]peer 4.4.4.4 as-number 200 \[R3-bgp\]peer 4.4.4.4 connect-interface LoopBack 0 ![](https://i-blog.csdnimg.cn/direct/f39a041f937c4d58be11d1d6698b7618.png) ![](https://i-blog.csdnimg.cn/direct/8385c4579a5044d8aad4065cecb0d8c3.png) R4: \[R4\]bgp 200 \[R4-bgp\]router-id 4.4.4.4 \[R4-bgp\]peer 3.3.3.3 as-number 200 \[R4-bgp\]peer 3.3.3.3 connect-interface LoopBack 0 \[R4-bgp\]peer 2.2.2.2 as-number 200 \[R4-bgp\]peer 2.2.2.2 connect-interface LoopBack 0 ![](https://i-blog.csdnimg.cn/direct/3eab23607ec84ff5b4e3be3456d3dad0.png) ![](https://i-blog.csdnimg.cn/direct/d5f281bf91af47878b2d908177d1a23c.png) ### 使用环回接口IP地址建立EBGP对等体关系 **R4:** \[R4\]bgp 200 \[R4-bgp\]peer 5.5.5.5 as-number 300 \[R4-bgp\]peer 5.5.5.5 ebgp-max-hop 3 \[R4-bgp\]peer 5.5.5.5 connect-interface LoopBack 0 ![](https://i-blog.csdnimg.cn/direct/95b40fe7f3d544f190a6e2f9ae68406c.png) ![](https://i-blog.csdnimg.cn/direct/7acfdd881ba24dc68af32e1a363562e0.png) ![](https://i-blog.csdnimg.cn/direct/697cfd05756642d69c54e4da916ffd88.png) R5: ![](https://i-blog.csdnimg.cn/direct/178758c26f4c4bc2917c1e56aad34870.png) ![](https://i-blog.csdnimg.cn/direct/1e2a655128064f3ab98182346bee6091.png) ### 在R1和R5上进行路由发布 R1: \[R1\]bgp 100 \[R1-bgp\]network 1.1.1.1 32 ![](https://i-blog.csdnimg.cn/direct/985bd38396854127a7f68ce9e48bb112.png) R5: \[R5\]bgp 300 \[R5-bgp\]net \[R5-bgp\]network 10.1.1.1 24 ![](https://i-blog.csdnimg.cn/direct/d46095a94eee47eebf6b8c09319c1357.png) ### 测试结果: ![](https://i-blog.csdnimg.cn/direct/3f67d0a06c464ca2a997bcdbe06bc2ea.jpeg)

相关推荐
恰薯条的屑海鸥6 分钟前
零基础在实践中学习网络安全-皮卡丘靶场(第十四期-XXE模块)
网络·学习·安全·web安全·渗透测试
科技小E8 分钟前
口罩佩戴检测算法AI智能分析网关V4工厂/工业等多场景守护公共卫生安全
网络·人工智能
御承扬17 分钟前
从零开始开发纯血鸿蒙应用之网络检测
网络·华为·harmonyos
Kaede63 小时前
如何应对Linux云服务器磁盘空间不足的情况
linux·运维·服务器
Zfox_5 小时前
Redis:Hash数据类型
服务器·数据库·redis·缓存·微服务·哈希算法
DevSecOps选型指南9 小时前
2025软件供应链安全最佳实践︱证券DevSecOps下供应链与开源治理实践
网络·安全·web安全·开源·代码审计·软件供应链安全
ABB自动化9 小时前
for AC500 PLCs 3ADR025003M9903的安全说明
服务器·安全·机器人
努力学习的小廉9 小时前
深入了解linux系统—— 进程池
linux·运维·服务器
秃头菜狗9 小时前
各个主要目录的功能 / Linux 常见指令
linux·运维·服务器
利刃大大9 小时前
【在线五子棋对战】二、websocket && 服务器搭建
服务器·c++·websocket·网络协议·项目