BGP 联邦+Community

简介: 文章目录实验拓扑实验要求IP地址表实验配置配置BGP联邦属性配置BGP团体属性(Community)实验总结

实验拓扑

实验要求

R1-R5都配置BGP协议,通过BGP联邦属性建立私有AS号打破IBGP协议只传一跳的规则,让R5收到R1所有环回口地址的BGP条目。再做团体属性要求R 2收到R1.上环回C地址的4条BGP条目,R3收到R1.上环回口地址的3条BGP条目,R4收到R1上

环回口地址的2条BGP目, R5收到R1上环回口地址的1条BGP条目。

IP地址表

路由器 接口 IP地址
R1 f0/0 10.1.1.1
R1 f1/0 10.1.1.2
R2 f0/0 10.1.1.1
R2 f0/0 20.1.1.1
R3 f1/0 30.1.1.2
R3 f0/0 30.1.1.2
R4 f1/0 30.1.1.2
R4 f0/0 40.1.1.1
R5 f1/0 40.1.1.2
R1 Loopback0 1.1.1.1
R1 Loopback1 192.168.1.1
R1 Loopback2 192.168.2.1
R1 Loopback3 192.168.3.1
R2 Loopback0 2.2.2.2
R3 Loopback0 3.3.3.3
R4 Loopback0 4.4.4.4
R5 Loopback0 5.5.5.5



实验配置

配置BGP联邦属性

R1的配置:

R1#configure terminal 
R1(config)#interface f0/0
R1(config-if)#ip address 10.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#interface Loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#interface loopback 1
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#interface loopback 2
R1(config-if)#ip address 192.168.2.1 255.255.255.0
R1(config)#interface loopback 3
R1(config-if)#ip address 192.168.3.1 255.255.255.0
R1(config-if)#exit
R1(config)#ip route 2.2.2.2 255.255.255.255 10.1.1.2 
R1(config)#router bgp 100
R1(config-router)#neighbor 2.2.2.2 remote-as 200
R1(config-router)#neighbor 2.2.2.2 update-source loopback 0 //更新源为Loopback0
R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 5  //指定EBGP邻居关系可以传递5跳
R1(config-router)#network 1.1.1.0 mask 255.255.255.0
R1(config-router)#network 192.168.1.0 mask 255.255.255.0
R1(config-router)#network 192.168.2.0 mask 255.255.255.0
R1(config-router)#network 192.168.3.0 maks 255.255.255.0  
 //宣告需要传递的有条目并指出起子网掩码


R2的配置

R2#configure terminal 
R2(config)#interface f1/0
R2(config-if)#ip address 10.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface f0/0
R2(config-if)#ip address 20.1.1.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#interface loopback0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R2(config-if)#exit
R2(config)#ip route 1.1.1.1 255.255.255.255 10.1.1.1
R2(config)#router rip
R2(config-router)#ver 2
R2(config-router)#no auto-summary
R2(config-router)#network 20.1.1.0 
R2(config-router)#network 2.2.2.0
R2(config-router)#router bgp 65500  //建立一个虚拟的私有AS号
R2(config-router)#neighbor 1.1.1.1 remote-as 100
R2(config-router)#neighbor 1.1.1.1 update-source Loopback0  //更新源为 Loopback0
R2(config-router)#neighbor 1.1.1.1 ebgp-multihop 5  //指定EBGP邻居关系可以传递5跳
R2(config-router)#bgp confederation identifier 200  //联邦命令,把现有的AS65500标识成200,用此伪造的AS号和R1建立BGP关系
R2(config-router)#neighbor 3.3.3.3 remote-as 65500
R2(config-router)#neighbor 3.3.3.3 update-source loopback0  //更新源为Loopback0
R2(config-router)#neighbor 3.3.3.3 next-hop-self  //通告邻居其下一跳路由为此路由器
R3的配置
R3#configure terminal 
R3(config)#interface f1/0
R3(config-if)#ip address 20.1.1.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#interface f0/0
R3(config-if)#ip address 30.1.1.1 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#interface loopback0
R3(config-if)#ip address 3.3.3.3 255.255.255.0
R3(config-if)#router rip
R3(config-router)#ver 2
R3(config-router)#no auto-summary
R3(config-router)#network 20.1.1.0
R3(config-router)#network 30.1.1.0
R3(config-router)#network 3.3.3.0
R3(config-router)#router bgp 65500
R3(config-router)#neighbor 2.2.2.2 remote-as 65500
R3(config-router)#neighbor 2.2.2.2 update-source loopback0  //更新源为Loopback0
R3(config-router)#bgp confederation identifier 200  //R3也需要此命令来伪造成AS-200 传递BGP信息
R3(config-router)#neighbor 4.4.4.4 remote-as 65501
R3(config-router)#neighbor 4.4.4.4 update-source loopback0  //更新源为loopback0
R3(config-router)#neighbor 4.4.4.4 ebgp-multihop 5  //指定EBGP邻居关系可以传递5跳
R3(config-router)#bgp confederation peers 65501 //和AS-200 中的另一个虚拟AS-65501 建立BGP对等体关系


R4的配置

R4#configure terminal 
R4(config)#interface f1/0
R4(config-if)#ip address 30.1.1.2 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#interface f0/0
R4(config-if)#ip address 40.1.1.1 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#exit
R4(config)#interface loopback0 
R4(config-if)#ip address 4.4.4.4 255.255.255.0
R4(config-if)#exit
R4(config)#ip route 5.5.5.5 255.255.255.255 40.1.1.2
R4(config)#router rip
R4(config-router)#version 2
R4(config-router)#no auto-summary
R4(config-router)#network 4.4.4.0
R4(config-router)#network 30.1.1.0 
R4(config-router)#router bgp 65501
R4(config-router)#neighbor 3.3.3.3 remote-as 65500
R4(config-router)#neighbor 3.3.3.3 update-source loopback0  //更新源威Loopback0
R4(config-router)#neighbor 3.3.3.3 ebgp-multihop 5  //指定EBGP邻居关系可以传递5跳
R4(config-router)#bgp confederation identifier 200  //R4也需要此命令来伪造成AS-200 传递BGP信息
R4(config-router)#bgp confederation peers 65500 //和AS-200 中的另一个虚拟AS-65500建立BGP对等体关系
R4(config-router)#neighbor 5.5.5.5 remote-as 300
R4(config-router)#neighbor 5.5.5.5 update-source loopback 0 //更新源为loopback0 
R4(config-router)#neighbor 5.5.5.5 ebgp-multihop 5  //指定EBGP邻居关系可以传递5跳


R5的配置

R5#configure terminal 
R5(config)#interface f1/0
R5(config-if)#ip address 40.1.1.2 255.255.255.0
R5(config-if)#no shutdown
R5(config)#interface loopback0
R5(config-if)#ip address 5.5.5.5 255.255.255.0
R5(config-if)#exit
R5(config)#ip route 4.4.4.4 255.255.255.255 40.1.1.1
R5(config)#router bgp 300
R5(config-router)#neighbor 4.4.4.4 remote-as 200
R5(config-router)#neighbor 4.4.4.4 update-source loopback0  //更新源为loopback0
R5(config-router)#neighbor 4.4.4.4 ebgp-multihop 5  //指定EBGP邻居关系可以传递5跳


接下来验证配置

show ip route 路由表,R4会收到R1以B为前缀的所有环回口地址的路由条目.




show ip bgp 查看bgp信息,R4会收到4个BGP信息,且都是最优路由条目.此时建立私有AS号突破了IBGP只传一跳的规则.

配置BGP团体属性(Community)

R1#configure terminal 
R1(config)#access-list 10 permit 192.168.1.0
R1(config)#access-list 20 permit 192.168.2.0
R1(config)#access-list 30 permit 192.168.3.0
R1(config)#access-list 40 permit 192.168.4.0
//创建访问控制列表并抓去相应的路由条目进行设置
R1(config)#route-map ccie permit 10 //创建路由策略 ccie
R1(config-route-map)#match ip address 10  //路由策略匹配访问控制列表10
R1(config-route-map)#set community no-advertise //设置团体属性让R1的路由条目传到R2不再往下传递,不再宣告通告
R1(config-route-map)#exit
R1(config)#route-map ccie permit 20
R1(config-route-map)#match ip address 20  
R1(config-route-map)#set community local-as
R1(config-route-map)#exit
R1(config)#route-map ccie permit 30  //路由策略匹配访问控制列表30
R1(config-route-map)#set community no-export  //只在IGBP内部传递
R1(config-route-map)#exit
R1(config)#route-map ccie permit 40 
R1(config-route-map)#match ip address 40 //路由策略匹配访问控制列表40
R1(config-route-map)#set community none //不做任何属性
R1(config-route-map)#exit
R1(config)#route-map ccie permit 50
R1(config-route-map)#exit
R1(config)#router bgp 100
R1(config-router)#neighbor 2.2.2.2 route-map ccie out //把策略挂在接口上
R1(config-router)#neighbor 2.2.2.2 send-community //建立团体属性
R2(config)#router bgp 65500
R2(config-router)#neighbor 3.3.3.3 send-community
R3(config)#router bgp 65500
R3(config-router)#neighbor 4.4.4.4 send-community

接下来

show ip bgp R2-R5分别重看bgp信息,可以观察到R2的bgp表中有4条BGP信息R3的bgp表中有3条BGP信息;R4的bgp表中有2条BGP信息;R5的bgp表中有1条BGP信息.





实验总结

BGP联邦属性通过建立私有AS号来可以打破IBGP协议只能传递一跳的规则,BGP团体属性能够控制BGP路由条目的传递。

目录
相关文章
|
存储 编译器 C语言
【C语言必知必会 | 第三篇】顺序结构入门,这一篇就够了
【C语言必知必会 | 第三篇】顺序结构入门,这一篇就够了
1238 0
|
关系型数据库 MySQL Java
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException 异常解决
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException 异常解决
'webpack-dev-server' 不是内部或外部命令,也不是可运行 的程序 或批处理文件。
'webpack-dev-server' 不是内部或外部命令,也不是可运行 的程序 或批处理文件。
459 0
|
网络协议 应用服务中间件 Linux
centos7 Nginx Log日志统计分析 常用命令
centos7 Nginx Log日志统计分析 常用命令
612 2
|
缓存 Java 应用服务中间件
【高并发优化手段】基于Springboot项目(二)
【高并发优化手段】基于Springboot项目
1473 0
|
存储 SQL Java
(七)全面剖析Java并发编程之线程变量副本ThreadLocal原理分析
在之前的文章:彻底理解Java并发编程之Synchronized关键字实现原理剖析中我们曾初次谈到线程安全问题引发的"三要素":多线程、共享资源/临界资源、非原子性操作,简而言之:在同一时刻,多条线程同时对临界资源进行非原子性操作则有可能产生线程安全问题。
324 1
|
存储 设计模式 分布式计算
面向对象编程在大数据处理中的最佳实践
【8月更文第12天】随着互联网和物联网技术的发展,数据量呈指数级增长,大数据处理已成为现代企业不可或缺的一部分。大数据处理通常涉及收集、存储、管理和分析海量数据集。传统的数据库管理系统难以应对这样的挑战,因此出现了诸如Hadoop、Spark等分布式处理框架。这些框架通常使用面向对象编程(OOP)来构建可扩展、可维护的应用程序。本文将探讨如何利用面向对象编程的原则和模式来优化大数据处理任务。
309 0
|
缓存 弹性计算 分布式计算
阿里云服务器2核2G、2核4G、4核8G、8核16G收费标准与活动价格参考
阿里云服务器可选配置为1核1G,最高为256核3072G,其中大部分用户购买最多的配置是2核2G、2核4G、4核8G、8核16G,2024年,2核2G配置只要61元/1年,2核4G配置只要199元/1年,4核8G配置只要955.58元/1年,8核16G配置只要1803.17元/1年。本文为大家整理汇总了阿里云服务器2核2G、2核4G、4核8G、8核16G配置的收费标准与活动价格情况,以供参考。
阿里云服务器2核2G、2核4G、4核8G、8核16G收费标准与活动价格参考