CCIE学习笔记 3---BGP 团体属性 community

    可选传递

   - BGP communities是一种给路由条目打上标记,用于确保路由过滤和选择的连续性

   - BGP 路由器可以在重分布、发送、接收路由更新的时候给路由条目打上community值(route-map)

   - 根据 community值,BGP 路由器可以过滤进出路由更新或者优选某些路由

   - 缺省情况下,在update路由的时候community被剥离


    ◆32 bit community balue is split into two parts:

      [AS-number]:[low-order-16-bits]

        AS号       描述本地设备


    ◆配置

        router(config)#

            match condition

            set community value---100:1 // AS100

        router bgp 100

            nei x.x.x.x route-map map in/out

            neit x.x.x.x send-community //community默认不传递,此命令用于传递

        调用community,操作

        router(config)#

            ip community-list 1-99 permit | deny value 


      ◆community-list 标准(1-99):匹配别人打的值

                       扩展(100-199):用正则表达式匹配。

                        

        route-map name permit|deny

            match community clist-number

            set attributes


实验:

CCIE学习笔记 3---BGP 团体属性 community_第1张图片

AS200配置联邦,R2 R4在AS2000;R5在AS300

R2 R4 R5igp运行ospf

R1:

    int f1/0

        ip add 12.1.1.1 255.255.255.0

        no shu

    int lo0

        ip add 1.1.1.1 255.255.255.255

    router bgp 100

        nei 12.1.1.1 remot 200

R2:

    int f1/0

        ip add 12.1.1.2 255.255.255.0

        no shu

        ip os 1 a 0

    int lo0

        ip add 2.1.1.1 255.255.255.255

        ip os 1 a 0

    int f1/1

        ip add 24.1.1.2 255.255.255.0

        no shu

        ip os 1 a 0

        int lo0

            ip add 2.1.1.1 255.255.255.255

            ip os 1 a 0

    router bgp 2000

        bgp confen id 200

        nei 4.1.1.1 remot 2000

        nei 4.1.1.1 up lo0

        nei 4.1.1.1 next-hop-self

        nei 12.1.1.1 remot 100

R4:启用IGP OSPF

    router bgp 2000

        bgp confen id 200

        bgp confen peers 3000

        nei 2.1.1.1 remot 2000

        nei 2.1.1.1 up lo0

        nei 5.1.1.1 remot 3000

        nei 5.1.1.1 up lo0

        nei 5.1.1.1 ebgp-multihop

R5:启用IGP ospf

    router bpg 3000

        bgp confen id 200

        bgp confen peer 2000

        nei 4.1.1.1 remot 2000

        nei 4.1.1.1 up lo0

        nei 4.1.1.1 next-hop-s

        nei 4.1.1.1 ebgp-multi

        nei 56.1.1.6 remot 300

R6:router bgp 300

        nei 56.1.1.5 remot 200

####################################################

配置community

R1:router bgp 100

        net 1.1.1.1

    ip prefix-list 1.1 per 1.1.1.1/32

    route-map com per 10

        match ip add prefix-list 1.1

        set commu 100:1

    route-map com per 1000

    router bgp 100

        nei 12.1.1.2 send-community  //community默认不传递,需手动配置传递

R2:sho ip bgp 1.1.1.1 //commuity 值不是100:1格式

    conf t 

        ip bgp-community new-format // 配置以100:1格式显示

    sho ip bgp 1.1.1.1


◆R2上就可以通过配置community-list 调用100:1,再set不同值

    ip community-list 1 per 100:1

    route-map com per 10

        match  community 1

        set commuity 200:2

    route-map com per 1000

    router bgp 2000

        nei 12.1.1.1 route-map com out

    sho ip bgp 1.1.1.1 //此时community=200:2,之前的100:1被覆盖

    若要不覆盖100:1,需要在route-map加关键字 additive

    route-map com per 10

        set community 200:2 additive

    sho ip b 1.1.1.1  //可以同时看到100:1 200:2


◆ 在匹配community值做策略时,在一条路由有多个community值,只要匹配一个就可以

        R4:

            ip community-list 1 per 100:1

            route-map test per 10

                match community 1

                set wei 2000

◆ 可以通过关键字 exact-match 设置,有多个community时,全匹配才行(精确匹配)

        route-map test per 10

            match community 1 exact-match

◆ ip community-list 1 per 100:1 200:2

    sho ip b 

◆ commnity-list 可以匹配多个值

    ip commnuity-list 1 per 100:1 200:2

    ip commnuity-list 1 per 200:2

    sho ip community-list   

    

###########################################################################################


利用community控制路由传递的范围

    属性值:

        1,no-advertise:do not advertise routes to any peer不传给任何邻居

        2, local-as:do not advertise routes to any EBGP peers不传给任何EBGP邻居,包括联邦

        3, no-export: do not advertise routes to real EBGP peers不传给EBGP邻居,联邦可以

        4, internet: advertise this route to the internet community 传给所有











你可能感兴趣的:(BGP)