可选传递
正则表达式
- BGP communities是一种给路由条目打上标记,用于确保路由过滤和选择的连续性
负载均衡
- BGP 路由器能够在重分布、发送、接收路由更新的时候给路由条目打上community值(route-map)
ide
- 根据 community值,BGP 路由器能够过滤进出路由更新或者优选某些路由
oop
- 缺省状况下,在update路由的时候community被剥离
ui
◆32 bit community balue is split into two parts:
this
[AS-number]:[low-order-16-bits]
spa
AS号 描述本地设备
orm
◆配置router
router(config)#
blog
match condition
set community value---100:1 // AS100
router bgp 100
nei x.x.x.x route-map map in/out
neit x.x.x.x send-community //community默认不传递,此命令用于传递
调用community,操做
router(config)#
ip community-list 1-99 permit | deny value
◆community-list 标准(1-99):匹配别人打的值
扩展(100-199):用正则表达式匹配。
route-map name permit|deny
match community clist-number
set attributes
实验:
AS200配置联邦,R2 R4在AS2000;R5在AS300
R2 R4 R5igp运行ospf
R1:
int f1/0
ip add 12.1.1.1 255.255.255.0
no shu
int lo0
ip add 1.1.1.1 255.255.255.255
router bgp 100
nei 12.1.1.1 remot 200
R2:
int f1/0
ip add 12.1.1.2 255.255.255.0
no shu
ip os 1 a 0
int lo0
ip add 2.1.1.1 255.255.255.255
ip os 1 a 0
int f1/1
ip add 24.1.1.2 255.255.255.0
no shu
ip os 1 a 0
int lo0
ip add 2.1.1.1 255.255.255.255
ip os 1 a 0
router bgp 2000
bgp confen id 200
nei 4.1.1.1 remot 2000
nei 4.1.1.1 up lo0
nei 4.1.1.1 next-hop-self
nei 12.1.1.1 remot 100
R4:启用IGP OSPF
router bgp 2000
bgp confen id 200
bgp confen peers 3000
nei 2.1.1.1 remot 2000
nei 2.1.1.1 up lo0
nei 5.1.1.1 remot 3000
nei 5.1.1.1 up lo0
nei 5.1.1.1 ebgp-multihop
R5:启用IGP ospf
router bpg 3000
bgp confen id 200
bgp confen peer 2000
nei 4.1.1.1 remot 2000
nei 4.1.1.1 up lo0
nei 4.1.1.1 next-hop-s
nei 4.1.1.1 ebgp-multi
nei 56.1.1.6 remot 300
R6:router bgp 300
nei 56.1.1.5 remot 200
####################################################
配置community
R1:router bgp 100
net 1.1.1.1
ip prefix-list 1.1 per 1.1.1.1/32
route-map com per 10
match ip add prefix-list 1.1
set commu 100:1
route-map com per 1000
router bgp 100
nei 12.1.1.2 send-community //community默认不传递,需手动配置传递
R2:sho ip bgp 1.1.1.1 //commuity 值不是100:1格式
conf t
ip bgp-community new-format // 配置以100:1格式显示
sho ip bgp 1.1.1.1
◆R2上就能够经过配置community-list 调用100:1,再set不一样值
ip community-list 1 per 100:1
route-map com per 10
match community 1
set commuity 200:2
route-map com per 1000
router bgp 2000
nei 12.1.1.1 route-map com out
sho ip bgp 1.1.1.1 //此时community=200:2,以前的100:1被覆盖
若要不覆盖100:1,须要在route-map加关键字 additive
route-map com per 10
set community 200:2 additive
sho ip b 1.1.1.1 //能够同时看到100:1 200:2
◆ 在匹配community值作策略时,在一条路由有多个community值,只要匹配一个就能够
R4:
ip community-list 1 per 100:1
route-map test per 10
match community 1
set wei 2000
◆ 能够经过关键字 exact-match 设置,有多个community时,全匹配才行(精确匹配)
route-map test per 10
match community 1 exact-match
◆ ip community-list 1 per 100:1 200:2
sho ip b
◆ commnity-list 能够匹配多个值
ip commnuity-list 1 per 100:1 200:2
ip commnuity-list 1 per 200:2
sho ip community-list
###########################################################################################
利用community控制路由传递的范围
属性值:
1,no-advertise:do not advertise routes to any peer不传给任何邻居
2, local-as:do not advertise routes to any EBGP peers不传给任何EBGP邻居,包括联邦
3, no-export: do not advertise routes to real EBGP peers不传给EBGP邻居,联邦能够
4, internet: advertise this route to the internet community 传给全部
注意:community值默认不传递,手工 nei x.x.x.x send-community
##########################################################################################
利用community选路 第8.5条
扩展community :extcommunity cost
R1,将loopback0宣告你BGP。此时若果在R8配置 maxinum-path就会负载均衡
R8:router bgp 300
maxinum-paths ibgp 2 //默认只对ebgp生效
若是利用community扩展属性,能够在第9条前生效
R7:
route-map cost permit 10
set extcommunity cost 10(community-ID) 2147483646(community值) //默认community值=2147483647
其中 communityID会优先比较,以后才是community值
router bgp 300
nei 8.1.1.1 route-map cost out
nei 8.1.1.1 send-community extended
clear
R8:sho ip bgp
#################################################################
利用community选路 第0.5条
R8:配置到R6的weight=100 默认=0
nei 6.1.1.1 weight 100 //这样就会选从R6过来
在R7配置扩展community选R7,证实是在第1条前边优先
route-map cost per 10
set extcommunity cost pre-bestpath 1(ID号) 2147483646
注意:只能在IBGP之间使用
##########################################################################################
利用community实现两个AS之间实现非等价负载均衡 bgp dmzlink-bw
正常 R8
router bgp 300
bgp maxinum-path ibgp 2 //maxinum 默认只对EBGP路由生效
sho ip route 1.1.1.1 是等价负载均衡的 “trafficshare count is x”
\\\\\\\
R5:
int f1/1
bandw 50000 //设置R5 R6之间带宽为50M,默认100M
R6: int f1/0
band 50000
router bgp 300
bgp dmzlintk-bw //开启功能
neighbor 56.1.1.5 dmzlink-bw //针对ebgp链路开启
nei 8.1.1.1 send-community extended //开启community属性传递
R7: router bgp 300
bgp dmzlink-bw
neighbro 57.1.1.5 dmzlink-bw
nei 8.1.1.1 send-community extended
clear ip b * soft
sho ip bgp 1.1.1.1 //可看见DMZ-link 标记
R8: router bgp 300
bgp dmzlink-bw
clear ip b * so
sho ip b 1.1.1.1 //查看