BGP联邦 反射器实验

 实验要求如上

首先来划分子网:

骨干部分:

172.16.0.0 30(2 3)         172.16.0.4 30(3 4)          172.16.0.8 30(4 7)         

172.16.0.12 30(2 5)        172.16.0.16 30(5 6)        172.16.0.20 30(6 7)

建邻环回:

172.16.1.0 32

用户网段:

172.16.2.0 24(R2)172.16.3.0 24(R3)172.16.4.0 24(R4)

172.16.5.0 24(R5)172.16.6.0 24(R6)172.16.7.0 24(R7)

这里只展示一部分的ip配置
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 12.1.1.2 24
[R2-LoopBack0]ip add 172.16.1.2 32
[R2-LoopBack1]ip add 172.16.2.1 24
[R2-GigabitEthernet0/0/2]ip add 172.16.0.13 30
[R2-GigabitEthernet0/0/0]ip add 172.16.0.1 30

其余配置类似

2-7之间配置igp 我们使用ospf


[R2-GigabitEthernet0/0/0]ospf
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
由于我们前期汇总过 这里宣告更简单
[R3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[R4-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[R5-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[R6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[R7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

宣告完毕

测试 as2的igp 发现互通

 进行bgp的建邻

R1 R2之间

[R1]bgp 1
[R1-bgp]peer 172.16.1.2 as-number 2
但是双方没有到达对方环回的路由 需要手写静态
[R1]ip route-static 172.16.1.2 32 12.1.1.2
[R2]ip route-static 1.1.1.1 32 12.1.1.1 

由于访问的是环回 需要增加ttl
[R1-bgp]peer 172.16.1.2 ebgp-max-hop 2
用自己的环回去与对方建邻
[R1-bgp]peer 172.16.1.2 connect-interface LoopBack 0

R2上我们使用联邦的方式 
[R2]bgp 65412
[R2-bgp]router-id 2.2.2.2
[R2-bgp]confederation id 2
自己以as 2的身份与 as2以外的区域建立ebgp关系
[R2-bgp]confederation peer-as 65413
自己的附近 存在一个as号为65413你们是ibgp关系
[R2-bgp]peer 1.1.1.1 as-number 1
[R2-bgp]peer 1.1.1.1 connect-interface LoopBack 0 
[R2-bgp]peer 1.1.1.1 ebgp-max-hop 2
[R2-bgp]dis bgp peer

 BGP local router ID : 2.2.2.2
 Local AS number : 65412
 Total number of peers : 1		  Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  1.1.1.1         4           1        2        2     0 00:00:11 Established       0

建立成功

R2 R3

[R3-ospf-1]bgp 65412

[R3-bgp]confederation id 2
声明所在的大as
[R3-bgp]peer 172.16.1.2 as-number 65412
在同一大as内部配置采用小as进行建邻配置
[R2-bgp]peer 172.16.1.3 as-number 65412
我们需要让R3作为反射器工作
[R3-bgp]peer 172.16.1.2 reflect-client 
让1.2作为反射器的客户端
[R2-bgp]peer 172.16.1.3 connect-interface LoopBack 0
[R3-bgp]peer 172.16.1.2 connect-interface LoopBack 0
使用自己的环回与对方建邻

[R3-bgp]dis bgp peer

 BGP local router ID : 172.16.0.5
 Local AS number : 65412
 Total number of peers : 1		  Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  172.16.1.2      4       65412        2        2     0 00:00:01 Established       0
建立成功

R2 R5 

[R5]bgp 65413
[R5-bgp]router-id 5.5.5.5
[R5-bgp]confederation id 2
声明自己所在的大as
[R5-bgp]confederation peer-as 65412
声明自己的小as邻居
[R2-bgp]peer 172.16.1.5 as-number 65413
[R2-bgp]peer 172.16.1.5 connect-interface LoopBack 0                     
[R2-bgp]peer 172.16.1.5 ebgp-max-hop 2

[R5-bgp]peer 172.16.1.2 as-number 65412
[R5-bgp]peer 172.16.1.2 connect-interface LoopBack 0                       
[R5-bgp]peer 172.16.1.2 ebgp-max-hop 2

[R5-bgp]dis bgp peer

 BGP local router ID : 5.5.5.5
 Local AS number : 65413
 Total number of peers : 1		  Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  172.16.1.2      4       65412        2        2     0 00:00:03 Established       0
建立成功

其余配置类似 不做过多展示

[R7-bgp]peer 78.1.1.2 as-number 3
[R8-bgp]peer 78.1.1.1 as-number 2
AR7 8之间为了方便直接使用直连接口配置

[R6-bgp]peer 172.16.1.5 reflect-client 

[R3-bgp]peer 172.16.1.2 reflect-client 

三和六作为反射器工作

现在开始宣告只需要在R1R2R7R8上进行宣告

在R2和R7上为了减少路由条目 直接宣告缺省

能宣告的条件是先得有

[R2]ip route-static 172.16.0.0 16 NULL 0
[R2-bgp]network 172.16.0.0 16
这样即可 如果有明细路由需要传递 可以进行单独宣告
[R1-bgp]network 11.1.1.0 24
[R7]ip route-static 172.16.0.0 16 NULL 0
[R7-bgp]network 172.16.0.0 16
[R8-bgp]network 88.8.8.0 24
[R7-bgp]network 11.1.1.0 24
[R2-bgp]network 88.8.8.0 24

完成宣告 发现 在 5或3上存在路由条目不优的现象 原因是下一跳可达原则没有满足

 需要在R1和R7上配置让下一跳变成自己

[R2-bgp]peer 172.16.1.3 next-hop-local
[R2-bgp]peer 172.16.1.5 next-hop-local
[R7-bgp]peer 172.16.1.6 next-hop-local
[R7-bgp]peer 172.16.1.4 next-hop-local

问题解决这时所有的路由表都已齐全

这里展示部分

【R4】

 

 【R1】

【R3】

 可以看到 路由表齐全 开始测试

 

 

在测试中发现bgp中已经优了的没有下发给路由 原因是一不小心打了

  bgp-rib-only
这一命令会禁止bgp中的路由下发给路由表经改正后

已经实现全网可达

 

posted @ 2023-08-12 14:34  f0r9  阅读(5)  评论(0编辑  收藏  举报  来源