HCIP第十一天(笔记)

BGP的选路原则
前提条件 --- 丢弃所以不可用的路由信息
1.优选preferred-vlaue属性值最大的路由
2.优选local_preference
3.本地始发的BGP路由优于从其他对等体学习到的路由,本地 始发的路由优先级:优选手动聚合>自动聚合>network>import>从对等体学到的
4.优选AS_Path属性值最短的路由
5.优选origin属性最优的路由,origin属性值按优先级从高到低的排列是:IGP、EGP及Incomplete
6.优选MED属性值最小的路由
7.优选从EBGP对等体学来的路由(EBGP路由优先级高于IBGP路由)
8.优选到Next_Hop的IGP度量值最小的路由
9.优选Cluser_List最短的路由
10.优选Router ID(Orginator_ID)最小的设备通告的路由
11.优选具有最小IP地址的对等体通告的路由

属性名称      传播范围               默认值                            评判标准
PV                  不传播                0(0-65535)                越大越优
LP                 IBGP对等体之间    100                               越大越优
AS_Path       BGP对等体                                                 越短越优
OGN            BGP对等体                                                  I>e>?
MED             BGP对等体           继承路由表中的开销值   越小越优

3.手工聚合>自动聚合>network>import>从对等体那学来的

4.优选AS_Path属性值最短的路由
          1.如果AS_Path属性存在大括号,则大括号在选路时,需要看作是一个AS
          2.如果AS_Path属性存在小括号,则选路中不关注小括号
          
          1.抓流量[r1]ip ip-prefix AS permit 10.0.0.0 24
          2.做路由策略[r1]route-policy AS permit node 10
                               Info: New Sequence of this List.
                              [r1-route-policy]if-match ip-prefix AS
                              [r1-route-policy]apply as-path 11 22 ?
                               INTEGER<1-4294967295> AS number in asplain format (number<1-4294967295>)
                               STRING<3-11> AS number in asdot format 
                                                       (number<1-65535>.number<0-65535>)
                               additive Append to original As Number
                               overwrite Overwrite original As Number
                              [r1-route-policy]apply as-path 11 22 33 ?
                               INTEGER<1-4294967295> AS number in asplain format (number<1-4294967295>)
                               STRING<3-11> AS number in asdot format 
                                                         (number<1-65535>.number<0-65535>)
                                  additive Append to original As Number --- 在原先AS_PATH属性的基础上,增加AS号
                                  overwrite Overwrite original As Number --- 将覆盖掉原先的属性,变成定义的AS号
                              [r1-route-policy]apply as-path 11 22 33 additive 
                              [r1]route-policy AS permit node 20
                                Info: New Sequence of this List.
                              [r1-route-policy]qu
          3.调用[r1-bgp]peer 12.0.0.2 route-policy AS export
                     为了避免对AS_PATH属性防环特性的影响,我们可以添加AS_PATH属性中,已有的AS号,仅改变AS_PATH属性的长短。

5.比较OGN属性,I > e > ?
             1.抓流量[r1]ip ip-prefix OGN permit 10.0.0.0 24
             2.做路由策略[r1]route-policy OGN permit node 10
                                   Info: New Sequence of this List.
                                 [r1-route-policy]if-match ip-prefix OGN
                                 [r1-route-policy]apply origin ?
                                   egp Remote EGP
                                   igp Local IGP
                                   incomplete Unknown heritage
                                 [r1-route-policy]apply origin incomplete 
                                 [r1-route-policy]qu
                                 [r1]route-policy OGN permit node 20
                                  Info: New Sequence of this List.
                                 [r1-route-policy]
                                 [r1-route-policy]qu
             3,调用[r1-bgp]peer 12.0.0.2 route-policy OGN export

6.优选MED属性值最小的路由
    多出口鉴别属性 --- BGP协议在进行宣告时,MED属性将继承路由表中的开销值,便于本地的EBGP对等体所在的AS内部设备选路。若本地通过IBGP对等体学习到BGP路由,之后,再发送给EBGP对等体时,将不会携带MED属性,因为他不能反映自身真实的开销情况,但是,这样设计也会造成选路不佳,所以,建议所有边界设备发布路由都同时发布
   
    注意:多出口鉴别属性一定需要多出口环境下使用,我们可以通过比较路由条目AS_Path属性最左边的AS号来判断是否从同一个AS发出,如果从同一个AS发出,则判定为多出口环境,否则,将不比较第六条,直接比较后面的规则
    
    1.抓流量[r3]ip ip-prefix MED permit 4.4.4.0 24

    2.路由策略[r3]route-policy MED permit node 10
                      Info:New sequence of this List
                     [r3-route-policy]if-match ip-prefix MED
                     [r3-route-policy]apply cost 10
                     [r3-route-policy]qu
                     [r3]route-policy MED permit node 20
                      Info: New Sequence of this List.
                     [r3-route-policy]qu

    3.调用[r3-bgp]peer 13.0.0.1 route-policy MED export

7.EBGP路由优于IBGP路由


8.优选到NEXT_HOP的IGP度量值最小的路由

BGP的路由过滤
1.使用前缀列表进行过滤[r1]ip ip-prefix aa deny 192.168.1.0 24
                                      [r1]ip ip-prefix aa permit 0.0.0.0 0 less-equal 32
                                      [r1-bgp]peer 12.0.0.2 ip-prefix aa export

2.使用路由策略进行过滤[r2]ip ip-prefix aa permit 192.168.2.0 24
                                      [r2]route-policy aa deny node 10
                                        Info: New Sequence of this List.
                                      [r2-route-policy]if-match ip-prefix aa
                                      [r2-route-policy]qu
                                      [r2]route-policy aa permit node 20
                                        Info: New Sequence of this List.
                                      [r2-route-policy]qu
                                      [r2-bgp]peer 12.0.0.1 route-policy aa import

3.使用过滤列表进行过滤[r3-acl-basic-2000]rule deny source 192.168.3.0 0 ---- 注意:使用过滤列表时,抓取流量的列表必须使用拒绝动作
                                      [r3-acl-basic-2000]rule permit source any --- 注意:对于不需要过滤的流量,一定要进行放通
                                      [r3-bgp]peer 13.0.0.1 filter-policy 2000 import

BGP的社团属性
                        社团属性 --- 32位二进制构成 ---- 1.使用十进制表示;2.AS:NN --- 一条路由条目可以同时打多个社团属性

                        公有社团属性
                        1. 0X00000000 --- 0 ---“Internet”---- 所有的BGP路由默认都打上了“Internet”的社团属性
                        2. 0xFFFFFF02 --- “no - advertise” ---- 如果BGP路由打上该社团属性,则代表不允许通告给其他的BGP对等体
                        3. 0xFFFFFF01 --- “no - export”---- 如果BGP路由打上该社团属性,则将不允许通告给自己的EBGP对等体(不包括联邦的EBGP对等体)
                        4. 0xFFFFFF03 ---“no -export - subconfed”---- 如果BGP路由打上该社团属性,则将不允许通告给自己的EBGP对等体(包括联邦的EBGP对等体)

                        [r1]route-policy com permit node 10
                         Info: New Sequence of this List.
                        [r1-route-policy]apply community ?
                         INTEGER<0-4294967295> Specify community number
                         STRING<3-11> Specify aa<0-65535>:nn<0-65535>
                         internet Internet(well-known community attributes)
                         no-advertise Do not advertise to any peer (well-known community 
                                            attributes)
                         no-export Do not export to external peers(well-known community 
                                            attributes)
                         no-export-subconfed Do not send outside a sub-confederation(well-known 
                                            community attributes)
                         none No community attribute
                        [r1-route-policy]apply community no-advertise
                        [r1-route-policy]qu
                        [r1-bgp]peer 12.0.0.2 route-policy com export 
                        [r1-bgp]peer 12.0.0.2 advertise-community --- 开启社团属性的传递功能

需求:AS1中分别创建
172.16.0.0/24,172.16.1.0/24,172.16.2.0/24,172.16.3.0/24。之后,0.0和1.0带上1:11的社团属性,2.0和3.0带上1:22的社团属性。要求,1:11社团的路由不传递,1:22的路由no_export。

1.做社团属性的策略[r1]route-policy com1 permit node 10
                                   Info: New Sequence of this List.
                               [r1-route-policy]apply community 1:11
                               [r1-route-policy]qu
                               [r1]route-policy com2 permit node 10
                                 Info: New Sequence of this List.
                               [r1-route-policy]apply community 1:22

2.发布路由
 network 172.16.0.0 255.255.255.0 route-policy com1 
 network 172.16.1.0 255.255.255.0 route-policy com1 
 network 172.16.2.0 255.255.255.0 route-policy com2 
 network 172.16.3.0 255.255.255.0 route-policy com2 

3.依靠社团属性抓取流量 --- community-filter
[r1]ip community-filter 1 permit 1:11
[r1]ip community-filter 2 permit 1:22

4.做路由策略[r1]route-policy aaa deny node 10
                      Info: New Sequence of this List.
                    [r1-route-policy]if-match community-filter 1
                    [r1-route-policy]qu
                    [r1]route-policy aaa permit node 20
                     Info: New Sequence of this List.
                    [r1-route-policy]if-match community-filter 2
                    [r1-route-policy]apply community no-export ?
                      INTEGER<0-4294967295> Specify community number
                      STRING<3-11> Specify aa<0-65535>:nn<0-65535>
                      additive Add to the existing community
                      internet Internet(well-known community attributes)
                      no-advertise Do not advertise to any peer (well-known community 
                                       attributes)
                      no-export Do not export to external peers(well-known community 
                                        attributes)
                      no-export-subconfed Do not send outside a sub-confederation(well-known 
                                        community attributes)
                      <cr> Please press ENTER to execute command 
                    [r1-route-policy]apply community no-export additive 
                    [r1-route-policy]qu
                    [r1]route-policy aaa permit node 30
                    [r1-route-policy]qu

5.调用[r1-bgp]peer 12.0.0.2 route-policy aaa export
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

田驰02

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

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

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

打赏作者

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

抵扣说明:

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

余额充值