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)

相关推荐
锐策2 分钟前
深入 RFC 793:TCP 报文头部、MSS 协商与三次握手 / 四次挥手全解析
网络·网络协议·tcp/ip
橘颂TA37 分钟前
【C/C++】进程
服务器
Lenyiin1 小时前
《 Linux 点滴漫谈: 三 》掌控终端:让 Shell 成为你的系统魔杖
linux·运维·服务器·lenyiin
AORO20251 小时前
防爆手机是什么?2025年防爆手机哪个牌子好?
网络·5g·智能手机·制造·信息与通信
霖.241 小时前
Docker常见问题
服务器·docker·云原生·容器
一匹电信狗1 小时前
【MySQL】数据库表的操作
linux·运维·服务器·数据库·mysql·ubuntu·小程序
撬动未来的支点2 小时前
【Linux】Linux 零拷贝技术全景解读:从内核到硬件的性能优化之道
linux·服务器·性能优化
ajassi20002 小时前
开源 Linux 服务器与中间件(六)服务器--Lighttpd
linux·服务器·开源
milanyangbo2 小时前
从C10K到Reactor:事件驱动,如何重塑高并发服务器的网络架构
服务器·网络·后端·架构
爱吃生蚝的于勒2 小时前
【Linux】深入理解进程(一)
java·linux·运维·服务器·数据结构·c++·蓝桥杯