可選傳遞
正則表達式
- 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 //查看