BGP学习笔记
一,基本概念
1、 路由协议的分类
(1) IGP:rip、ospf、eigrp、isis等
(2) EGP:分为EGP和BGP,BGP是基于EGP开发出来的。
2、 区分IGP和EGP:工作在一个AS内部的就是IGP,工作在AS之间的就是EGP。
(1) AS(autonomous systems):由统一管理者管理的管理的范围就是一个AS。
(2) 例如:电信和网通
3、 AS号的范围
(1) 公有:0~64511
(2) 私有:64512~65535
(3) 查全世界的AS号的网址:
http://bgp.potaroo.net
4、 BGP:Path-Vector Routing(路径矢量协议)
1. BGP:AS-by-AS
2. IGP:Hop-by-Hop
5、 BGP Characteristics
(1) 当一个数据包从一个AS穿越另一个AS的时候
(2) 当一个AS连接多个AS的时候
(3) 路由策略(选路)
(4) 在公网选用BGP的优点:
l 管理不方便
l 其他协议没办法支持那么多路由(在公网一般有十几万条)ospf支持1万条,isis也就2万条。
l 策略方面比IGP更多
l 扩展性大:可以传ipv4、ipv6和***v4等。
(5) 公网的虚拟路由器,映射了公网的所有路由。
l telnet route-server.ip.att.net
l 用show ip route summary可以查看公网有多少BGP路由
6、 在什么情况下不要用BGP
(1) 对BGP不熟悉的时候
(2) 不存在选路的时候
(3) 路由器的性能不够强的时候
7、 BGP的特征
(1) 用的协议是:tcp
(2) 端口:179
(3) 更新:触发更新(rip、ospf、isis是触发和周期更新,而eigrp是触发更新)
(4) 通过发keepalive报文维持邻居的状态,周期性的发keepalive报文,周期是60秒。如果180秒没有收到keepalive就认为邻居down了
8、 BGP与IGP的不同
(1) 在IGP中hello包上用来建邻居和keeplive的
(2) 在BGP中,建邻居用的是open报文,保持连接用的是keepalive报文
9、 IGP是用metrics或者cost来衡量路径的好坏,而BGP是用attribute(属性)。
10、 BGP设计是为了大型网络的。
二、BGP的三张表
1、表的名称和作用
(1)Neighbor table:用open报文建立邻居
(2)BGP table(forwarding database):会选出一条最优的路径放到路由表中。
(3)ip routeing table
2、BGP分IBGP和EBGP,IBGP的管理距离是200,EBGP是20
三、BGP的报文
1、报文的名称和作用
(1)Open:用来建立邻居,报文中包括hold time和router id(router id手工指定,如果没有手工指定就是loopback口最大的ip地址,或者物理接口最大IP地址)
(2)keepalive:用来维持邻居关系
(3)Update:传输BGP路由,bgp的路由更新
(4)Notification:当错误发生的时候会发这个报文
四、EBGP和IBGP的介绍
1、名词解释:
(1)Peers = Neighbors
(2)BGP speakers:运行BGP的路由器
2、External BGP:在不同AS之间建立的BGP邻居关系
3、Internal BGP:在同一AS之间建立的BGP邻居关系
五、路由黑洞解决方法:
1、物理线路FULL MESH
2、BGP邻居的FULL MESH
3、将BGP重分布到IGP中(只用于实验环境中)
4、最好的解决方法的MPLS
六、水平分割
1、EBGP的水平分割:主要靠AS号,不接收本AS号的BGP路由。如下图:
因为一个AS里的A1路由器发给下一个AS里的A2路由器路由的时候,其中字段包含AS号和下一条地址等,当A2发给A3路由的时候,字段里就带两个AS号AS1和AS2,当A3再发给A1的时候,里面有和A1一样的AS号。这时候A1就不接收相同AS号的路由。
2、IBGP的水平分割:从IBGP邻居学到的路由,不会再通告给其他的IBGP邻居。如下图,D从B学到的路由不会再通告给E.
七.BGP的基本配置
1、实验拓扑如下:
2、实验步骤:
(1)基本配置:
R1: interface loopback0
ip add 1.1.1.1 255.255.255.0
interface serial 0
ip address 12.1.1.1 255.255.255.0
no shut
interface serial 1
ip address 13.1.1.1 255.255.255.0
no shut
line con 0
exec-time 0 0
logging sysncharonous
R2:interface loopback0
ip add 2.2.2.2 255.255.255.0
interface serial 0
ip address 12.1.1.2 255.255.255.0
clockrate 1000000
no shut
interface serial 1
ip address 24.1.1.2 255.255.255.0
clockrate 1000000
no shut
R3:interface loopback0
ip add 3.3.3.3 255.255.255.0
interface serial 0
ip address 35.1.1.3 255.255.255.0
clockrate 1000000
no shut
interface serial 1
ip address 13.1.1.3 255.255.255.0
clockrate 1000000
no shut
R4:interface loopback0
ip add 4.4.4.4 255.255.255.0
interface serial 0
ip address 461.1.4 255.255.255.0
clockrate 1000000
no shut
interface serial 1
ip address 24.1.1.4 255.255.255.0
clockrate 1000000
no shut
R5:interface loopback0
ip add 5.5.5.5 255.255.255.0
interface serial 0
ip address 35.1.1.5 255.255.255.0
clockrate 1000000
no shut
(2)R2和R4建邻居
l R4的配置
R4(config)#router bgp 4
R4(config-router)#bgp router-id 4.4.4.4(建议和OSPF配成一样的)
R4(config-router)#neighbor 24.1.1.2 remote-as 1(与对端建立邻居,在BGP中用这条命令建立邻居)
l R2的配置
R2(config)#router bgp 1
R2(config-router)#bgp router-id 2.2.2.2(建议和OSPF配成一样的)
R2(config-router)#neighbor 24.1.1.4 remote-as 4
(3)R2和R3建立IBGP邻居()
首先配置IGP(OSPF)互通路由
l R2的配置
R2(config)#router ospf 110
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 12.1.1.0 0.0.0.255 area 0
R2(config-router)#network 2.2.2.0 0.0.0.255 area 0
l R1的配置
R1(config)#router ospf 110
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 12.1.1.0 0.0.0.255 area 0
R1(config-router)#network 13.1.1.0 0.0.0.255 area 0
R2(config-router)#network 1.1.1..0 0.0.0.255 area 0
l R3的配置
R3(config)#router ospf 110
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 13.1.1.0 0.0.0.255 area 0
R3(config-router)#network 3.3.3.0 0.0.0.255 area 0
建立IBGP邻居用R2和R3的环回口
l R2的配置
R2(config)#router bgp 1
R2(config-router)#neighbor 3.3.3.3. remote-as 1
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0(我和R3建立邻居的时候,回来的时候是loopback口,不然无法用环回口建立邻居)
l R3的配置
R3(config)#router bgp 1
R3(config-router)#neighbor 2.2.2.2 remote-as 1
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0(建议两边都做,但一边做也可以)
(4)如果R3和R5是如下图所示,要用环回口建立邻居,能保证冗余备份
这是建立邻居关系最麻烦的一种,默认发出来的TTL=1,到了对端就不能再传了,所以这里要涉及到ebgp-multihop(多跳),配置为大于等于2才能到达对端的环回口。配置静态路由的为了能跑让不同的AS有路由。
l 如上图的R3和R5建立邻居如下:
l R3的配置
R3(config)#router bgp 1
R3(config-router)#neighbor 5.5.5.5 remote-as 5
R3(config-router)#neighbor 5.5.5.5 update-source loopback 0
R3(config-router)#neighbor 5.5.5.5 ebgp-multihop 2(ebgp的最大跳数是2,默认回车是最大的255)
R3(config)#ip route 5.5.5.5 255.255.255.255 serial 0
l R5的配置
R5(config)#router bgp 5
R3(config-router)#neighbor 3.3.3.3 remote-as 1
R3(config-router)#neighbor 3.3.3.3 update-source loopback 0
R3(config-router)#neighbor 3.3.3.3 ebgp-multihop 2
R5(config)#ip route 3.3.3.3 255.255.255.255 serial 0
(5)宣告路由:
l R4的配置
R4(config)#router bgp 4
R4(config-router)#network 4.4.4.0 mask 255.255.255.0(BGP的network可以通告本地路由表所有的路由,而IGP是只通告本接口的路由)
(6)当R4的路由传到R5上的时候,还是不能通信,必须R1和R2、R3都建立BGP邻居才可以,配置如下,用peer group技术,如下:
R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor WOLF peer-group(定义一个模板,给peer group启的名字)
R1(config-router)#neighbor WOLF remote-as 1(模板的命令,与1建立邻居关系)
R1(config-router)#neighbor WOLF update-source loopback 0(模板的命令,更新源是环回口)
R1(config-router)#neighbor 2.2.2.2 peer-group WOLF(调用peer-group的模板)
R1(config-router)#neighbor 3.3.3.3 peer-group WOLF(调用peer-group的模板)
R2(config)#router bgp 1
R2(config-router)#neighbor 1.1.1.1 remote-as 1
R2(config-router)#neighbor 1.1.1.1 update-source loopback 0
R2(config-router)#neighbor 1.1.1.1 next-hop-self
R3(config)#router bgp 1
R3(config-router)#neighbor 1.1.1.1 remote-as 1
R3(config-router)#neighbor 1.1.1.1 update-source loopback 0
(7)想要R5和R4互通,需要把R5的路由通告出来
R5(config)#router bgp 5
R5(config-router)#network 5.5.5.0 mastk 255.255.255.0
R3(config-router)#neighbor 1.1.1.1 next-hop-self
R3(config-router)#neighbor 2.2.2.2 next-hop-self
(8)用R5 ping R4测试
R5#ping 4.4.4.4 source 5.5.5.5 (否则源地址是R5的S0接口了,没有宣告路由,所以不同)
3、查看命令:
(1)查看邻居信息的简表:show ip bgp summary
如果看到state/PfxRcd下面是数字就代表邻居建立起来了,数字代表学到了多少路由
(2)查看邻居详细列表:show ip bgp neighbor
(3)查看链接的端口:show tcp brief
(4)查看BGP表:show ip bgp
l *号代表这条路由可用
l >号代表最好的路由,没有标识>号的路由,认为不是最优的,所有不放进路由表,也不会给其他BGP邻居传
l BGP路由优化的条件:
1. 同步:(解放方法:从IGP学到或者关掉同步no syn(在12.2(8)以上的版本开启BGP后会自动生产的)同步是针对IBGP说的,EBGP传过来的路由都优化}
2. 下一条:用静态或IGP学/ next-hop-self(就是我给你发的路由下一条指向我,如上图在R2的配置:
R2(config-router)#neighbor 3.3.3.3 next-hop-self
八、实验二
1、实验拓扑:
2.实验目的:如图所示,A和B,C和D建立的邻居关系,如果A给D发数据包,先发到B,再发给C,然后到D,所以我们验证,A先发给C是不是更好。
3、实验配置
(1)基本配置IP地址
(2)建立BGP关系
l R2的配置
R2(config)#router bgp 2
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 12.1.1.1 remote-as 1
l R1的配置
R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 12.1.1.2 remote-as 2
(3)R1和R3建立IGP用ripv2,
l R1的配置:
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto-summary
R1(config-router)#network 1.0.0.0
R1(config-router)#network 134.1.0.0
l R3的配置:
R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#network 3.0.0.0
R3(config-router)#network 134.1.0.0
(4)R1、R3、R4建立IBGP关系
l R1的配置:
R1(config)#router bgp 1
R1(config-router)#neighbor 3.3.3.3 remote-as 1
R1(config-router)#neighbor 3.3.3.3 update-source loopback 0
R1(config-router)#neighbor 3.3.3.3 next-hop-self (为了能让路由变优)
l R3的配置:
R3(config)#router bgp 1
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 1.1.1.1 remote-as 1
R3(config-router)#neighbor 1.1.1.1 update-source loopback 0
R3(config-router)#neighbor 134.1.1.4 remote-as 4
l R4的配置:
R4(config)#router bgp 4
R4(config-router)# bgp router-id 4.4.4.4
R4(config-router)#neighbor 134.1.1.3 remote-as 1
(5)在R2上通告路由:
R2(config)#router bgp 2
R2(config-router)#network 2.2.2.0 mask 255.255.255.0
4、实验结论:当R4收到R2宣告的路由,下一条指向是134.1.1.1, 应该是134.1.1.3,所有在MA网络中,ICMP是开启的,ICMP的作用是,如果我从这个接口收到的数据包,还从这个接口发出去,这时候R3就像源端R4发一个ICMP重定向的包,报文内容是你R4发包下一条不用指向我R3了,直接把网管指向R1的134.1.1.1
l Show ip interface e0 可以看到ICMP是开启的
l Debug ip bgpupdate 查看建立邻居关系
l Clear ip bgp * 清楚BGP邻居,硬清,这样重建TCP连接
l Clear ip bgp * soft 软清,不断开TCP连接。重新发一些update报文
l 通告debug看是R3判断出来的
5、BGP States(BGP 的状态)
(1)Idle:(空闲状态)刚配了一条路由,正在查找,这个阶段就是Idle
(2)Connect:本台路由器已经找到了那个邻居的路由,而且也完成了三次握手
(3)Open sent:发送Open报文建邻居,如果都匹配,进入下一个阶段
(4)Open confirm:确认两边收到的Open报文的匹配的,正常就进入下一阶段
(5)Established:建立完成(用show ip bgp summary可以查看学习到的路由)
6、不正常的情况会出现下列几种状态
(1)Idle:本地不能发现邻居的路由(例如没有运行IGP)
(2)Active:
l 邻居没有我本端的路由表
l Neighbor 对端的地址错误的时候
l 邻居没有配置neighbor本端的命令
l AS号配置错了
7、BGP Neighbor authentication(BGP 邻居的认证)
(1)配置命令
l R3(config-router)#neighbor 1.1.1.1 password 123456
8、show ip bgp rib-failure:查看bgp的路由信息库(routing information base)
(1)如果查看到路由条目前打的是r,说明这条路由即从IGP学到,又从BGP学到,但IGP的AD比BGP的小,最终导致IGP的路由进入路由表,而BGP路由没有进入,她就会在BGP表中标识一个r。
(2)标识r的路由:
l 不放进路由表,
l 会给其他BGP邻居传,是优的路由
9、查看收发给邻居的路由
(1)show ip bgp neighbors 12.1.1.1 advertised-router:查看我想邻居12.1.1.1发送了那些路由
(2)show ip bgp neighbors 12.1.1.2 received-routes (默认是看不到的,必须先配置如下命令)
l R1(config-router)#neighbor 12.1.1.2 soft-reconfiguration inbound(这个命令作用就是看我通过自己一些内存保留这个12.1.1.2邻居给我发了那些路由)
10、auto-summary和no auto-summary的区别和作用
(1)no auto-summary:在BGP里的这条命令是用作重发布的时候,当任何一种协议重发布进入BGP中的时候,不会发生自动汇总。而且携带下一条和metric值
(2)Auto-summary:一种协议重发布到BGP中,执行的操作是不携带原有的下一条和metric值,而且会发生自动汇总
九、CIDR and Aggregate Addresses
(1)手工写一条静态路由NULL0,network汇总路由
l 例如:在上面拓扑的R2上有4条明细路由分别为:200.1.16.0/24、200.1.17.0/24、200.1.18.0/24、200.1.19.0/24、
l 配置如下:
R2(config)#ip route 200.1.16.0 255.255.252.0 null0
R2(config)#router bgp 2
R2(config-router)#network 200.1.16.0 mask 255.255.252.0
(2)聚合地址
l 宣告明细路由
R2(config-router)#network 200.1.16.0
R2(config-router)#network 200.1.17.0
R2(config-router)#network 200.1.18.0
R2(config-router)#network 200.1.19.0
l Aggregate-address
R2(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only
(summary-only的意思是仅仅传聚合路由,这样做BGP路由表里会出现s开头的路由,代表被抑制掉的路由)
(3) 如上,如果想抑制掉16和17,想学习聚合的和18、19的。配置如下:
R2(config-router)#aggregate-address 200.1.16.0 255.255.252.0 suppress-map SUP
(SUP 是route-map的名字)
R2(config)#ip prefix-list 1 permit 200.1.16.0/23 ge 24 le 24
R2(config)#route-map SUP
R2(config-route-map)#match ip address prefix-list 1
(4) as-set:当明细路由和聚合路由不在一个路由器上的时候,还原明细路由的属性,把明细路由的属性添加到聚合路由上。让聚合路由也携带这个属性。
l 例如:在R2上宣告明细路由,在R1的配置如下:
R1(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only as-set
十、BGP Path Attributes(BGP 路径属性)
1、识别
2、遵守和自行决定
(1)AS path *:防环
(2)Next-hop *:为了路由能达到最优
(3)Origin *:(起源属性)
l I:通过network通告进BGP都是打i
l ?:重发布过来的路由
l E:从EGP重发布到BGP中
修改属性会从路由看到E,在R1配置如下:
Ip prefix-list 2 permit 2.2.2.2/24
Route-map TEST permit 10
Match ip address prefix-list 2
Set origin egp 2
设置起源属性值
Router bgp 1
Neighbor 12.1.1.2 route-map TEST in
3、传播范围
4、添加其他类型
十一、选路原则
1、 前提是我的同步都关掉,我的下一条是否可达到情况下去选路,保证路由都达到优化
(1) 比最大的weight值
(2) 比本地优先级
(3) 优先于起源于本地的路由
(4) 经过的AS path越短越好
(5) 起源值越小越好(IGP<EGP<incomplete)
(6) Metric值越小越好(MED=metric)
(7) EBGP是由于IBGP的
(8) 优选于最近的IGP邻居(就是metric最小)
(9) 如果前面都相等,我会比较最小BGP邻居的router-id
2、 实验
(1) 实验拓扑图
(2) 实验目的:验证上面属性对选路的影响
(3) Weight值
l 基本配置以完成,R1、R3和R4运行IGP协议ospf,
l 在R2上通告路由
R2(config)#network 2.2.2.0 mask 255.255.255.0
R2(config)#network 9.9.9.0 mask 255.255.255.0
l 默认2.2.2.0和9.9.9.0网段都从R4走,如果想让这两个网段都从R1走,修改weight值,如果在我本台路由器上通告的路由,默认weight值是32768,在R3上修改weight值,配置如下:
R3(config)#router bgp1
R3(config-router)#neighbor 1.1.1.1 weight 1(R3的in方向,意思是所有1.1.1.1发过来的路由我把weight值都调成1,如果没有变,用clear ip bgp * soft清一下)
l 到R3访问2网段从R1走,访问9网段从R4走,配置如下:
R3(config)#ip prefix-list 2 permit 2.2.2.0/24(抓2网段的路由)
R3(config)#router-map W
R3(config-router-map)#match ip address prefix-list 2 (匹配列表2)
R3(config-router-map)#set weight 3
(设置weight值为3)
R3(config)#router-map W permit 20 (写一句空的是为了其他路由能通过)
R3(config)#router bgp1
R3(config-router)#neighbor 1.1.1.1 router-map W in(在R3的in方向调用W)
(4) 本地优先级(local preference Attribute)
l 传播范围:只能在一个AS内部
l 默认值是100
l 越大越优
l 让R3访问这两个网段从R1走,在R1配置如下:
R1(config)#router bgp1
R1(config-router)#bgp default local-preference 111
l bgp default local-preference 111 这条命令对下面的是否起效
1、 network 对自己的network的路由是否起效
2、 对EBGP传过来的路由是否起效
3、 对IBGP路由传过来的路由是否起效
4、 对聚合的路由是否起效
l 让2网段走R1,配置如下:
R1(config)#access-list 2 permit 2.2.2.0(抓2网段的路由)
R1(config)#router-map L
R1(config-router-map)#match ip address 2 (匹配列表2)
R1(config-router-map)#set local-preference 123
R1(config)#router-map L permit 20
R1(config)#router bgp1
R1(config-router)#neighbor 3.3.3.3 router-map L out
(5) 比short 的AS path
l R3访问2网段走R1,在R2配置如下:
R2(config)#ip prefix-list 2 permit 2.2.2.0/24(抓2网段的路由)
R2(config)#router-map AS
R2(config-router-map)#match ip address prefix-list 2 (匹配列表2)
R2(config-router-map)#set as-path prepend 6 7 8
(设置as的长短)
R2(config)#router-map AS permit 20
R2(config)#router bgp 2
R2(config-router)#neighbor 24.1.1.4 router-map AS out(在R2的out方向)
l R3访问2网段走R1,在R4配置如下
R4(config)#ip prefix-list 2 permit 2.2.2.0/24(抓2网段的路由)
R4(config)#router-map AS
R4(config-router-map)#match ip address prefix-list 2 (匹配列表2)
R4(config-router-map)#set as-path prepend 7 8 9 (设置as的长短)
R4(config)#router-map AS permit 20
R4(config)#router bgp 1
R4(config-router)#neighbor 24.1.1.2 router-map AS in
(6) lower origin code(IGP<EGP<Incomplete)
l IGP:network出来的
l 把EGP重分布到BGP中
l Incomplete(?):把IGP或者静态路由重分布到BGP中
(7) lower MED(MED相当于IGP的metric值)
l 传播范围
l 默认值是0
l 越小越好
l 实验:在R3上建立一个环回口并通告出来,配置如下:
R3(config)#interface loopback 8
R3(config-if)#ip address 8.8.8.8 255.255.255.0
R3(config)#router bgp 1
R3(config-router)#network 8.8.8.0 255.255.255.0
l 默认R2访问R3的8网段上从R1走,如果想从R4走,配置如下:
R1(config)#router-map MED
R1(config-router-map)#set metric 8
R1(config)#router bgp1
R1(config-router)#neighbor 12.1.1.2 route-map MED out
用扩展ping可以检验配置的效果,最常用的是Local perference(本地优先级)MED
十一、补充知识
1、解决IBGP的水平分割:
(1)路由反射器:下图是C/S模型,R1是RR,是S
a.RR从EBGP收到的路由:即会反射给我的客户端,也会反射给我的非客户端
b,RR从client端收到的路由:会反射给我的client,以及我的非client,以及我的EBGP邻居
c.RR从非client收到的路由:只会反射给client端和EBGP邻居,不会反射给非client
l 实验如图:默认R3是不会给R4发路由的,因为IBGP水平分割的,解决方法配置如下:
R3(config)#router bgp1
R3(config-router)#neighbor 1.1.1.1 route-reflector-client(这条命令即把R1变成客户端,也把自己变成server了,也就是RR了)
R3(config-router)#neighbor 4.4.4.4 route-reflector-client
(2)联邦
l Router bgp 小AS号(私有AS号)
l 声明所在的大AS号
l 小AS号之间互指peer
l 实验如上图,配置如下:
R1(config)#router bgp 64512
R1(config-router)#neighbor 12.1.1.2 remote-as 2
R1(config-router)#neighbor 3.3.3.3 remote-as 64512
R1(config-router)#neighbor 3.3.3.3 update-source loopback 0
R1(config-router)#neighbor 3.3.3.3 next-hop-self
R3(config)#router bgp 64512
R3(config-router)#neighbor 1.1.1.1 remote-as 64512
R3(config-router)#neighbor 1.1.1.1 update-source loopback 0
R3(config-router)#neighbor 4.4.4.4 remote-as 64513
R3(config-router)#neighbor 4.4.4.4 update-source loopback 0
R3(config-router)#neighbor 4.4.4.4 ebgp-multihop
R4(config)#router bgp 64513
R4(config-router)#neighbor 3.3.3.3 remote-as 64512
R4(config-router)#neighbor 3.3.3.3 update-source loopback 0
R4(config-router)#neighbor 3.3.3.3 ebgp-multihop
l 在联邦中的每台路由器上声明大AS号:
R1(config)#router bgp 64512
R1(config-router)#bgp confederation identifier 1(声明大AS号,联邦中的每台路由器都的做)
R3(config-router)#bgp confederation identifier 1
R4(config-router)#bgp confederation identifier 1
l 在小AS边界互指peer
R3(config-router)#bgp confederation peers 64513
R4(config-router)#bgp confederation peers 64512
3、 社团属性:Community:干涉路由传播范围
(1) 可选:路由器有可能不识别此属性(default),如果想识别,做如下配置:neighbor x.x.x.x send-community
(2) 传递:社团属性只在neighbor邻居有效,如果想往下传,做如下配置:neighbor x.x.x.x send-community
(3) 属性no-advertise:携带此社团属性的路由不会通告给任何BGP邻居
R2(config)#router-map COM
R2(config-router-map)#set community no-advertise
R2(config)#router bgp 2
R2(config-router)#neighbor 12.1.1.1 router-map COM out
R2(config-router)#neighbor 12.1.1.1 send-community
(4)属性no-export:携带此社团属性的路由不会传出大AS
R2(config)#router-map COM
R2(config-router-map)#set community no-export
R2(config)#router bgp 2
R2(config-router)#neighbor 12.1.1.1 router-map COM out
R2(config-router)#neighbor 12.1.1.1 send-community
(5)属性local-AS:携带此社团属性的路由不会传出小AS
R2(config)#router-map COM
R2(config-router-map)#set community local-AS
R2(config)#router bgp 2
R2(config-router)#neighbor 12.1.1.1 router-map COM out
R2(config-router)#neighbor 12.1.1.1 send-community
转载于:https://blog.51cto.com/netsky1/466314