公认团体属性的3个实验
在R2上给两条路由打上标记,并通告给R3
[R2]ip ip-prefix 1.1 permit 10.1.1.1 32
[R2]ip ip-prefix 1.2 permit 10.1.1.2 32
[R2-route-policy]dis th
route-policy comm permit node 10
if-match ip-prefix 1.1
apply community 100:1
route-policy comm permit node 20
if-match ip-prefix 1.2
apply community 100:2
#
[R2-bgp]peer 12.1.1.1 route-policy comm import //在R1进入R2时把这两条路由加上团体属性
[R2-bgp]peer 3.3.3.3 advertise-community //团体属性通告给3.3.3.3
no-advertise
[R2]route-policy 1.2 permit node 10
[R2-route-policy]if-match ip-prefix 1.2
[R2-route-policy]apply community no-advertise
[R2]route-policy 1.2 permit node 99
[R2-bgp]peer 3.3.3.3 route-policy 1.2 export
//在出接口应用,R3得到不通告的团体属性,到达R4后消失。
<R3>dis bgp routing-table 10.1.1.2
BGP local router ID : 34.1.1.3
Local AS number : 64512
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 10.1.1.2/32:
From: 2.2.2.2 (23.1.1.2)
Route Duration: 00h04m14s
Relay IP Nexthop: 23.1.1.2
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 2.2.2.2
Qos information : 0x0
Community:no-advertise
AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal-conf
ed, best, select, active, pre 255
Not advertised to any peer yet
[R4-bgp]dis bgp routing-table 10.1.1.2
Info: The network does not exist.
几乎不传递给任何对等体邻居。
no-export
[R2-route-policy]apply community no-export
//此时R3、R4查看1.1有团体属性,1.2团体属性为no-export
[R4-bgp]peer 45.1.1.5 advertise-community
<R5>dis bgp routing-table 10.1.1.2 //在R5上10.1.1.2的路由消失,只有1.1的路由
Info: The network does not exist.
<R5>dis bgp routing-table 10.1.1.1
BGP local router ID : 45.1.1.5
Local AS number : 300
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 10.1.1.1/32:
From: 45.1.1.4 (45.1.1.4)
Route Duration: 00h00m08s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 45.1.1.4
Qos information : 0x0
Community:<100:1>
AS-path 200 100, origin igp, pref-val 0, valid, external, best, select, active,
pre 255
Not advertised to any peer yet
该属性不导出给其他as区域,在IBGP内传递属性。
no-export-subconfed
[R2-route-policy]apply community no-export-subconfed
在一个as联盟的子区域内传,出了子区域就消失。
<R4>dis bgp routing-table 10.1.1.2
Info: The network does not exist.
<R4>dis bgp routing-table 10.1.1.1
BGP local router ID : 45.1.1.4
Local AS number : 64513
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 10.1.1.1/32:
From: 3.3.3.3 (34.1.1.3)
Route Duration: 00h15m52s
Relay IP Nexthop: 34.1.1.3
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 2.2.2.2
Qos information : 0x0
Community:<100:1>
AS-path (64512) 100, origin igp, MED 0, localpref 100, pref-val 0, valid, exter
nal-confed, best, select, active, pre 255
Advertised to such 1 peers:
45.1.1.5
MED属性实验
MED(Multi-Exit Discriminator,多出口鉴别器)是可选非过渡属性,MED值不会跨AS传递(EBGP间传递一次)。
缺省情况下,路由器只比较来自同一相邻AS的BGP路由的MED值,也就是说如果去往同一个目的地的两条路由来自不同的相邻AS,则不进行MED值的比较。
一台BGP路由器将路由通告给EBGP对等体时,是否携带MED属性,需要根据以下条件进行判断(不对EBGP对等体使用策略的情况下):
1.如果该BGP路由是本地始发(本地通过network或import-route命令引入)的,则缺省携带MED属性发送给EBGP对等体。
2.如果该BGP路由为从BGP对等体学习到,那么该路由传递给EBGP对等体时缺省不会携带MED属性。
3.在IBGP对等体之间传递路由时,MED值会被保留并传递,除非部署了策略,否则MED值在传递过程中不发生改变也不会丢失。
可以使用default imed命令修改缺省的MiED值,default med命令只对本设备上用import-route命令引入的路由和BGP的聚合路由生效。例如在R2上配置default med 999,那么R2通过import-route及aggregate命令产生的路由传递给R3时,路由携带的MED为999。
在R1宣告
[R1-bgp]network 1.11.11.11 32
在R1上bgp宣告,则MED为0
[R2-bgp]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.11.11.11/32 1.1.1.1 0 100 0 i
[R3-bgp]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.11.11.11/32 23.1.1.2 0 100i
是本路由器产生,所以MED为0,在AS内和该as相连的下一跳AS都为0。
在R2宣告
[R2-bgp]network 1.11.11.11 32
[R2-bgp]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.11.11.11/32 0.0.0.0 1 0 i
[R3-bgp]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.11.11.11/32 23.1.1.2 1 0 100i
[R1-bgp]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.11.11.11/32 2.2.2.2 1 100 0 i
该路由在R2产生为ospf学习来,cost为1,所以在BGP内宣告后MED值为1
姓名:
Q Q:
电话:
|