实操华为BGP选路原则

1、实验拓扑

2、实验目的

完成所有选路规则的实验,重点就是当前的HCIE考试考核的内容~MED

BGP选路原则:

世界恋爱组织亚洲办公室

W(世界)~华为的PreVal

L(恋爱)~Local Preference

O(组织)~本地起源sOurced

A(亚洲)~AS Path

O(办公室)~Origin CODE

墓碑下的半兽人(MEML ORC)

MED

EBGP优于IBGP

Metric

Load Balance

Cluster list

RID小的

Peer后地址小的

3、实验步骤

操作前先需要先还原部分设备配置

3.1 华为的PrefVal

本地入方向生效,数值越大越优先,缺省值0

[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>

还原配置

3.2 Local Preference

公认可选属性(类比道德,对比刑法)

在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

<R7>

3.3 AS Path

公认必遵属性【类比刑法,必须遵守,否则报错】

AS-path属性越短越优先,BGP有时叫做路径(As-Path)向量协议

也可忽略    bestroute as-path-ignore //仅仅针对本设备

实验请查看上期作业

3.4 Origin CODE

公认必遵属性,起源可类比阿三哥的种姓制度

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?  导致不会优选

3.5 重点 MED

多出口分离,约等于开销值(Metric),数值越小越优先。和本地优先级正好相反。

在ASBR上来应用,起到一个挖墙脚、策反的效果

要求:在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的路由选择(负载分担)

下一跳、MED、本地优先级属性都可以在联邦成员AS之间传递

3.6 EBGP优于IBGP

EBGP优于IBGP(外来的和尚会念经),和路由优先级(Preference)无关

3.7 Metric,到达下一跳的IGP的开销值较小的优选

BGP依赖于底层的IGP,会影响到达BGP的下一跳(由IGP决定)

3.8 Load Balance,出现负载分担的路由表

是指出现在路由表里(dis ip rou,而不是dis bgp rou)

eBGP和iBGP路由都适用,需要满足一定的条件:1.前边的8条选路规则都不能选出最优路径 2.AS-path要完全一致

优选Cluster_List最短的路由。

说明:

缺省情况下,BGP在选择最优路由时Cluster-List优先于Originator-ID。配置bestroute routerid-prior-clusterlist命令后,BGP在选择最优路由时Originator-ID优先于Cluster-List。

优选Router ID最小的设备发布的路由。

说明:

如果路由携带Originator_ID属性,选路过程中将比较Originator_ID的大小(不再比较Router ID),并优选Originator_ID最小的路由。

比较对等体的IP Address,优选从具有较小IP Address的对等体学来的路由。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ender_joe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值