1 试验目的 验证BGP属性 控制选路
2 试验拓扑
说明如下:AR1,AR2 在AS1中,它们之间建立通过loopback地址建立IBGP,其直连链路未通告到ospf中。其他配置情况如图所示。
在AR3上,display bgp routing
[AR3]dis bgp rout
BGP Local router ID is 3.3.3.3
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 7
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 5.5.5.5/32 2.2.2.2 0 1 3?
* i 1.1.1.1 100 0 1 3?
*> 100.1.1.1/32 2.2.2.2 0 1 3?
* i 1.1.1.1 100 0 1 3?
[AR3]dis bgp rout 5.5.5.5
BGP routing table entry information of 5.5.5.5/32:
From: 4.4.4.4 (4.4.4.4)
Route Duration: 00h02m01s
Relay IP Nexthop: 34.0.0.4
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 1.1.1.1
Qos information : 0x0
AS-path 1 3, origin incomplete, localpref 100, pref-val 0, valid, internal, pre
255, IGP cost 2, not preferred for peer type // 前面几条选路规则都相同,到Peer 邻居时 EBGP优于IBGP,所以选择下一跳为2.2.2.2 AR2 发过来的路由
Not advertised to any peer yet
a. 验证pre-value 属性
在AR3上添加 配置
[AR3-bgp]peer 4.4.4.4 route-policy xu import
#
route-policy xu permit node 5
apply preferred-value 10
#
在AR3上,display bgp routing
>i 5.5.5.5/32 1.1.1.1 100 10 1 3?
* 2.2.2.2 0 1 3?
*>i 100.1.1.1/32 1.1.1.1 100 10 1 3?
* 2.2.2.2 0 1 3?
可知
BGP routing table entry information of 5.5.5.5/32:
From: 2.2.2.2 (2.2.2.2)
Route Duration: 01h11m39s
Relay IP Nexthop: 23.0.0.2
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 2.2.2.2
Qos information : 0x0
AS-path 1 3, origin incomplete, pref-val 0, valid, external, pre 255, IGP cost
1, not preferred for PreVal
注:AR3上的最优路由会再发送给AR2 ,但其路由是从AR2所在的AS中传过来的,再传到该AS会被拒收。
------------------------------------------------------------------------------
b 验证 prefence (单独验证,其他属性都相同)
BGP local router ID : 3.3.3.3
Local AS number : 2
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 5.5.5.5/32:
From: 2.2.2.2 (2.2.2.2)
Route Duration: 01h25m17s
Relay IP Nexthop: 23.0.0.2
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 2.2.2.2
Qos information : 0x0
AS-path 1 3, origin incomplete, pref-val 0, valid, external, best, select, acti
ve, pre 44, IGP cost 1
Advertised to such 1 peers:
4.4.4.4
BGP routing table entry information of 5.5.5.5/32:
From: 4.4.4.4 (4.4.4.4)
Route Duration: 00h01m23s
Relay IP Nexthop: 34.0.0.4
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 1.1.1.1
Qos information : 0x0
AS-path 1 3, origin incomplete, localpref 100, pref-val 0, valid, internal, pre
33, IGP cost 2, not preferred for peer type
Not advertised to any peer yet
说明 preference属性对路由选路无影响
c.验证 as-path 属性对选路的影响
route-policy xu permit node 5
apply as-path 5 7 additive
[AR3-bgp]peer 2.2.2.2 route-policy xu import //对从AR2过来的路由 加上路径AS号,增加其长度
[AR3]dis bgp rout 5.5.5.5
BGP local router ID : 3.3.3.3
Local AS number : 2
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 5.5.5.5/32:
From: 4.4.4.4 (4.4.4.4)
Route Duration: 00h00m41s
Relay IP Nexthop: 34.0.0.4
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 1.1.1.1
Qos information : 0x0
AS-path 1 3, origin incomplete, localpref 100, pref-val 0, valid, internal, bes
t, select, active, pre 33, IGP cost 2
Advertised to such 1 peers:
2.2.2.2
BGP routing table entry information of 5.5.5.5/32:
From: 2.2.2.2 (2.2.2.2)
Route Duration: 00h00m23s
Relay IP Nexthop: 23.0.0.2
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 2.2.2.2
Qos information : 0x0
AS-path 5 7 1 3, origin incomplete, pref-val 0, valid, external, pre 44, IGP co
st 1, not preferred for AS-Path
Not advertised to any peer yet
--------------------------------------------------------------------------
d .验证 local-preference
[AR3-route-policy]apply local-preference 99
[AR3-bgp]peer 2.2.2.2 route-policy xu import //对从AR2过来的路由降低其local-preference值,默认为100 ,故选择AR4过来的路由
[AR3]dis bgp rout 5.5.5.5
BGP local router ID : 3.3.3.3
Local AS number : 2
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 5.5.5.5/32:
From: 4.4.4.4 (4.4.4.4)
Route Duration: 00h09m14s
Relay IP Nexthop: 34.0.0.4
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 1.1.1.1
Qos information : 0x0
AS-path 1 3, origin incomplete, localpref 100, pref-val 0, valid, internal, bes
t, select, active, pre 33, IGP cost 2
Advertised to such 1 peers:
2.2.2.2
BGP routing table entry information of 5.5.5.5/32:
From: 2.2.2.2 (2.2.2.2)
Route Duration: 00h00m21s
Relay IP Nexthop: 23.0.0.2
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 2.2.2.2
Qos information : 0x0
AS-path 1 3, origin incomplete, localpref 99, pref-val 0, valid, external, pre
44, IGP cost 1, not preferred for Local_Pref
Not advertised to any peer yet
---------------------------------------------------------