BGP community属性3

发布时间:2019-08-26 07:17:46编辑:auto阅读(1669)

      配置团体属性,让2.2.2.0网络只被R2学习到
    这里最合适的community属性应该是:no_advertise 因为它不会向任何EBGP IBGP邻居公布路由。
    r1(config)#access-list 1 permit 2.2.2.0 0.0.0.255  /ACL匹配该路由
     
    r1(config)#route-map WY permit 10
    r1(config-route-map)#match ip add 1
    r1(config-route-map)#set community no-advertise  /设定团体属性
    r1(config)#route-map WY permit 20 /ACL一样 route-map最后也隐藏了一句deny any ,所以在这里要允许所有,要不然其它两条路由会因为匹配不上而无法从R1传递出去。
    r1(config)#router bgp 100
    r1(config-router)#neighbor 12.0.0.2 route-map WY out  /在进程下出方向调用route-map
    r1(config-router)#neighbor 12.0.0.2 send-community /R2传递该社团属性
     
    先在R2上进行查看;
    r2#sh ip bgp
       Network          Next Hop            Metric LocPrf Weight Path
    *> 2.2.2.0/24       12.0.0.1                 0             0 100 i
    *> 22.22.22.0/24    12.0.0.1                 0             0 100 i
    *> 222.222.222.0    12.0.0.1                 0             0 100 i
    R2可以学习到该路由
    R3上查看
    r3#sh ip bgp
       Network          Next Hop            Metric LocPrf Weight Path
    *>i22.22.22.0/24    23.0.0.2                 0    100      0 100 i
    *>i222.222.222.0    23.0.0.2                 0    100      0 100 i
    可以看到R3已经收不到2.2.2.0这个网络了,往后的路由器也无法收到了。所以社团属性
    No_advertise 满足了只让R2学到该路由的需求。
     
      配置团体属性,让22.22.22.0网络只被R2,R3学习到
    因为R2,R3处于联邦内同一个子AS,意思是该路由不能传递出这个子AS,所以可以用community属性:LOCAL_AS
     
    r1(config)#access-list 2 permit 22.22.22.0 0.0.0.255
     
    r1(config)#route-map WY permit 10
    r1(config-route-map)#match ip add 2
    r1(config-route-map)#set community local-AS
    r1(config)#route-map WY permit 20
     
    现在进行查看
    r2#sh ip bgp
       Network          Next Hop            Metric LocPrf Weight Path
    *> 2.2.2.0/24       12.0.0.1                 0             0 100 i
    *> 22.22.22.0/24    12.0.0.1                 0             0 100 i
    *> 222.222.222.0    12.0.0.1                 0             0 100 i
    R2可以学习到。
    r3#sh ip bgp
       Network          Next Hop            Metric LocPrf Weight Path
    *>i2.2.2.0/24       23.0.0.2                 0    100      0 100 i
    *>i22.22.22.0/24    23.0.0.2                 0    100      0 100 i
    *>i222.222.222.0    23.0.0.2                 0    100      0 100 i
    R3也可以学到
    r4#sh ip bgp
       Network          Next Hop            Metric LocPrf Weight Path
    *> 2.2.2.0/24       34.0.0.3                 0    100      0 (64512) 100 i
    *> 22.22.22.0/24    34.0.0.3                 0    100      0 (64512) 100 i
    *> 222.222.222.0    34.0.0.3                 0    100      0 (64512) 100 i
    为什么R4依然可以学习到,难道属性没起作用吗?显然属性没有起作用,这是因为R2R3传递该路由时没有让R3继承这个属性,所以R4依然可以学习到,现在必须在R2上配置让R3继承这个属性,这样R3R4传递路由时团体属性才能生效。
    r2(config)#router bgp 64512
    r2(config-router)#neighbor 23.0.0.3 send-community
    R2上配置让R3继承该属性
    r4#sh ip bgp
       Network          Next Hop            Metric LocPrf Weight Path
    *> 2.2.2.0/24       34.0.0.3                 0    100      0 (64512) 100 i
    *> 222.222.222.0    34.0.0.3                 0    100      0 (64512) 100 i
    现在R4就收不到这条路由了,R5当然也收不到,LOCAL_AS团体属性满足了这个需求。
     
      配置团体属性,让222.222.222.0网络只被R2,R3,R4学习到
    这个需求意思是让这条路由不传到联邦外(大AS之外),所以要用NO_EXPORT属性
     
    r1(config)#access-list 3 permit 222.222.222.0 0.0.0.255
     
    r1(config)#route-map WY permit 10
    r1(config-route-map)#match ip add 3
    r1(config-route-map)#set community no-export
    r1(config)#route-map WY permit 20
     
    为了让R4能继承到该属性,必须在R1,R2,R3都配置send-community以便让该属性进行传递。在配置了传递属性之后,现在进行查看
    r4#sh ip bgp
       Network          Next Hop            Metric LocPrf Weight Path
    *> 2.2.2.0/24       34.0.0.3                 0    100      0 (64512) 100 i
    *> 22.22.22.0/24    34.0.0.3                 0    100      0 (64512) 100 i
    *> 222.222.222.0    34.0.0.3                 0    100      0 (64512) 100 i
    R4可以收到
     
    r5#sh ip bgp
       Network          Next Hop            Metric LocPrf Weight Path
    *> 2.2.2.0/24       45.0.0.4                               0 234 100 i
    *> 22.22.22.0/24    45.0.0.4                               0 234 100 i
    R5已经学习不到222.222.222.0了。需求满足。
     
    但上面的做法有一个明显的缺点就是要在R1,R2,R3上配置传递该属性,比较麻烦。
     
    现在用另一种比较简单的方法。
    R4上直接进行配置。
    r4(config)#access-list 1 permit 222.222.222.0 0.0.0.255
     
    r4(config)#route-map WY permit 10
    r4(config-route-map)#match ip add 1
    r4(config-route-map)#set community no-export
    r4(config)#route-map WY permit 20
     
    r4(config)#router bgp 64513
    r4(config-router)#neighbor 34.0.0.3 route-map WY in
    指定R3R4传递路由时应用该route-map,所以是in方向的。

关键字

上一篇: Python List的赋值方法

下一篇: python_day12_html