• BGP(Border Gateway Protocol)


    目录

    BGP报文类型

    BGP状态机 

    BGP邻居

    BGP同步规则

    Transit AS中的IBGP路由传递

    IBGP水平分割原则

    路由通告规则

    计时器

    配置命令

    维护BGP

    BGP表

    路径属性

    WEIGHT 

    LOCAL PREFERENCE 

    AS-path

    Origin 

    MED

    NEXT_HOP

    NEXT_HOP on shared Media

    COMMUNITY

    Atomic_Aggregate及Aggregator

    自动汇总

    手工汇总

    原子字符 

    乘法字符

    范围字符 

    使用正则表达式匹配AS_PATH示例

    使用ip as-path access-list匹配路由

    BGP Communities

    BGP Filters

    Prefix-list

    distribute-list

    route-map

    advertise-map

    ORF(Outbound Route Filtering)

    路由拆分BGP Deaggregation

    中转AS中的IBGP问题

    路由反射器技术背景

    路由反射规则

    路由反射器环境下的防环

    ​Originator_ID、Cluster_list

    路由反射簇

    路由反射器的冗余

    拓扑图

    联邦内的BGP路由路径属性

    传统BGP路由属性MED传递规则 

    路由反射器与联邦选用方案

    拓扑图 

    1.优选具有最大Weight值的路由

    2.优选具有最大Local_Pref值的路由

    3.优选起源于本地的路由

    4.优选AS_PATH最短的路由

    5.ORIGIN(i>e>?)

    6.优选MED最小的路由

    7.优选EBGP邻居的路由(相对于IBGP)

    8.优选到NEXT_HOP最近的路由

    9.BGP负载均衡

    10.优选最老的EBGP邻居的路由 

    11.优选RouterlD最小的BGP邻居的路由

    12.优选Cluster_List最短的路由

    13.选择邻居IP地址最小的路由

    实验环境

    EBGP非等价负载均衡

    IBGP非等价负载均衡

    BGP Link Bandwidth 

    BGP Link Bandwidth的预备条件

    BGP Link Bandwidth特性的限制

    BGP Link Bandwidth Extended Community

    Cost Community概述

    Cost Community的限制

    Cost Community如何影响BGP最佳路径选择

    Cost Community的顺序

    实验:cost community基础

    实验∶测试默认Cost Community

    实验:Cost Value和Cost ID的PK

    实验∶测试pre-bestpath的POI

    实验:cost community在联邦eBGP邻居之间的传递

    私有AS

    如何移除AS_PATH中的私有AS

    neighbor remove-private-as命令注解

    DUAL AS的实现

    DUAL AS命令详解

    Dual AS配置示例1

    Dual AS配置示例2

    Dual AS配置示例3

    Dual AS配置示例4

     BGP PA配置步骤


    BGP报文类型

    报文名称作用是什么 什么时候发包
    open协商BGP邻居的各项参数,建立邻居关系通过TCP建立BGP连接,发送open报文 
    update进行路由信息的交换连接建立后,有路由需要发送或路由变化时,发送update通告对端路由信息
    notification报告错误,中止邻居关系当BGP在运行中发现错误时,要发送notification报文通告BGP对端
    keepalive维持邻居关系定时发送keepalive报文以保持BGP邻居关系的有效
    route-refresh为保证网络稳定,触发更新路由的机制

    当路由策略发生变化时,触发请求邻居重新通告路由 

    BGP状态机 

    Peer状态名称发什么包在做什么
    ldle尝试建立TCP连接开始准备TCP的连接并监视远程peer启动TCP连接,启用BGP时,要准备足够的资源
    Connect发TCP包正在进行TCP连接,等待完成中,认证都是在TCP建立期间完成的。如果TCP连接不上则进入Active状态,反复尝试连接
    Active发TCP包TCP连接没建立成功,反复尝试TCP连接
    OpenSent发Open包TCP连接建立已经成功,开始发送Open包,Open包携带参数协商对等体的建立
    OpenConfirm发Keepalive包参数、能力特性协商成功,自己开始发送Keepalive包,等待对方的Keepalive包
    Established发Update包已经收到对方的Keepalive包,双方能力特性一致,开始使用Update通告路由信息

    BGP邻居

    运行BGP的路由器被称为BGP speaker
    BGP对等体也叫BGP邻居,建立基于TCP的关系

    EBGP : BGP位于不同自治系统的路由器之间,称为EBGP

    EBGP邻接关系,必须满足三个条件 
            -EBGP之间自制系统号不同
            -定义邻居建立TCP会话
            -neighbor中指定的IP地址要可达

    IBGP:位于同一个自治系统的路由器之间运行
    建立IBGP邻接关系,满足的条件

            -自治系统号相同 

            -定义邻居建立TCP会话 

    BGP同步规则

    BGP同步规则指出,BGP路由器不应使用通过IBGP获悉的路由或将其通告给外部邻居,除非该路由是本地的或通过IGP获悉的
    CiscoIOS默认关闭同步

    同步关闭:不需要从IGP学到该路由就转发(会产生路由黑洞问题)
    同步开启:则路由器通过IBGP获悉路由后,将等待IGP将该路由传遍整个自治系统,然后再将其通告给外部领居

    Transit AS中的IBGP路由传递

    • 解决办法1 

    2b46eb4000ec4b609c22e4a2bf0a048c.png

    •  解决办法2

    全互联IBGP邻居关系

    IBGP全互联虽然能解决transit AS内的路由黑洞问题,但是却造成BGP路由器需耗费大量资源维护BGP连接的新问题

    解决办法:
    路由反射器、联邦

    IBGP水平分割原则

    BGP防环是通过AS_PATH实现的,而AS_PATH仅仅在路由离开AS才回被更改,因此在AS内,IBGP就没有EBGP的防环能力,为了防止环路的出现,BGP路由器不会将从IBGP邻居学习过来的路由再通告给自己其他IBGP邻居。(在AS内部,AS-PATH不会改变,因此很容易出现环路)

    路由通告规则

    ·当存在多条路径时,BGP Router只选取最优的路由来使用(没有负载均衡的情况下) 
    ·BGP只把自己使用的路由传递给BGP领居

    ·从EBGP获得的路由会向它所有BGP领居通告(包括EBGP和IBGP) 
    ·从IBGP获得的路由不向它的IBGP邻居通告(水平分割)
    ·从IBGP获得的路由是否通告给它的EBGP领居要视IGP和BGP同步的情况来决定

    ·BGP表:包含了从邻居学习所有路由,以及到达目的网段的多个路径和属性
    ·路由表∶列出了到达目的网段的最佳路径,EBGP路由AD为20,IBGP路由AD为200

    计时器

    • KEEPALIVE

    默认60s ,keepalive计时器不会在Open消息中交互
    如果当前手工配置的 keepalive timer 小于min ( holdtime ) /3,则取配置值
    如果当前手工配置的keepalive timer 大于min ( holdtime ) /3,则取 int[min ( holdtime ) /3]

    其中min ( holdtime )为两台BGP邻居间holdtime的最小值 

    小结:选小的

    • HOLDTIME 

    CISCO默认180s ( 3倍KEEPLIVE timer ),该计时器包含在open报文中
    必须收到一个KEEPLIVE 或更新消息前所允许经过的最大时间。如果两端Holdtime不一致,双方接受较小的的时间

    配置命令

    ***创建BGP进程***
    Router(config)#router bgp autonomous-system
    ·仅仅执行命令router bgp并不能在路由器上激活BGP,必须至少执行一个子命令才能在路由器上激活BGP进程
    ·在路由器上只能配置一个BGP实例
    -----------------------------------------------------------------------------------------
    ***指定BGP邻居及激活BGP会话***
    Router(config-router)# neighbor {ip-address | peer-group-name} remote-as autonomous-system
    ·指定邻居的IP地址必须路由可达
    .BGP邻居需手工指定
    ·AS决定了与邻居建立的是EBGP会话还是IBGP会话
    -----------------------------------------------------------------------------------------
    ***指定BGP将通告的网络***
    Router(config-router)network network-number [mask network-mask] [route-map map-tag]
    ·BGP命令network为通告哪些IGP路由进BGP进程,而不是在接口上启用BGP
    ·network支持无类前缀,前缀必须与路由表中的条目完全匹配
    ·如果不指定mask,只通告主类网络号,而且仅当主类网络中至少有一个子网出现在IP路由表中,BGP才会将该主类网络作为一条BGP路由通告
    ·指定了mask,则仅当路由选择表中有与该网络完全匹配的条目时才被通告出去
    -----------------------------------------------------------------------------------------
    ***BGP同步***
    Router(config-router)#no synchronization    //关闭同步(默认关闭)
    Router(config-router)#synchronization    //开启同步
    -----------------------------------------------------------------------------------------
    ***BGP router-id***
    Router(config-router)# bgp router-id x.x.x.x    //手工设置BGP routerID
    -----------------------------------------------------------------------------------------
    ***修改next-hop***
    ·BGP是AS-by-As的路由协议,而不是router-by-router的路由协议
    ·在BGP中,next-hop并不意味着是下一台路由器,而是到达下一个AS的IP地址
    ·EBGP中,默认next-hop为发送更新的邻居路由器的IP地址
    ·IBGP中,从EBGP传来的next-hop属性在IBGP中保持不变的被传递
    -----------------------------------------------------------------------------------------
    ***EBGP multihop***
    Router(config-router)#neighbor {ip-address | peer-group-name} ebgp-multihop [ttl]
    ·建立对等关系时,如果不进行额外配置,EBGP路由器只能使用与外部EBGP路由器直接相连的接口地址
    ·以上命令如若不显式指定跳数时,则为255跳
    -----------------------------------------------------------------------------------------
    ***BGP身份验证***
    Router(config-router)#neighbor {ip-address | peer-group-name} password string
    ·BGP支持MD5邻居身份验证
    ·启用身份验证后,将对通过对等体之间的TCP连接传输的所有数据等进行验证
    ·认证都是在TCP建立连接的时候完成的

    维护BGP

    •  硬重置

    断开相应的TCP连接,通过这些会话收到的所有信息都将失效,并从BGP表中删除
    clear ip bgp {neighbor-address}
    clear ip bgp *

    • 软重置( soft reconfiguration ) 

    -不拆除并重建TCP或BGP连接,而是仅触发更新操作以便让新的路由策略生效
    -软重置可以仅用于出站或入站策略,也可同时用于出入站策略
    出站软重置
        –不会拆除TCP连接,不会重置BGP会话,仅触发更新操作以便让新的路由策略生效(发送update消息)
        –需要修改出站策略时,建议使用该命令
        -clear ip bgp soft out
    入站软重置
        -本地发送route-refresh给所有BGP邻居
        -clear ip bgp soft in
    cisco ios 12.1开始全面支持入站路由的动态软重配置,但在之前的版本在使用入站软重配置之前必须首先在BGP进程中增加如下配置∶
    neighbor x.x.x.x soft-reconfiguration inbound
    然后再使用clear ip bgp soft in命令
    这条命令会将x.x.x.x邻居发送过来的BGP路由存储在内存中,当配置入站软重置后,路由器不再向邻居发送更新请求,而是直接在内存中存储的路由中执行新配置的入站策略,以此来防止触发大批量的路由更新而造成资源的浪费,但是这种操作仍会耗费内存,因此在使用的时候要非常慎重

    BGP表

    ***show ip bgp***
       Network          Next Hop            Metric LocPrf Weight Path
    *>i4.4.4.0/24       3.3.3.3                  0    100      0 400 i
    第一栏的可能取值如下:
    *    可用的路由(但不一定是最优)
    s    被抑制的路由条目,例如做了路由汇总,抑制了明细
    d    被惩罚( dampening )的路由,路由受到了惩罚,虽该路由当前可能正常,但惩罚期结束前不会被通告
    h    被惩罚( dampening )的路由,路由可能出现了故障( down ),有历史信息,但没有最佳路由
    r    路由没有被装载进RIB表,例如由于AD值等原因导致
    S    大写的s ,stale,表示过期的路由
    第二栏
    >    BGP算法选出的最优路径
    第三栏
    为空,或为i。为空表示该路由从EBGP邻居获取,为i表示这是从IBGP学习到的路由
    -------------------------------------------------------------------------------------------
    ***show ip bgp 4.4.4.0***
    BGP routing table entry for 4.4.4.0/24, version 2
    Paths: (1 available, best #1, table Default-IP-Routing-Table)
    Flag: 0x820
      Not advertised to any peer
      400
        3.3.3.3 (metric 65) from 3.3.3.3 (3.3.3.3)
    //  ^          ^                ^          ^
    //  next_hop   到达该next_hop  BGP领居的    领居的RouterID
    //             的metric(IGP)   更新源地址
          Origin IGP, metric 0, localpref 100, valid, internal, best

    路径属性

    公认属性 Well-Known

    公认强制属性 Well-known mandatory(BGP路由器要支持,包含在update包)


    公认自由决定属性 Well-known discretionary(BGP路由器要支持,不一定包含在update包)

    Origin

    AS-Path

    Next hop


    Local-Preference

    ATOMIC_Aggregate

    可选属性 Optional

    可选传递的 Optional transitive(可以不支持该属性,但即使不支持也应当接受包含该属性的路由并传递给其他邻居)


    可选非传递的 Optional non-transitive(可以不支持该属性,不识别的BGP进程可以忽略包含这个属性的更新消息,并且不传递给其他BGP邻居)

    Community

    Aggregator


    MED

    Originator_ID

    Cluster_list

    Weight

    • WEIGHT 

    Cisco私有
    本地路由器有效

    • 在路由器本地配置,只提供本地路由策略,不会传播给任何BGP邻居
    • 范围:0~65535;越大越优先
    • 路由器本地始发的路径默认权重为32768,从其他BGP邻居学习到的为0
    • LOCAL PREFERENCE 

    1. 告诉AS中的路由器,哪条路径是离开AS的首选路径
    2. 值越高路径越优
    3. 只发送给IBGP邻居,而不能传递给EBGP邻居
    4. 默认本地优先级为100

    bgp default local-preference 500    //修改默认LP值

    • AS-path

    1. 是前往目标网络的路由经过的自制系统号列表,通告该路由的自治系统号位于列表末尾
    2. 作用︰确保无环,通告给EBGP时会加上自己的AS号;通告给IBGP时不修改AS-path
    3. AS_SEQENCE:一个有序的AS号列表
    4. AS_SET:一个去往特定目的地所经路径上的无序AS号列表
    • Origin 

    标识路由的起源,有下列3种可能:

    1. i通过BGP network,也就是起源于IGP,因为BGPnetwork必须保证该网络在路由表中
    2. e是由EGP这种早期的协议重发布而来
    3. ?Incomplete从其他渠道学习到的,路由来源不完全(确认该路由来源的信息不完全)。(重发布的路由)
    • 路由优选顺序:lowest origin code (IGP> EGP > Incomplete)
    • MED

    • 是一种度量值,用于向外部邻居指出进入AS的首选路径,即当入口有多个时,自治系统可以使用MED动态的影响其他AS如何选择进入路径
    • 度量值越小路径越优
    • MED是在AS之间交换,MED发送给EBGP对等体,这些路由器在AS内传播MED,不传递给下一个AS
    • 默认情况下,仅当路径来自同一个AS中的不同EBGP邻居时,路由器才比较他们的MED属性
    • CISCO默认MED为0

    MED设置方法:

    1. 将IGP路由引入BGP时关联Route-map进行设置
    2. 对BGP Peer应用INOUT方向的Route-map进行设置
    3. 非 Route-map(自动)方式:

           使用network或redistribute方式将IGP路由引入BGP时,MED将继承IGP路由的Metric(直           连路由及静态路由的Metric为0)
           使用aggregate-address方式引入路由,则MED为空


    总结如下∶

    • network        本地从IGP路由协议学习到的路由进BGP,MED值继承IGP协议中的metric
    • network        本地直连接口的网段进BGP,MED值为0;network本地静态路由进BGP,MED值为0
    • redistribute   本地从IGP路由协议学习到的路由进BGP;MED值继承IGP协议中的metric
    • redistribute   本地直连接口网段进BGP,MED值为0;redistribute本地静态路由进BGP,MED值为0
    • NEXT_HOP

    1. 从EBGP领居收到路由更新,下一跳是领居发送更新的接口IP
    2. 路由来自IBGP邻居,并描述的是AS外的目的地(下一跳是AS外发送这条路由更新的接口IP)
    3. 如果路由传递自IBGP邻居,并由AS内BGP路由器引入
    • 如果是通过aggregate-address 命令被注入的,那么next-hop等于执行汇总路由器(的更新源IP)
    • 如果是通过network或重发布注入的,那么在注入前该前缀的IGP下一跳将成为BGP的next-hop
    • NEXT_HOP on shared Media

    cee9f916aba740df91d516a79a560ad5.png

     NEXT_HOP on NBMA,要注意有没有做映射

    • COMMUNITY

    1.  一种标记,用于简化路由策略的执行
    2. 可以将某些路由分配一个特定的COMMUNITY属性,之后就可以基于COMMUNITY值而不是每条路由进行BGP属性的设置了
    99185181580846b4b24f35da8d811a18.png

     98051303bf444a7582874063504e43cf.png

     d77d1dc4d2574d76b68ccca91b2286b7.png

     fc795888bfb345bf894f67969e29456e.png

    • Atomic_Aggregate及Aggregator

    d07f2b53ac15499cb1de97df9c9cb74a.png

     aggregate-address 172.16.0.0 255.255.0.0 summary-only

     自动汇总

    BGP自动汇总( auto-summary )只汇总重发布引入的路由,以及使用network命令有类宣告方式引入的路由。目前Cisco IOS默认关闭自动汇总 

    52c525e5417b46c68585c47b0485e189.png

     R1关闭自动汇总

    1. network主类       
    2. 结果:R2上看不到BGP路由
    3. network明细       
    4. 结果:
    5. Network Next Hop Metric LocPrf Weight Path
    6. *>i172.16.1.0/24 10.1.12.1 0 100 0 i
    7. 重分布
    8. Network Next Hop Metric LocPrf Weight Path
    9. r>i10.1.12.0/24 10.1.12.1 0 100 0 ?
    10. *>i172.16.1.0/24 10.1.12.1 0 100 0 ?
    11. *>i172.16.2.0/24 10.1.12.1 0 100 0 ?
    12. *>i172.16.3.0/24 10.1.12.1 0 100 0 ?
    13. //直连优先级最高,重发布进BGP的路由AD值为200
    14. //?表示是重发布进来的

    R1开启自动汇总

    1. network主类
    2. Network Next Hop Metric LocPrf Weight Path
    3. *>i172.16.0.0 10.1.12.1 0 100 0 i
    4. network明细
    5. Network Next Hop Metric LocPrf Weight Path
    6. *>i172.16.1.0/24 10.1.12.1 0 100 0 i
    7. 重分布
    8. Network Next Hop Metric LocPrf Weight Path
    9. *>i10.0.0.0 10.1.12.1 0 100 0 ?
    10. *>i172.16.0.0 10.1.12.1 0 100 0 ?

    小结:关闭汇总就没效了,开启汇总只有network明细不汇总 

    手工汇总

    30fd03374ba14e0ab363a0e90173782d.png

    aggregate-address 汇总地址

    1. R3(config-router)#aggregate-address 172.16.0.0 255.255.0.0
    2. //R5上看到汇总和明细都有
    3. Network Next Hop Metric LocPrf Weight Path
    4. *> 172.16.0.0 10.1.34.3 0 0 300 i
    5. *> 172.16.1.0/24 10.1.34.3 0 300 100 i
    6. *> 172.16.2.0/24 10.1.34.3 0 300 100 i
    7. *> 172.16.10.0/24 10.1.34.3 0 300 200 i
    8. *> 172.16.11.0/24 10.1.34.3 0 300 200 i

     aggregate-address 汇总地址 summary-only

    1. R3(config-router)#aggregate-address 172.16.0.0 255.255.0.0 summary-only
    2. //R5上只有条汇总
    3. Network Next Hop Metric LocPrf Weight Path
    4. *> 172.16.0.0 10.1.35.3 0 0 300 i
    5. R5#sho ip bgp 172.16.0.0
    6. BGP routing table entry for 172.16.0.0/16, version 6
    7. Paths: (1 available, best #1, table Default-IP-Routing-Table)
    8. Not advertised to any peer
    9. 300, (aggregated by 300 10.1.35.3) //汇总来自AS300,IP为10.1.35.3的接口
    10. 10.1.35.3 from 10.1.35.3 (10.1.35.3)
    11. Origin IGP, metric 0, localpref 100, valid, external, atomic-aggregate, best

    aggregate-address 汇总地址 summary-only as-set 

    1. R3(config-router)#$ddress 172.16.0.0 255.255.0.0 summary-only as-set
    2. //R5
    3. Network Next Hop Metric LocPrf Weight Path
    4. *> 172.16.0.0 10.1.35.3 0 0 300 {100,200} i <-
    5. //在R1上重发布,R3上看
    6. Network Next Hop Metric LocPrf Weight Path
    7. *> 172.16.0.0 0.0.0.0 100 32768 {100,200} ? <-
    8. s> 172.16.1.0/24 10.1.13.1 0 0 100 ?
    9. s> 172.16.2.0/24 10.1.13.1 0 0 100 ?
    10. s> 172.16.10.0/24 10.1.23.2 0 0 200 i
    11. s> 172.16.11.0/24 10.1.23.2 0 0 200 i
    1. 可以继承明细路由的BGP某些路径属性。as-set继承明细属性的规则如下∶
    2. As-path 将收到的所有明细路由的as号都放置在{}中,计算AS_Path长度时这些AS只被算为1AS
    3. origin 继承最差的origin属性
    4. community 继承所有明细路由的community
    5. MED 不继承
    6. LP 取明细路由中LP的最大值
    7. NEXT_HOP 汇总路由为0.0.0.0(因为汇总路由为本地产生)

    aggregate-address 汇总地址 suppress-map xxx as-set 

    1. R3(config-router)#$.16.0.0 255.255.0.0 summary-only as-set suppress-map 1
    2. //R5
    3. Network Next Hop Metric LocPrf Weight Path
    4. *> 172.16.0.0 10.1.35.3 0 0 300 {100,200} ?
    5. *> 172.16.10.0/24 10.1.35.3 0 300 200 i
    6. *> 172.16.11.0/24 10.1.35.3 0 300 200 i
    1. 用于宣告聚合及选定的明细路由(抑制特定的明细路由),后面跟上route-map xx,被route-map 匹配(permit)的路由将被过滤,其他放行
    2. 抑制列表虽然调用route-map,但是route-map只能用于匹配,不能用于设置属性(不能用set 命令)

     针对特定邻居取消抑制

    1. R3(config-router)#neighbor 10.1.34.4 unsuppress-map 1
    2. //R3上放行172.16.1.0这条明细
    3. //R4
    4. Network Next Hop Metric LocPrf Weight Path
    5. *> 172.16.0.0 10.1.34.3 0 0 300 {100,200} ?
    6. *> 172.16.1.0/24 10.1.34.3 0 300 100 ?

     advertise-map

    1. R3(config-router)#$.16.0.0 255.255.0.0 summary-only as-set advertise-map 1
    2. //当advertise-map匹配的路由全部都没有,汇总路由会消失;没被匹配的路由没有,只要advertise-map匹配的路由还在,汇总就还在
    3. //继承领居传来的community=no-adv

    attribute-map

    1. R3(config-router)#$.16.0.0 255.255.0.0 summary-only as-set attribute-map aa
    2. Network Next Hop Metric LocPrf Weight Path
    3. *> 172.16.0.0 10.1.34.3 66 0 300 100 i
    4. //给汇总路由设置属性
    5. //这里设置的是Metric值

    原子字符 

    .匹配任何单个的字符,包括空格
    ^一个字符串的开始
    $一个字符串的结束
    _匹配任意的一个分隔符如^、$、空格、tab、逗号、{、}
    |管道符,逻辑或
    \转义符,用来将紧跟其后的控制字符转变为普通字符

    示例:

    ^a.$匹配一个以a开始,任意单一字符结束的字符串,如a0,a!等
    ^100_匹配100 、100 200、100 300 400等
    ^100$匹配100
    100$|400$匹配100、1400、300 400等
    ^65000$仅仅匹配(65000)

    乘法字符

    *

    匹配前面字符0次或多次出现
    +匹配前面字符1次或多次出现
    匹配前面字符的0次或1次出现

    示例:

    abc*d

    匹配abd、abcd、abccd、abcccd等

    abc+d匹配abcd、abccd、abcccd等
    abc?d匹配abd、abcd、abcdefg等
    a(bc)?d匹配ad、abcd、aaabcd等

    ·一个乘法字符可以应用于一个单字符或多个字符,如果应用于多字符,需将字符串放入( )中

    范围字符 

    [        ]表示一个范围。只匹配包含在范围内的字符之一。
    可以在一个范围的开始使用^来排除范围内的所有字符,也可以使用下划线_来指定一个区间。

    示例

    [abcd]匹配只要出现了a、b、c、d的内容
    [a-c 1-2]$匹配a、a1、62、1b、xv2等
    [^act]$匹配不以a或c或t结尾的内容
    [123].[7-9]159 220、91 70

    使用正则表达式匹配AS_PATH示例

    ^$匹配本地AS内的路由
    .*允许.匹配0次或多次(匹配所有)
    ^100$只匹配为100的AS_PATH
    _100$匹配以100结束的AS_PATH
    ^10[012349]$匹配为100~104、109的AS_PATH
    ^10[^0-6]$匹配除了为100~106的AS_PATH
    ^10.匹配100~109,10 (这里有空格)
    ^(100|200)$匹配为100或200的AS_PATH
    12(_34)?_56匹配12 56、12 34 56

    注意as-path access-list也是默认隐含拒绝所有

    使用ip as-path access-list匹配路由

    示例1搭配filter-list
    57e4e8d365524c46a834ac14ea1dc17c.png

    1. //R2
    2. L0172.16.1.1
    3. L1172.16.11.1 //用route-map为该路由增加as-path为600as
    4. //在R3上过滤as号为600的路由更新,相关代码如下:
    5. ip as-path access-list 1 deny _600$
    6. ip as-path access-list 1 permit .*
    7. router bgp 300
    8. neighbor 10.1.23.2 filter-list 1 in

    示例2搭配route-map

    还是上面那张图,要求:将172.16.11.0/24这条路由限制在AS300

    1. R3上相关代码如下:
    2. ip as-path access-list 1 permit _600$
    3. route-map 1 permit 10
    4. match as-path 1
    5. set community local-AS
    6. route-map 1 permit 20
    7. router bgp 300
    8. neighbor 10.1.23.2 route-map 1 in
    9. //
    10. R3#sho ip bgp 172.16.11.0
    11. BGP routing table entry for 172.16.11.0/24, version 12
    12. Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised outside local AS)
    13. Flag: 0x820
    14. Not advertised to any peer
    15. 200 600
    16. 10.1.23.2 from 10.1.23.2 (172.16.11.1)
    17. Origin IGP, metric 0, localpref 100, valid, external, best
    18. Community: local-AS <<<<<---------

    Router# show ip bgp regexp xx
    显示BGP表中所有被该正则表达式匹配上的路由,这是一个非常不错的工具

     BGP Communities

    1. BGP communities是一种路由标记方法,用于确保路由过滤和选择的连续性 
    2. 可选传递属性,不支持该属性的BGP router原封不动的将community值传递给下游BGP邻居 

    为路由前缀分配Community

    9e8d20b107b74c00ae801dc23994ccb3.png

    1. R1
    2. neighbor 10.1.12.2 send-community
    3. neighbor 10.1.12.2 route-map 1 out
    4. route-map 1 permit 10
    5. match ip address prefix-list 1
    6. set community 6553611
    7. ip prefix-list 1 seq 5 permit 11.11.11.0/24

    为路由前缀分配多个Community

     还是上面那张图,在R2上给11.11.11.0/24这条路由添加no-export属性

    1. //R2
    2. ip community-list 11 permit 100:11
    3. neighbor 10.1.23.3 route-map 1 out
    4. route-map 1 permit 10
    5. match community 11
    6. set community no-export additive

    用community-list匹配团体属性

    lp community-list 1 permit 100:11

    匹配。匹配community中包含100:11的路由

    lp community-list 1 permit 100:11 no-adv

    不匹配。要求100:11及no-adv两者都有才匹配成立

    lp community-list 1 permit 100:11

    lp community-list 1 permit no-export( 或将no-export换成no-adv )

    匹配。只要community中包含100:11或no-export

    ip community-list 12 permit internet

    默认所有路由都属于internet

    lp community-list 11 permit no-export

    route-map test permit 10
    match community 11 exact-match        //严格匹配

    严格匹配community属性为no-export的路由,多一点,少一点都不行

    删除某个或多个community值 

    ip community-list standard del permit no-export        //匹配要删除的commu值
    route-map test permit 10
    set comm-list del delete        //用这条命令删除

    //删除多个就写多行,一行写多个值不生效

    配置community-list

    lp community-list 1-99 permit|deny value [value...]
    定义标准的community-list,使用internet关键字匹配任何community
    lp community-list 100-199 permit|deny regexp
    定义扩展的community-list,可使用正则表达式匹配community
    show ip community-list 
    查看配置的community-list 
    show ip bgp x.X.X.X 
    查看BGP路由的详细信息,包括community

     BGP Filters

    2b9c950a0c7f406bb6bebf9fc10412a5.png

    Prefix-list

    R2上,过滤掉172.16.2.0/24路由,其他放行 

    1. R2(config)#ip prefix-list 1 deny 172.16.2.0/24
    2. R2(config)#ip prefix-list 1 permit 0.0.0.0/0 le 32
    3. R2(config)#router bgp 200
    4. R2(config-router)#neighbor 10.1.23.3 prefix-list 1 out

    distribute-list

    示例1

    R2上,过滤掉172.16.2.0/24路由,其他放行

    1. R2(config)#access-list 1 deny 172.16.2.0
    2. R2(config)#access-list 1 permit any
    3. R2(config)#router bgp 200
    4. R2(config-router)#neighbor 10.1.23.3 distribute-list 1 out //对指定领居生效

    示例2

    R2上,过滤掉172.16.2.0/24路由,其他放行

    还是上图

    1. R2(config)#ip prefix-list 1 deny 172.16.2.0/24
    2. R2(config)#ip prefix-list 1 permit 0.0.0.0/0 le 32
    3. R2(config)#router bgp 200
    4. R2(config-router)#distribute-list prefix 1 out //对所有领居生效

     小结:过滤路由可以对特定领居也可以所有领居

    8f197acfc4cf4fe4845d393db4cb79b6.png

    8d888d3d634441e58fee99563658839f.png

    这里的无效指的是命令无效。

    redistribute ospf 1
    默认只重发布Intra-Area(区域内)及Inter-Area(区域间)路由

    match external                只重发布E1及E2
    match external 1             只重发布E1 

    match external 2             只重发布E2

    match nssa-external       只重发布NSSA外部路由

    route-map

    9b7b8d9421804a838a44bc3dc21f13fe.png

    f96c0ccb28a943938820599eb6ecd635.png

    279722aa03bb479f9cefaf8eb94f42db.png0214b2b4de9e46fba0112952f025458b.png

    f51b46c242144f9b9e41c0f6a93ad834.png

    5bd60621051848538540d07a740c74dd.png

    52964b29acfa4fc2ae57c193b72b7886.png

    19797cbaa35d4bc3aae63569ca7d7610.png

    e82caa6c2d0d41adb71b01ac5a382879.png

    b53a2eda18c04a34b558f7c5f9ddcb4c.png

    b9f126de5aa1441a96701a3921f9c707.png

     5fa5867b003d4735bc1dfa462839ab4d.png

     advertise-map

    df87e8438e5a4ed9899d4e399abba958.png

    c297e0a1450542a097b283ffe8adbea5.png

    实验:

    1. neighbor 10.1.23.3 advertise-map 1 exist-map 2
    2. R3
    3. Network Next Hop Metric LocPrf Weight Path
    4. *> 11.11.11.0/24 10.1.23.2 0 200 100 i
    5. *> 22.22.22.0/24 10.1.23.2 0 200 100 i
    6. 只关掉22路由接口
    7. R3上啥也没有
    8. 只关11路由接口
    9. R3
    10. Network Next Hop Metric LocPrf Weight Path
    11. *> 22.22.22.0/24 10.1.23.2 0 200 100 i
    12. ------------------------------------------------------------------------
    13. neighbor 10.1.23.3 advertise-map 1 non-exist-map 2
    14. R3
    15. Network Next Hop Metric LocPrf Weight Path
    16. *> 22.22.22.0/24 10.1.23.2 0 200 100 i
    17. 只关掉22路由接口
    18. Network Next Hop Metric LocPrf Weight Path
    19. *> 11.11.11.0/24 10.1.23.2 0 200 100 i
    20. 只关11路由接口
    21. Network Next Hop Metric LocPrf Weight Path
    22. *> 22.22.22.0/24 10.1.23.2 0 200 100 i

    小结

    exist-map匹配的路由

    存在,就传递(不管有没有没被exist-map匹配的路由)


    不存在,啥也不传

    non-exist-map匹配的路由

    存在,就只发自己匹配的路由


    不存在,就发前面advertise-map匹配的路由

    ORF(Outbound Route Filtering)

     

     

     

    路由拆分BGP Deaggregation

     

     

     实验结果

    1. //R2上看到
    2. Network Next Hop Metric LocPrf Weight Path
    3. *> 172.16.0.0 10.1.12.1 0 0 100 i
    4. *> 172.16.1.0/24 10.1.12.1 0 ? <<<<<<<<----------
    5. R2#sho ip bgp 172.16.1.0
    6. BGP routing table entry for 172.16.1.0/24, version 3
    7. Paths: (1 available, best #1, table Default-IP-Routing-Table)
    8. Flag: 0x820
    9. Advertised to update-groups:
    10. 1
    11. Local, (aggregated by 100 172.16.2.1), (injected path from 172.16.0.0/16) <<<<<<------
    12. 10.1.12.1 from 10.1.12.1 (172.16.2.1)
    13. Origin incomplete, localpref 100, valid, external, best
    14. //可以看到是注入进来的

    代码

    1. R1
    2. !
    3. interface Loopback0
    4. ip address 172.16.1.1 255.255.255.0
    5. !
    6. interface Loopback1
    7. ip address 172.16.2.1 255.255.255.0
    8. !
    9. interface Serial1/0
    10. ip address 10.1.12.1 255.255.255.0
    11. serial restart-delay 0
    12. !
    13. router bgp 100
    14. no synchronization
    15. bgp log-neighbor-changes
    16. network 172.16.1.0 mask 255.255.255.0
    17. network 172.16.2.0 mask 255.255.255.0
    18. aggregate-address 172.16.0.0 255.255.0.0 as-set summary-only
    19. neighbor 10.1.12.2 remote-as 200
    20. no auto-summary
    21. !
    22. R2
    23. interface Serial1/0
    24. ip address 10.1.12.2 255.255.255.0
    25. serial restart-delay 0
    26. !
    27. interface Serial1/1
    28. ip address 10.1.23.2 255.255.255.0
    29. serial restart-delay 0
    30. !
    31. router bgp 200
    32. no synchronization
    33. bgp log-neighbor-changes
    34. bgp inject-map 2 exist-map 1
    35. neighbor 10.1.12.1 remote-as 100
    36. neighbor 10.1.23.3 remote-as 300
    37. no auto-summary
    38. !
    39. ip prefix-list 1 seq 5 permit 172.16.0.0/16
    40. !
    41. ip prefix-list 2 seq 15 permit 10.1.12.1/32
    42. !
    43. ip prefix-list 3 seq 5 permit 172.16.1.0/24
    44. !
    45. route-map 1 permit 10
    46. match ip address prefix-list 1
    47. match ip route-source prefix-list 2
    48. !
    49. route-map 2 permit 10
    50. set ip address prefix-list 3
    51. !
    52. R3
    53. !
    54. interface Serial1/1
    55. ip address 10.1.23.3 255.255.255.0
    56. serial restart-delay 0
    57. !
    58. router bgp 300
    59. no synchronization
    60. bgp log-neighbor-changes
    61. neighbor 10.1.23.2 remote-as 200
    62. no auto-summary
    63. !

    中转AS中的IBGP问题


     

    路由反射器技术背景


     

    路由反射规则


     规则示例


    小结:

    AS内,client发出,给client和非client;非client发出,只给client,不给非client

    RR从EBGP邻居收到,发给所有领居 

    路由反射器环境下的防环

    Originator_ID、Cluster_list


     Originator_ID

    Originator_ID的值
     

    路由反射簇

    路由反射器的冗余


    拓扑图

     相关代码

    1. neighbor 10.1.34.3 route-reflector-client
    2. bgp cluster-id 33.33.33.33

    联邦内的BGP路由路径属性

    next-hop属性在成员AS间传递不变

    传统BGP路由属性MED传递规则 

    路由反射器与联邦选用方案


    拓扑图 

    1. R1
    2. router bgp 100
    3. network 1.1.1.0 mask 255.255.255.0
    4. network 2.2.2.0 mask 255.255.255.0
    5. neighbor 10.1.13.3 remote-as 300 //这里的AS是联邦AS
    6. R2
    7. router bgp 200
    8. neighbor 10.1.25.5 remote-as 300
    9. R3
    10. router ospf 1
    11. network 3.3.3.3 0.0.0.0 area 0
    12. network 10.1.34.3 0.0.0.0 area 0
    13. router bgp 64512 //AS号为成员AS
    14. bgp confederation identifier 300 //联邦AS标识
    15. neighbor 4.4.4.4 remote-as 64512
    16. neighbor 4.4.4.4 update-source Loopback0
    17. neighbor 4.4.4.4 next-hop-self //L0口建领居,要注意ttl(默认为1
    18. neighbor 10.1.13.1 remote-as 100
    19. R4
    20. router ospf 1
    21. network 4.4.4.4 0.0.0.0 area 0
    22. network 10.1.34.4 0.0.0.0 area 0
    23. network 10.1.45.4 0.0.0.0 area 0
    24. router bgp 64512
    25. bgp confederation identifier 300
    26. bgp confederation peers 64513 //AS号(在成员AS里的EBGP路由器,指另一个成员AS的EBGP路由器)
    27. neighbor 3.3.3.3 remote-as 64512 //联邦AS内,成员AS指成员AS
    28. neighbor 3.3.3.3 update-source Loopback0
    29. neighbor 5.5.5.5 remote-as 64513
    30. neighbor 5.5.5.5 ebgp-multihop 3
    31. neighbor 5.5.5.5 update-source Loopback0
    32. R5
    33. router ospf 1
    34. network 5.5.5.5 0.0.0.0 area 0
    35. network 10.1.45.5 0.0.0.0 area 0
    36. router bgp 64513
    37. bgp confederation identifier 300
    38. bgp confederation peers 64512
    39. neighbor 4.4.4.4 remote-as 64512
    40. neighbor 4.4.4.4 ebgp-multihop 3
    41. neighbor 4.4.4.4 update-source Loopback0
    42. neighbor 10.1.25.2 remote-as 200

    1.优选具有最大Weight值的路由


    2.优选具有最大Local_Pref值的路由


    3.优选起源于本地的路由


    4.优选AS_PATH最短的路由

    5.ORIGIN(i>e>?)


    6.优选MED最小的路由

    7.优选EBGP邻居的路由(相对于IBGP)


    8.优选到NEXT_HOP最近的路由

    9.BGP负载均衡

    10.优选最老的EBGP邻居的路由 


    11.优选RouterlD最小的BGP邻居的路由

    12.优选Cluster_List最短的路由

    13.选择邻居IP地址最小的路由

    实验环境

    EBGP非等价负载均衡

    1. R4的配置如下:
    2. router bgp 400
    3. bgp router-id 4.4.4.4
    4. bgp dmzlink-bw
    5. network 44.44.44.0 mask 255.255.255.0
    6. neighbor 10.1.24.2 remote-as 123
    7. neighbor 10.1.24.2 dmzlink-bw
    8. neighbor 10.1.34.3 remote-as 123
    9. neighbor 10.1.34.3 dmzlink-bw
    10. maximum-paths 2
    11. R4的BGP表项:
    12. R4#sho ip bgp 11.11.11.0
    13. BGP routing table entry for 11.11.11.0/24, version 2
    14. Paths: (2 available, best #1, table Default-IP-Routing-Table)
    15. Multipath: eBGP
    16. Advertised to update-groups:
    17. 1
    18. 123
    19. 10.1.24.2 from 10.1.24.2 (2.2.2.2)
    20. Origin IGP, localpref 100, valid, external, multipath, best
    21. DMZ-Link Bw 1250 kbytes <<<<<<<<<
    22. 123
    23. 10.1.34.3 from 10.1.34.3 (3.3.3.3)
    24. Origin IGP, localpref 100, valid, external, multipath
    25. DMZ-Link Bw 193 kbytes <<<<<<<<<
    26. R4的路由表:
    27. R4#sho ip ro 11.11.11.0
    28. Routing entry for 11.11.11.0/24
    29. Known via "bgp 400", distance 20, metric 0
    30. Tag 123, type external
    31. Last update from 10.1.34.3 00:13:54 ago
    32. Routing Descriptor Blocks:
    33. 10.1.34.3, from 10.1.34.3, 00:13:54 ago
    34. Route metric is 0, traffic share count is 37 <<<<<<<<<
    35. AS Hops 1
    36. Route tag 123
    37. * 10.1.24.2, from 10.1.24.2, 00:13:54 ago
    38. Route metric is 0, traffic share count is 240 <<<<<<<<<
    39. AS Hops 1
    40. Route tag 123

    IBGP非等价负载均衡

    1. R1的配置如下:
    2. router bgp 123
    3. bgp router-id 1.1.1.1
    4. bgp dmzlink-bw <<<<<<<<<<<开启(使用DMZ链路带宽作为BGP多路径的权重)
    5. network 11.11.11.0 mask 255.255.255.0
    6. neighbor 2.2.2.2 remote-as 123
    7. neighbor 2.2.2.2 update-source Loopback0
    8. neighbor 3.3.3.3 remote-as 123
    9. neighbor 3.3.3.3 update-source Loopback0
    10. maximum-paths ibgp 2
    11. R2的配置如下:
    12. router bgp 123
    13. bgp router-id 2.2.2.2
    14. bgp dmzlink-bw <<<<<<<<<<<开启(使用DMZ链路带宽作为BGP多路径的权重)
    15. neighbor 1.1.1.1 remote-as 123
    16. neighbor 1.1.1.1 update-source Loopback0
    17. neighbor 1.1.1.1 next-hop-self
    18. neighbor 1.1.1.1 send-community extended <<<<<<<<<<<发送community属性的extended
    19. neighbor 10.1.24.4 remote-as 400
    20. neighbor 10.1.24.4 dmzlink-bw <<<<<<<<<<<只能对EBGP领居使用
    21. R3的配置如下:
    22. router bgp 123
    23. bgp router-id 3.3.3.3
    24. bgp dmzlink-bw <<<<<<<<<<<开启(使用DMZ链路带宽作为BGP多路径的权重)
    25. neighbor 1.1.1.1 remote-as 123
    26. neighbor 1.1.1.1 update-source Loopback0
    27. neighbor 1.1.1.1 next-hop-self
    28. neighbor 1.1.1.1 send-community extended <<<<<<<<<<<发送community属性的extended
    29. neighbor 10.1.34.4 remote-as 400
    30. neighbor 10.1.34.4 dmzlink-bw <<<<<<<<<<<只能对EBGP领居使用
    31. R1的BGP表项:
    32. R1#sho ip bgp 44.44.44.0
    33. BGP routing table entry for 44.44.44.0/24, version 6
    34. Paths: (2 available, best #2, table Default-IP-Routing-Table)
    35. Multipath: iBGP
    36. Not advertised to any peer
    37. 400
    38. 3.3.3.3 (metric 11) from 3.3.3.3 (3.3.3.3)
    39. Origin IGP, metric 0, localpref 100, valid, internal, multipath
    40. DMZ-Link Bw 193 kbytes <<<<<<<<<<<
    41. 400
    42. 2.2.2.2 (metric 11) from 2.2.2.2 (2.2.2.2)
    43. Origin IGP, metric 0, localpref 100, valid, internal, multipath, best
    44. DMZ-Link Bw 1250 kbytes <<<<<<<<<<<
    45. R1的路由表:
    46. R1#sho ip ro 44.44.44.0
    47. Routing entry for 44.44.44.0/24
    48. Known via "bgp 123", distance 200, metric 0
    49. Tag 400, type internal
    50. Last update from 2.2.2.2 00:13:27 ago
    51. Routing Descriptor Blocks:
    52. 3.3.3.3, from 3.3.3.3, 00:13:27 ago
    53. Route metric is 0, traffic share count is 37 <<<<<<<<<<<
    54. AS Hops 1
    55. Route tag 400
    56. * 2.2.2.2, from 2.2.2.2, 00:13:27 ago
    57. Route metric is 0, traffic share count is 240 <<<<<<<<<<<
    58. AS Hops 1
    59. Route tag 400

    注:验证的时候,ip load-sharing per-packet这条命令要打上(接口上打)

    BGP Link Bandwidth 

    BGP Link Bandwidth的预备条件


    BGP Link Bandwidth特性的限制


    BGP Link Bandwidth Extended Community

    Cost Community概述

    Cost Community的限制


    Cost Community如何影响BGP最佳路径选择


    Cost Community的顺序


    实验:cost community基础

    1. R1
    2. router bgp 123
    3. no synchronization
    4. bgp log-neighbor-changes
    5. network 1.1.1.0 mask 255.255.255.0
    6. neighbor 10.1.12.2 remote-as 123
    7. no auto-summary
    8. R2
    9. router bgp 123
    10. no synchronization
    11. bgp log-neighbor-changes
    12. neighbor 10.1.12.1 remote-as 123
    13. neighbor 10.1.23.3 remote-as 123
    14. no auto-summary
    15. R3
    16. router bgp 123
    17. no synchronization
    18. bgp log-neighbor-changes
    19. network 1.1.1.0 mask 255.255.255.0
    20. neighbor 10.1.23.2 remote-as 123
    21. no auto-summary
    1. R2BGP表
    2.    Network          Next Hop            Metric LocPrf Weight Path
    3. * i1.1.1.0/24       10.1.23.3                0    100      0 i
    4. *>i                 10.1.12.1                0    100      0 i
    5. //现在用cost community实现优选从10.1.23.3来的
    6. router bgp 123
    7. neighbor 10.1.12.1 route-map 1 in
    8. neighbor 10.1.23.3 route-map 2 in
    9. route-map 1 permit 10
    10. set extcommunity cost igp 1 20
    11. route-map 2 permit 10
    12. set extcommunity cost igp 1 10
    13. --------------------------------------------------------
    14. Network Next Hop Metric LocPrf Weight Path
    15. *>i1.1.1.0/24 10.1.23.3 0 100 0 i
    16. * i 10.1.12.1 0 100 0 i
    17. R2#sho ip bgp 1.1.1.0
    18. BGP routing table entry for 1.1.1.0/24, version 4
    19. Paths: (2 available, best #1, table Default-IP-Routing-Table)
    20. Not advertised to any peer
    21. Local
    22. 10.1.23.3 from 10.1.23.3 (1.1.1.1)
    23. Origin IGP, metric 0, localpref 100, valid, internal, best
    24. Extended Community: Cost:igp:1:10
    25. Local
    26. 10.1.12.1 from 10.1.12.1 (1.1.1.1)
    27. Origin IGP, metric 0, localpref 100, valid, internal
    28. Extended Community: Cost:igp:1:20

    实验∶测试默认Cost Community

    1. R2
    2. router bgp 123
    3. neighbor 10.1.12.1 route-map 1 in
    4. route-map 1 permit 10
    5. set extcommunity cost igp 1 2147483647
    6. --------------------------------------------------------------------
    7. Network Next Hop Metric LocPrf Weight Path
    8. *>i1.1.1.0/24 10.1.12.1 0 100 0 i
    9. * i 10.1.23.3 0 100 0 i
    10. --------------------------------------------------------------------
    11. 1.0.0.0/24 is subnetted, 1 subnets
    12. B 1.1.1.0 [200/0] via 10.1.12.1, 00:01:52
    13. //这里是routerid最小的生效
    14. --------------------------------------------------------------------
    15. --------------------------------------------------------------------
    16. R2(config-router)#maximum-paths ibgp 2
    17. 1.0.0.0/24 is subnetted, 1 subnets
    18. B 1.1.1.0 [200/0] via 10.1.23.3, 00:00:13
    19. [200/0] via 10.1.12.1, 00:01:26
    20. //可以看到负载均衡,此时说明poi没生效

    实验:Cost Value和Cost ID的PK

    1. R2
    2. router bgp 123
    3. neighbor 10.1.12.1 route-map 1 in
    4. neighbor 10.1.23.3 route-map 2 in
    5. route-map 1 permit 10
    6. set extcommunity cost igp 1 2147483648
    7. route-map 2 permit 10
    8. set extcommunity cost igp 2 10
    9. Network Next Hop Metric LocPrf Weight Path
    10. * i1.1.1.0/24 10.1.12.1 0 100 0 i
    11. *>i 10.1.23.3 0 100 0 i

    实验∶测试pre-bestpath的POI

    1. R1
    2. router bgp 123
    3. neighbor 10.1.12.2 send-community extended
    4. neighbor 10.1.12.2 route-map 1 out
    5. route-map 1 permit 10
    6. set extcommunity cost pre-bestpath 1 20
    7. R3:
    8. router bgp 123
    9. neighbor 10.1.23.2 send-community extended
    10. neighbor 10.1.23.2 route-map 1 out
    11. route-map 1 permit 10
    12. set extcommunity cost pre-bestpath 1 10
    13. R2:
    14. Network Next Hop Metric LocPrf Weight Path
    15. *>i1.1.1.0/24 10.1.23.3 0 100 0 i
    16. * i 10.1.12.1 0 100 0 i
    17. R2#sho ip bg 1.1.1.0
    18. BGP routing table entry for 1.1.1.0/24, version 2
    19. Paths: (2 available, best #1, table Default-IP-Routing-Table)
    20. Flag: 0x820
    21. Not advertised to any peer
    22. Local
    23. 10.1.23.3 from 10.1.23.3 (1.1.1.1)
    24. Origin IGP, metric 0, localpref 100, valid, internal, best
    25. Extended Community: Cost:pre-bestpath:1:10
    26. Local
    27. 10.1.12.1 from 10.1.12.1 (1.1.1.1)
    28. Origin IGP, metric 0, localpref 100, valid, internal
    29. Extended Community: Cost:pre-bestpath:1:20

    实验:cost community在联邦eBGP邻居之间的传递

    1. R1
    2. router bgp 64551
    3. bgp confederation identifier 123
    4. bgp confederation peers 64552
    5. network 1.1.1.0 mask 255.255.255.0
    6. neighbor 10.1.12.2 remote-as 64552
    7. neighbor 10.1.12.2 send-community extended
    8. neighbor 10.1.12.2 route-map 1 out
    9. route-map 1 permit 10
    10. set extcommunity cost pre-bestpath 1 20
    11. R2
    12. router bgp 64552
    13. no synchronization
    14. bgp log-neighbor-changes
    15. bgp confederation identifier 123
    16. bgp confederation peers 64551 64553
    17. neighbor 10.1.12.1 remote-as 64551
    18. neighbor 10.1.23.3 remote-as 64553
    19. R3
    20. router bgp 64553
    21. bgp confederation identifier 123
    22. bgp confederation peers 64552
    23. network 1.1.1.0 mask 255.255.255.0
    24. neighbor 10.1.23.2 remote-as 64552
    25. neighbor 10.1.23.2 send-community extended
    26. neighbor 10.1.23.2 route-map 1 out
    27. route-map 1 permit 10
    28. set extcommunity cost pre-bestpath 1 10
    1. R2
    2. Network Next Hop Metric LocPrf Weight Path
    3. * 1.1.1.0/24 10.1.12.1 0 100 0 (64551) i
    4. *> 10.1.23.3 0 100 0 (64553) i
    5. R2#sho ip bg 1.1.1.0
    6. BGP routing table entry for 1.1.1.0/24, version 4
    7. Paths: (2 available, best #2, table Default-IP-Routing-Table)
    8. Flag: 0x820
    9. Advertised to update-groups:
    10. 1
    11. (64551)
    12. 10.1.12.1 from 10.1.12.1 (1.1.1.1)
    13. Origin IGP, metric 0, localpref 100, valid, confed-external
    14. Extended Community: Cost:pre-bestpath:1:20
    15. (64553)
    16. 10.1.23.3 from 10.1.23.3 (1.1.1.1)
    17. Origin IGP, metric 0, localpref 100, valid, confed-external, best
    18. Extended Community: Cost:pre-bestpath:1:10
    19. //这里取消pre-bestpath用负载均衡,负载均衡没有效果。

    私有AS

    如何移除AS_PATH中的私有AS

    neighbor remove-private-as命令注解

    DUAL AS的实现

    DUAL AS命令详解

    Dual AS配置示例1


    Dual AS配置示例2

    Dual AS配置示例3

    Dual AS配置示例4

     BGP PA配置步骤


     

  • 相关阅读:
    Python:实现随机正态分布快速排序算法(附完整源码)
    LeetCode刷题day24||回溯算法理论基础&&77. 组合--回溯
    STC8H开发(十五): GPIO驱动Ci24R1无线模块
    前端环境 本机可切换node多版本 问题源头是node使用的高版本
    城市易涝点怎么安装万宾科技内涝积水监测仪?
    视频加密的误解
    铁道交通运输运营3D模拟仿真实操提供一个沉浸、高效且环保的情境
    MySQL高可用和主从同步
    浅析三维模型重建的地面控制点精度常见的几个问题及解决方法
    openwrt 时区设置无效问题
  • 原文地址:https://blog.csdn.net/m0_74204829/article/details/133521756