1、实验拓扑
2、实验目的
完成所有选路规则的实验,重点就是当前的HCIE考试考核的内容~MED
3、实验步骤
[R7-bgp]peer 66.1.1.1 preferred-value 101 //粗线条的方式
以下为精准的修改方式:
操作前查看路由
<R7>disp bgp routing-table
BGP Local router ID is 10.1.57.7
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 11
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.1/32 55.1.1.1 0 100 0 (2005) 100i
i 22.1.1.1 100 0 100i
*>i 2.2.2.2/32 55.1.1.1 100 0 (2005) 100i
i 22.1.1.1 0 100 0 100i
*>i 3.3.3.3/32 55.1.1.1 100 0 (2005) 100i
i 22.1.1.1 100 0 100i
*>i 4.4.4.4/32 55.1.1.1 100 0 (2005) 100i
i 22.1.1.1 100 0 100i
*>i 5.5.5.5/32 55.1.1.1 0 100 0 (2005)i
*>i 6.6.6.6/32 66.1.1.1 0 100 0 i
*> 7.7.7.7/32 0.0.0.0 0 0 i
[R7]ip ip-prefix 7 permit 2.2.2.2 32 //在R7上匹配路由
[R7]ip ip-prefix 7 permit 4.4.4.4 32
[R7]route-policy PreVal permit node 10
[R7-route-policy]if-match ip-prefix 7
[R7-route-policy]apply preferred-value 5 //设置preferred-value为5
[R7-route-policy]route-policy PreVal permit node 20
[R7-route-policy]quit
[R7]bgp 2067
[R7-bgp]peer 66.1.1.1 route-policy PreVal import //面向邻居本地的入方向调用,影响本地的路由选路
<R7>disp bgp routing-table
BGP Local router ID is 10.1.57.7
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 11
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.1/32 55.1.1.1 0 100 0 (2005) 100i
* i 66.1.1.1 100 0 100i
*>i 2.2.2.2/32 66.1.1.1 0 100 5 100i //优选了R6
* i 55.1.1.1 100 0 (2005) 100i
*>i 3.3.3.3/32 55.1.1.1 100 0 (2005) 100i
* i 66.1.1.1 100 0 100i
*>i 4.4.4.4/32 66.1.1.1 100 5 100i //优选了R6
* i 55.1.1.1 100 0 (2005) 100i
*>i 5.5.5.5/32 55.1.1.1 0 100 0 (2005)i
*>i 6.6.6.6/32 66.1.1.1 0 100 0 i
*> 7.7.7.7/32 0.0.0.0 0 0 i
<R7>
在AS内部传递,数值越大越优先,默认值100。通常用于ASBR来影响内部的IBGP对等体如何把数据发出到其他AS
需求: 在AS200中,去往1.1.1.1和3.3.3.3的数据优选R5,另外2条路由优选R6
在两台ASBR实现
[R5]ip ip-prefix 13 permit 1.1.1.1 32
[R5]ip ip-prefix 13 permit 3.3.3.3 32
[R5]route-policy LocalPre permit node 10
[R5-route-policy]if-match ip-prefix 13
[R5-route-policy]apply local-preference 666
[R5-route-policy]route-policy LocalPre permit node 20
[R5-route-policy]quit
[R5]bgp 2005
[R5-bgp]peer 77.1.1.1 route-policy LocalPre export
[R5]disp ip ip-prefix
Prefix-list 13
Permitted 4
Denied 7
index: 10 permit 1.1.1.1/32
index: 20 permit 3.3.3.3/32
[R6]ip ip-prefix 24 permit 2.2.2.2 32
[R6]ip ip-prefix 24 permit 4.4.4.4 32
[R6]route-policy LocalPre permit node 10
[R6-route-policy]if-match ip-prefix 24
[R6-route-policy]apply local-preference 777
[R6-route-policy]route-policy LocalPre permit node 20
[R6-route-policy]quit
[R6]bgp 2067
[R6-bgp]peer 77.1.1.1 route-policy LocalPre ex
[R6]disp ip ip-prefix
Prefix-list 24
Permitted 0
Denied 0
index: 10 permit 2.2.2.2/32
index: 20 permit 4.4.4.4/32
[R6]disp ip ip-prefix
Prefix-list 24
Permitted 4
Denied 2
index: 10 permit 2.2.2.2/32
index: 20 permit 4.4.4.4/32
<R7>disp bgp routing-table //在R7上查看效果
BGP Local router ID is 10.1.57.7
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
*>i 1.1.1.1/32 55.1.1.1 0 666 0 (2005) 100i
*>i 2.2.2.2/32 66.1.1.1 0 777 0 100i
*>i 3.3.3.3/32 55.1.1.1 666 0 (2005) 100i
*>i 4.4.4.4/32 66.1.1.1 777 0 100i
*>i 5.5.5.5/32 55.1.1.1 0 100 0 (2005)i
*>i 6.6.6.6/32 66.1.1.1 0 100 0 i
*> 7.7.7.7/32 0.0.0.0 0 0 i
AS-path属性越短越优先,BGP有时叫做路径(As-Path)向量协议
也可忽略 bestroute as-path-ignore //仅仅针对本设备
i(network)>E>?(incomplete即引入的路由)
操作前却昂7.7.7.7的路由走的是R6 因为R6是从EBGP学习到的
R2:
#
ip community-filter 99 permit 2067:7 //之前的配置团体是属性,命中7.7.7.7/32
#
route-policy Select permit node 10
if-match community-filter 99
apply origin incomplete //配置为i属性
#
route-policy Select permit node 20
#
bgp 100
peer 66.1.1.1 route-policy Select import
[R2]disp bgp routing-table
BGP Local router ID is 22.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 12
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.1/32 11.1.1.1 0 100 0 i
*> 2.2.2.2/32 0.0.0.0 0 0 i
*>i 3.3.3.3/32 33.1.1.1 0 100 0 i
* i 33.1.1.1 0 100 0 i
*>i 4.4.4.4/32 44.1.1.1 0 100 0 i
* i 44.1.1.1 0 100 0 i
*>i 5.5.5.5/32 11.1.1.1 0 100 0 200i
* 66.1.1.1 0 200?
*> 6.6.6.6/32 66.1.1.1 0 0 200i
* i 11.1.1.1 100 0 200i
*>i 7.7.7.7/32 11.1.1.1 100 0 200i
* 66.1.1.1 0 200?
[R2] //验证从R6学习到的7.7.7.7的路由属性是200? 导致不会优选
多出口分离,约等于开销值(Metric),数值越小越优先。和本地优先级正好相反。
要求:在R1和R2上修改MED值,使得As200去往1.1.1.1 和3.3.3.3的路由通过R5发送数据,使得As200去往2.2.2.2 和4.4.4.4的路由通过R6发送数据
首先还原R5和R6的部分配置
[R5]bgp 2005
[R5-bgp]undo peer 77.1.1.1 route-policy LocalPre export
[R6]bgp 2067
[R6-bgp]undo peer 77.1.1.1 route-policy LocalPre export
[R1]ip ip-prefix 13 permit 1.1.1.1 32
[R1]ip ip-prefix 13 permit 3.3.3.3 32
[R1]ip ip-prefix 24 permit 2.2.2.2 32
[R1]ip ip-prefix 24 permit 4.4.4.4 32
[R1]route-policy R1 permit node 10
[R1-route-policy]if-match ip-prefix 13
[R1-route-policy]apply cost 100
[R1-route-policy]route-policy R1 permit node 20
[R1-route-policy]if-match ip-prefix 24
[R1-route-policy]apply cost 200
[R1-route-policy]route-policy R1 permit node 30
[R1-route-policy]quit
[R1]bgp 100
[R1-bgp]peer 10.1.15.5 route-policy R1 export //面向邻居R5来调用
<R1>disp ip ip-prefix
Prefix-list 13
Permitted 4
Denied 4
index: 10 permit 1.1.1.1/32
index: 20 permit 3.3.3.3/32
Prefix-list 24
Permitted 4
Denied 0
index: 10 permit 2.2.2.2/32
index: 20 permit 4.4.4.4/32
[R2]ip ip-prefix 13 permit 1.1.1.1 32
[R2]ip ip-prefix 13 permit 3.3.3.3 32
[R2]ip ip-prefix 24 permit 2.2.2.2 32
[R2]ip ip-prefix 24 permit 4.4.4.4 32
[R2]route-policy R2 permit node 10
[R2-route-policy]if-match ip-prefix 13
[R2-route-policy]apply cost 200
[R2-route-policy]route-policy R2 permit node 20
[R2-route-policy]if-match ip-prefix 24
[R2-route-policy]apply cost 100
[R2-route-policy]route-policy R2 permit node 30
[R2-route-policy]quit
[R2]bgp 100
[R2-bgp]peer 66.1.1.1 route-policy R2 export //面向邻居R6来调用
<R2>disp ip ip-pr
<R2>disp ip ip-prefix
Prefix-list 13
Permitted 4
Denied 8
index: 10 permit 1.1.1.1/32
index: 20 permit 3.3.3.3/32
Prefix-list 24
Permitted 4
Denied 4
index: 10 permit 2.2.2.2/32
index: 20 permit 4.4.4.4/32
<R7>tracert -a 7.7.7.7 3.3.3.3
traceroute to 3.3.3.3(3.3.3.3), max hops: 30 ,packet length: 40,press CTRL_C to break
1 10.1.57.5 30 ms 20 ms 20 ms
2 10.1.15.1 40 ms 20 ms 10 ms
3 10.1.13.3 30 ms 30 ms 30 ms
<R7>
如果不调整
<R7>tracert -a 7.7.7.7 4.4.4.4
traceroute to 4.4.4.4(4.4.4.4), max hops: 30 ,packet length: 40,press CTRL_C to break
1 10.1.57.5 20 ms 10 ms 10 ms
2 10.1.56.6 20 ms 20 ms 30 ms
3 10.1.26.2 20 ms 20 ms 20 ms
4 10.1.23.3 30 ms 30 ms 20 ms
5 10.1.34.4 30 ms 30 ms 50 ms
完成调整
[R7]int Serial 4/0/0
[R7-Serial4/0/0]ospf cost 2
[R7-Serial4/0/0]quit
[R7]quit
<R7>tracert -a 7.7.7.7 4.4.4.4
traceroute to 4.4.4.4(4.4.4.4), max hops: 30 ,packet length: 40,press CTRL_C to break
1 10.1.67.6 30 ms 20 ms 20 ms
2 10.1.26.2 30 ms 30 ms 10.1.56.6 20 ms
3 10.1.26.2 30 ms 30 ms 30 ms
4 10.1.23.3 30 ms 20 ms 10.1.34.4 40 ms
在As200内用本地优先影响选路(负载分担);在AS100内用MED影响AS200的路由选择(负载分担)
EBGP优于IBGP(外来的和尚会念经),和路由优先级(Preference)无关
BGP依赖于底层的IGP,会影响到达BGP的下一跳(由IGP决定)
是指出现在路由表里(dis ip rou,而不是dis bgp rou)
eBGP和iBGP路由都适用,需要满足一定的条件:1.前边的8条选路规则都不能选出最优路径 2.AS-path要完全一致
缺省情况下,BGP在选择最优路由时Cluster-List优先于Originator-ID。配置bestroute routerid-prior-clusterlist命令后,BGP在选择最优路由时Originator-ID优先于Cluster-List。
如果路由携带Originator_ID属性,选路过程中将比较Originator_ID的大小(不再比较Router ID),并优选Originator_ID最小的路由。