01_2_BGP Community

BGP Community只是BGP路由可以携带的一种属性,是BGP中的一个可选可传递属性(Optional Transitive),所以可以选择为路由配置Community,也可以不配,如果配置,Community需要明确要求BGP路由器保留和传递该属性,否则邻居收不到路由的Community属性。

都知道Peer Group是用来简化BGP邻居配置的,而BGP Community则可以简化BGP路由在某方面的配置。对于Community 属性,它只是BGP路由中携带的一个标签而已,可以分成不同的类别,分为众所周知的Community和私有Community,也可以分为标准Community和扩展Community(Extended  Community),它们的区别如下:

众所周知的Community

众所周知的Community被所有BGP路由器认识和理解,并且必须对携带众所周知的Community的路由做相应的操作,BGP拥有4个预先定义的众所周知的Community,分别为

no-export—不将路由发给任何eBGP邻居,也就是只能将该路由在本AS内部传递。

no-advertise—不将路由发给任何BGP邻居。

internet—可以将路由发给任何BGP邻居。

local-as—同no-export,即不将路由发到AS外。

注:众所周知的Community为固定格式,不可自定义,只能使用预定义的格式。

私有Community

私有Community可以理解为BGP路由的自定义标签,所以可以通过为BGP路由配置私有Community来配置任何自定义的标签,该标签可以在任何时候被利用。例如一台BGP路由器为某个Community标签配置策略后,那么所有携带该Community标签的路由都将获得相应策略。

在正常情况下,BGP路由器要对某些一定范围内的路由配置策略,必须使用prefix list或 access list将所有符合条件的路由匹配出来,然后调用之后再配置相应策略,如果是网络中所有路由器都要对这些路由设置策略,那么就必须在网络中每台设备上单独使用大量重复的配置将路由匹配出来,再做相应策略,工作烦琐并且容易出错,而在使用私有Community之后,就可以将特定的路由设置私有Community,并将其传递给所有邻居,最终所有路由器都对拥有该私有Community的路由配置策略,并且对大量路由设置私有Community只需要在一台路由器上完成后,发给所有邻居即可,可见私有Community可以减少网络中路由器对相同路由的匹配工作,这就是标签的效果。

私有Community的类型为数字,长度为32bit,但被分为两种格式:

单个32bit,如123,666

或者2字节长度的AS号码加两字节普通数字,称为AS:NN格式,范围为1:0 至 65534:65535。

默认路由器支持单个32bit格式,若要支持AS:NN格式,必须开启BGP-Community New-Format功能。

标准Community

标准Community就是普通路由可以设置的Community,包括上面提到的众所周知Community和私有Community。

扩展Community(Extended  Community)

扩展Community为MPLS中的VRF路由传递所定义的,在MPLS中有所解释。

注:BGP Community必须明确要求传递,否则邻居收不到相应Community。

要匹配携带Community的路由,方法为使用Community List,并且有数字list和命名list两种,每两条语句之间相隔10,以10递增,一组数字list最多支持100条语句,而命名list则不受此限制,但并不是所有IOS都支持命名list。在使用Community List匹配指定路由条目后,则可使用route-map来调用Community List,从而为指定路由设置相应参数和策略,最终应用该route-map。

注:Community可以传递的距离不受限制,邻居可以再传给其它邻居,Community可以被多个路由器多次使用。

配置BGP Community


 
 

说明:

上图中所有路由器都配有Loopback地址,地址分别为:

R1  Loopback 0  1.1.1.1/32      Loopback 11  11.1.1.1/24

R2  Loopback 0  2.2.2.2/32      Loopback 22  22.2.2.2/24

R3  Loopback 0  3.3.3.3/32      Loopback 33  33.3.3.3/24

R4  Loopback 0  4.4.4.4/32      Loopback 44  44.4.4.4/24

R5  Loopback 0  5.5.5.5/32      Loopback 55  55.5.5.5/24

R6  Loopback 0  6.6.6.6/32      Loopback 66  66.6.6.6/24

 
 

所有路由器之间运行OSPF,并将Loopback 0的地址发布到OSPF中,保证全网Loopback 0之间是可以通信的。

 
 

1.IGP保证全网Loopback 0互通

说明:此步略,请参见之前配置。

 
 

2.基础BGP配置

说明:此步略,请参见之前配置。

 
 

3.测试no-export

说明:在R5上将路由55.5.5.0/24设置no-export后传递给R4,由于带no-export的路由不能传递给任何eBGP邻居,所以R6将无法收到R4转发的55.5.5.0/24。

(1)查看R4的BGP路由

r4#sh ip bgp 

BGP table version is 11, local router ID is 4.4.4.4

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*  11.1.1.0/24      3.3.3.3                                0 1 i

*>                  2.2.2.2                                0 1 i

*> 22.2.2.0/24      2.2.2.2                  0             0 1 i

*> 33.3.3.0/24      3.3.3.3                  0             0 1 i

*> 44.4.4.0/24      0.0.0.0                  0         32768 i

*> 55.5.5.0/24      5.5.5.5                  0             0 5 i

*> 66.6.6.0/24      6.6.6.6                  0             0 6 i

*  100.1.1.0/24     3.3.3.3                                0 1 i

*>                  2.2.2.2                                0 1 i

*> 100.1.2.0/24     6.6.6.6                  0             0 6 i

*> 100.1.3.0/24     6.6.6.6                  0             0 6 i

r4#

说明:R4拥有全部的路由,其中包括R5发来的所有路由。

(2)查看R6的BGP路由

r6#sh ip bgp 

BGP table version is 156, local router ID is 6.6.6.6

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      4.4.4.4                                0 4 1 i

*> 22.2.2.0/24      4.4.4.4                                0 4 1 i

*> 33.3.3.0/24      4.4.4.4                                0 4 1 i

*> 44.4.4.0/24      4.4.4.4                  0             0 4 i

*> 55.5.5.0/24      4.4.4.4                                0 4 5 i

*> 66.6.6.0/24      0.0.0.0                  0         32768 i

*> 100.1.1.0/24     4.4.4.4                                0 4 1 i

*> 100.1.2.0/24     0.0.0.0                  0         32768 i

*> 100.1.3.0/24     0.0.0.0                  0         32768 i

r6#

说明:R4已将自己的全部路由发给R6。

 
 

(3)R5将自己的路由55.5.5.0/24设置no-export后发给R4

r5(config)#access-list 55 permit 55.5.5.0

 
 

r5(config)#route-map noe permit 10

r5(config-route-map)#mat ip address 55

r5(config-route-map)#set community no-export 

r5(config-route-map)#exit

r5(config)#route-map noe permit 20 

r5(config-route-map)#exit

 
 

r5(config)#router bgp 5

r5(config-router)#neighbor 4.4.4.4 route-map noe out

r5(config-router)#neighbor 4.4.4.4 send-community

说明:R5已将自己的路由55.5.5.0/24设置no-export,并且指示将community传给R4。

 
 

(4)查看R4收到的带community的路由

r4#sh ip bgp community        

BGP table version is 12, local router ID is 4.4.4.4

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 55.5.5.0/24      5.5.5.5                  0             0 5 i

r4#

说明:R4已经收到R5发来的带community的路由。

 
 

(5)查看R4收到的带community的路由

r4#sh ip bgp 55.5.5.0         

BGP routing table entry for 55.5.5.0/24, version 12

Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)

Flag: 0x880

  Not advertised to any peer

  5

    5.5.5.5 (metric 65) from 5.5.5.5 (5.5.5.5)

      Origin IGP, metric 0, localpref 100, valid, external, best

      Community: no-export

r4#

说明:R4收到的路由55.5.5.0/24的community为no-export,也就是不将该路由传给任何eBGP邻居。

 
 

(6)查看R4的eBGP邻居R6的路由情况

r6#sh ip bgp 

BGP table version is 157, local router ID is 6.6.6.6

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      4.4.4.4                                0 4 1 i

*> 22.2.2.0/24      4.4.4.4                                0 4 1 i

*> 33.3.3.0/24      4.4.4.4                                0 4 1 i

*> 44.4.4.0/24      4.4.4.4                  0             0 4 i

*> 66.6.6.0/24      0.0.0.0                  0         32768 i

*> 100.1.1.0/24     4.4.4.4                                0 4 1 i

*> 100.1.2.0/24     0.0.0.0                  0         32768 i

*> 100.1.3.0/24     0.0.0.0                  0         32768 i

r6#

说明:因为R4的路由55.5.5.0/24的community为no-export,也就是不将该路由传给任何eBGP邻居,所以R6没有收到55.5.5.0/24。

 
 

4.测试no-advertise

说明:在R4上将路由44.4.4.0/24设置no-advertise后传递给R2,由于带no-advertise的路由不能传递给任何BGP邻居,所以R1将无法收到R2转发的44.4.4.0/24。

 
 

(1)查看R2的BGP路由

r2#sh ip bgp 

BGP table version is 124, local router ID is 2.2.2.2

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*>i11.1.1.0/24      1.1.1.1                  0    100      0 i

*> 22.2.2.0/24      0.0.0.0                  0         32768 i

*> 44.4.4.0/24      4.4.4.4                  0             0 4 i

*> 66.6.6.0/24      4.4.4.4                                0 4 6 i

*>i100.1.1.0/24     1.1.1.1                  0    100      0 i

*> 100.1.2.0/24     4.4.4.4                                0 4 6 i

*> 100.1.3.0/24     4.4.4.4                                0 4 6 i

r2#

说明:R2拥有全部的路由,其中包括R4发来的所有路由。

 
 

(2)查看R1的BGP路由

r1#sh ip bgp 

BGP table version is 186, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      0.0.0.0                  0         32768 i

*>i22.2.2.0/24      2.2.2.2                  0    100      0 i

*>i33.3.3.0/24      3.3.3.3                  0    100      0 i

*>i44.4.4.0/24      2.2.2.2                  0    100      0 4 i

* i                 3.3.3.3                  0    100      0 4 i

*>i66.6.6.0/24      2.2.2.2                  0    100      0 4 6 i

* i                 3.3.3.3                  0    100      0 4 6 i

*> 100.1.1.0/24     0.0.0.0                  0         32768 i

* i100.1.2.0/24     3.3.3.3                  0    100      0 4 6 i

*>i                 2.2.2.2                  0    100      0 4 6 i

*>i100.1.3.0/24     2.2.2.2                  0    100      0 4 6 i

* i                 3.3.3.3                  0    100      0 4 6 i

r1#

说明:R2已将自己的全部路由发给R1。

 
 

(3)R4将自己的路由44.4.4.0/24设置no-advertise后发给R2

r4(config)#access-list 44 permit 44.4.4.0

 
 

r4(config)#route-map noa permit 10

r4(config-route-map)#match ip address 44

r4(config-route-map)#set community no-advertise 

r4(config-route-map)#exit

r4(config)#route-map noa permit 20    

r4(config-route-map)#exit

 
 

r4(config)#router bgp 4

r4(config-router)#neighbor 2.2.2.2 route-map noa out

r4(config-router)#neighbor 2.2.2.2 send-community 

说明:R4已将自己的路由44.4.4.0/24设置no-advertise,并且指示将community传给R2。

 
 

 
 

(4)查看R2收到的带community的路由

r2#sh ip bgp community

BGP table version is 125, local router ID is 2.2.2.2

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 44.4.4.0/24      4.4.4.4                  0             0 4 i

r2#

说明:R2已经收到R4发来的带community的路由。

 
 

 
 

(5)查看R2收到的带community的路由

r2#sh ip bgp 44.4.4.0 

BGP routing table entry for 44.4.4.0/24, version 125

Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to any peer)

Flag: 0x880

  Not advertised to any peer

  4

    4.4.4.4 (metric 2) from 4.4.4.4 (4.4.4.4)

      Origin IGP, metric 0, localpref 100, valid, external, best

      Community: no-advertise

r2#

说明:R2收到的路由44.4.4.0/24的community为no-advertise,也就是不将该路由传给任何BGP邻居。

 
 

(6)查看R2的邻居R1的路由情况

r1#sh ip bgp 

BGP table version is 187, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      0.0.0.0                  0         32768 i

*>i22.2.2.0/24      2.2.2.2                  0    100      0 i

*>i33.3.3.0/24      3.3.3.3                  0    100      0 i

*>i44.4.4.0/24      3.3.3.3                  0    100      0 4 i

*>i66.6.6.0/24      2.2.2.2                  0    100      0 4 6 i

* i                 3.3.3.3                  0    100      0 4 6 i

*> 100.1.1.0/24     0.0.0.0                  0         32768 i

* i100.1.2.0/24     3.3.3.3                  0    100      0 4 6 i

*>i                 2.2.2.2                  0    100      0 4 6 i

*>i100.1.3.0/24     2.2.2.2                  0    100      0 4 6 i

* i                 3.3.3.3                  0    100      0 4 6 i

r1#

说明:因为R2的路由44.4.4.0/24的community为no-advertise,也就是不将该路由传给任何邻居,所以R1没有收到R2发来的44.4.4.0/24。

 
 

 
 

 
 

5.测试普通私有Community

说明:私有Community的功能为路由标签,通过利用Community标签来匹配路由。

(1)R4将100.0.0.0/8的全部路由的Community设置为 123,并发给R5

r4(config)#access-list 10 permit 100.0.0.0 0.255.255.255

 
 

r4(config)#route-map com permit 10

r4(config-route-map)#match ip address 10

r4(config-route-map)#set community 123

r4(config-route-map)#exit

r4(config)#route-map com permit 20

r4(config-route-map)#exit

 
 

r4(config)#router bgp 4

r4(config-router)#neighbor 5.5.5.5 route-map com out 

r4(config-router)#neighbor 5.5.5.5 send-community

说明:R4将100.0.0.0/8的全部路由的Community设置为 123,并发给R5

 
 

(2)查看R5收到的带community的路由

r5#sh ip bgp community 

BGP table version is 41, local router ID is 5.5.5.5

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 100.1.1.0/24     4.4.4.4                                0 4 1 i

*> 100.1.2.0/24     4.4.4.4                                0 4 6 i

*> 100.1.3.0/24     4.4.4.4                                0 4 6 i

r5#

说明:R4收到的带community的路由为全部100.0.0.0/8。

 
 

(3)查看R5的community的路由情况

r5#sh ip bgp 100.1.1.0

BGP routing table entry for 100.1.1.0/24, version 39

Paths: (1 available, best #1, table Default-IP-Routing-Table)

Flag: 0x880

  Not advertised to any peer

  4 1

    4.4.4.4 (metric 65) from 4.4.4.4 (4.4.4.4)

      Origin IGP, localpref 100, valid, external, best

      Community: 123

r5#

说明:R4收到的路由100.0.0.0/8的community为123

 
 

 
 

(4)查看R5当前BGP路由情况

r5#sh ip bgp 

BGP table version is 41, local router ID is 5.5.5.5

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      4.4.4.4                                0 4 1 i

*> 22.2.2.0/24      4.4.4.4                                0 4 1 i

*> 33.3.3.0/24      4.4.4.4                                0 4 1 i

*> 44.4.4.0/24      4.4.4.4                  0             0 4 i

*> 55.5.5.0/24      0.0.0.0                  0         32768 i

*> 66.6.6.0/24      4.4.4.4                                0 4 6 i

*> 100.1.1.0/24     4.4.4.4                                0 4 1 i

*> 100.1.2.0/24     4.4.4.4                                0 4 6 i

*> 100.1.3.0/24     4.4.4.4                                0 4 6 i

r5#

说明:R5当前BGP路由正常,包括10.0.0.0/8。

 
 

(5)R5将所有community为123的路由的weight值改为123

r5(config)#ip community-list 5 permit 123

 
 

r5(config)#route-map wei permit 10

r5(config-route-map)#match community 5

r5(config-route-map)#set weight 123

r5(config-route-map)#exit

r5(config)#route-map wei permit 20

r5(config-route-map)#exit

 
 

r5(config)#router bgp 5

r5(config-router)#neighbor 4.4.4.4 route-map wei in

说明:R5上community-list匹配community为123的路由,并将weight值改为123。

 
 

(6)查看R5修改后的路由情况

r5#sh ip bgp 

BGP table version is 44, local router ID is 5.5.5.5

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      4.4.4.4                                0 4 1 i

*> 22.2.2.0/24      4.4.4.4                                0 4 1 i

*> 33.3.3.0/24      4.4.4.4                                0 4 1 i

*> 44.4.4.0/24      4.4.4.4                  0             0 4 i

*> 55.5.5.0/24      0.0.0.0                  0         32768 i

*> 66.6.6.0/24      4.4.4.4                                0 4 6 i

*> 100.1.1.0/24     4.4.4.4                              123 4 1 i

*> 100.1.2.0/24     4.4.4.4                              123 4 6 i

*> 100.1.3.0/24     4.4.4.4                              123 4 6 i

r5#

说明:community为123的路由100.0.0.0/8的weight值已被改为123。

 
 

 
 

6.测试AS:NN私有Community

(1)R4将100.0.0.0/8的全部路由的Community设置为 4:123,并发给R5

 
 

r4(config)#access-list 10 permit 100.0.0.0 0.255.255.255

 
 

r4(config)#route-map com2 permit 10

r4(config-route-map)#match ip address 10

r4(config-route-map)#set community 4:123

r4(config-route-map)#exit

r4(config)#route-map com2 permit 20

r4(config-route-map)#exit

 
 

r4(config)#router bgp 4

r4(config-router)#neighbor 5.5.5.5 route-map com2 out 

r4(config-router)#neighbor 5.5.5.5 send-community

 
 

说明:R4将100.0.0.0/8的全部路由的Community设置为4: 123,并发给R5,

 
 

(2)如果双方不做如下配置,则Community格式不是AS:NN:

r4(config)#ip bgp-community new-format 

r5(config)#ip bgp-community new-format

 
 

r5#sh ip bgp 100.1.1.0

BGP routing table entry for 100.1.1.0/24, version 11

Paths: (1 available, best #1, table Default-IP-Routing-Table)

Flag: 0x880

  Not advertised to any peer

  4 1

    4.4.4.4 (metric 65) from 4.4.4.4 (4.4.4.4)

      Origin IGP, localpref 100, valid, external, best

      Community: 262267

r5#

说明:不配置bgp-community new-format,格式不为AS:NN。

 
 

 
 

(3)配置bgp-community new-format后,格式为AS:NN:

r5#sh ip bgp 100.1.1.0     

BGP routing table entry for 100.1.1.0/24, version 11

Paths: (1 available, best #1, table Default-IP-Routing-Table)

  Not advertised to any peer

  4 1

    4.4.4.4 (metric 65) from 4.4.4.4 (4.4.4.4)

      Origin IGP, localpref 100, valid, external, best

      Community: 4:123

r5#

说明:双方配置bgp-community new-format后,Community变为 4:123,即为AS:NN格式。

 
 

 
 

7.测试错误AS号码下的BGP邻居

说明:当在指定BGP邻居时,如果AS号码错误,可以通过AS欺骗的形式来建立邻居。

(1)在R5上配置BGP

r5(config)#router bgp 5

r5(config-router)#bgp router-id 5.5.5.5

r5(config-router)#neighbor 4.4.4.4 remote-as 100

r5(config-router)#neighbor 4.4.4.4 up loopback 0

r5(config-router)#neighbor 4.4.4.4 ebgp-multihop

r5(config-router)#network 55.5.5.0 mask 255.255.255.0

说明:邻居4.4.4.4应该是AS 4的,而R5错指为100。

 
 

(2)在R4上配置AS 欺骗

r4(config)#router bgp 4

r4(config-router)#neighbor 5.5.5.5 remote-as 5

r4(config-router)#neighbor 5.5.5.5 update-source loopback 0

r4(config-router)#neighbor 5.5.5.5 ebgp-multihop 

r4(config-router)#neighbor 5.5.5.5 local-as 100

说明:R4将自己针对邻居5.5.5.5的AS改为100,以建立BGP邻居。

 
 

(3)查看R5的BGP邻居

r5#sh ip bgp summary 

BGP router identifier 5.5.5.5, local AS number 5

BGP table version is 10, main routing table version 10

9 network entries using 1161 bytes of memory

9 path entries using 468 bytes of memory

5/4 BGP path/bestpath attribute entries using 620 bytes of memory

3 BGP AS-PATH entries using 72 bytes of memory

0 BGP route-map cache entries using 0 bytes of memory

0 BGP filter-list cache entries using 0 bytes of memory

BGP using 2321 total bytes of memory

BGP activity 9/0 prefixes, 9/0 paths, scan interval 60 secs

 
 

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

4.4.4.4         4   100      10       7       10    0    0 00:00:34        8

r5#

说明:可以看到,R5已经与R4建立邻居关系,并且认为对方是AS 100。

 
 

 
 

(4)查看R5的BGP路由

r5#sh ip bgp 

BGP table version is 10, local router ID is 5.5.5.5

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      4.4.4.4                                0 100 4 1 i

*> 22.2.2.0/24      4.4.4.4                                0 100 4 1 i

*> 33.3.3.0/24      4.4.4.4                                0 100 4 1 i

*> 44.4.4.0/24      4.4.4.4                  0             0 100 4 i

*> 55.5.5.0/24      0.0.0.0                  0         32768 i

*> 66.6.6.0/24      4.4.4.4                                0 100 4 6 i

*> 100.1.1.0/24     4.4.4.4                                0 100 4 1 i

*> 100.1.2.0/24     4.4.4.4                                0 100 4 6 i

*> 100.1.3.0/24     4.4.4.4                                0 100 4 6 i

r5#

说明:R4在将所有路由发给R5时,除了原有的所有真正AS外,虚假AS 100也被添加进了AS_Path中,用以欺骗R5。

 
 

(5)查看R6的BGP路由

r6#sh ip bgp 

BGP table version is 158, local router ID is 6.6.6.6

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      4.4.4.4                                0 4 1 i

*> 22.2.2.0/24      4.4.4.4                                0 4 1 i

*> 33.3.3.0/24      4.4.4.4                                0 4 1 i

*> 44.4.4.0/24      4.4.4.4                  0             0 4 i

*> 55.5.5.0/24      4.4.4.4                                0 4 100 5 i

*> 66.6.6.0/24      0.0.0.0                  0         32768 i

*> 100.1.1.0/24     4.4.4.4                                0 4 1 i

*> 100.1.2.0/24     0.0.0.0                  0         32768 i

*> 100.1.3.0/24     0.0.0.0                  0         32768 i

r6#

说明:对于R4与R5之间的虚假AS 100,在将路由发给R6时,这个AS同样存在。

(6)在AS_Path中移除虚假AS 100

r4(config)#router bgp 4

r4(config-router)#neighbor 5.5.5.5 local-as 100 no-prepend

说明:指定虚假AS 100不添加在AS_Path中。

 
 

(7)再次查看R5的BGP路由表

r5#sh ip bgp 

BGP table version is 26, local router ID is 5.5.5.5

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      4.4.4.4                                0 100 4 1 i

*> 22.2.2.0/24      4.4.4.4                                0 100 4 1 i

*> 33.3.3.0/24      4.4.4.4                                0 100 4 1 i

*> 44.4.4.0/24      4.4.4.4                  0             0 100 4 i

*> 55.5.5.0/24      0.0.0.0                  0         32768 i

*> 66.6.6.0/24      4.4.4.4                                0 100 4 6 i

*> 100.1.1.0/24     4.4.4.4                                0 100 4 1 i

*> 100.1.2.0/24     4.4.4.4                                0 100 4 6 i

*> 100.1.3.0/24     4.4.4.4                                0 100 4 6 i

r5#

说明:对于R5来说,虚假的AS 100无法去除,因为对方邻居指定为100,如果AS_Path中没有AS 100,则会有错误。

 
 

(8)再次查看R6的BGP路由

 
 

r6#sh ip bgp 

BGP table version is 160, local router ID is 6.6.6.6

Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,

              r RIB-failure, S Stale

Origin codes: i – IGP, e – EGP, ? – incomplete

 
 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24      4.4.4.4                                0 4 1 i

*> 22.2.2.0/24      4.4.4.4                                0 4 1 i

*> 33.3.3.0/24      4.4.4.4                                0 4 1 i

*> 44.4.4.0/24      4.4.4.4                  0             0 4 i

*> 55.5.5.0/24      4.4.4.4                                0 4 5 i

*> 66.6.6.0/24      0.0.0.0                  0         32768 i

*> 100.1.1.0/24     4.4.4.4                                0 4 1 i

*> 100.1.2.0/24     0.0.0.0                  0         32768 i

*> 100.1.3.0/24     0.0.0.0                  0         32768 i

r6#

说明:在将路由发给与虚假AS 100不相关的邻居时,虚假AS 可以不添加到AS_Path中。

文章目录

Work Blog » 01_2_BGP Community
分享到:
赞(0) 打赏

评论抢沙发

评论前必须登录!

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏