neighbor {ip-address | peer-group-name} advertise-map route-map-name1 non-exist-map route-map-name2
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

n   ip-address— Neighbor's IP address.
邻居的 IP 地址 .
n   peer-group-name— Name of the peer group.
Peer 组的名字
n   route-map-name1— Route map that identifies the secondary prefix to advertise only if the primary prefix referenced by route-map-name2 disappears.
仅仅当 route-map-name2 关连的 主要前缀 消失后, Route map 标识的 次要前缀才会通告 .
n   route-map-name2— Route map that identifies the primary prefix to advertise. If this route disappears, the secondary prefix referenced by route-map-name1 is advertised.
    Route map 标识的主要前缀通告。如果这个路由消失,则 route-map-name1 关连的次要前缀将会被通告 .

 

。。。。。翻译的乱七八糟自己,举例说吧:
neighbor <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />10.1.12.2 advertise-map lo2 non-exist-map lo1
(lo1 lo2 都是 route-map 的名字 ,关连 loopback 1 loopback 2 的路由 .)
lo1 路由存在时,不发送 lo2 的路由;当 lo1 路由不存在时,则发送 lo2 的路由 .
注: advertise-map 命令解释 specify route-map for conditional advertisement
         non-exist-map 命令解释 advertise prefix only if prefix in the condition does not exist
         条件路由通告,两个必须合用 .
 
 
实验拓朴:
 
 
实验配置:

R1
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Loopback1
 ip address 172.16.1.1 255.255.255.0
!
interface Loopback2
 ip address 172.16.2.1 255.255.255.0
!
interface Serial1/1
 ip address 10.1.12.1 255.255.255.0
!
router bgp 1
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 172.16.1.0 mask 255.255.255.0
 network 172.16.2.0 mask 255.255.255.0
 neighbor 10.1.12.2 remote-as 2
 no auto-summary
!

 

R2
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface Serial1/0
 ip address 10.1.12.2 255.255.255.0
!
router bgp 2
 no synchronization
 bgp router-id 2.2.2.2
bgp log-neighbor-changes
 neighbor 10.1.12.1 remote-as 1
 no auto-summary
!

 

实验现象:

1.  R1 R2  EBGP 邻居关系,通告 lo1 lo2

R1#sh ip bgp
BGP table version is 13, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.1.0/24    0.0.0.0                  0         32768 i
*> 172.16.2.0/24    0.0.0.0                  0         32768 i

 

R2#sh ip bgp
BGP table version is 19, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.1.0/24    10.1.12.1                0             0 1 i
*> 172.16.2.0/24    10.1.12.1                0             0 1 i

 

 

2.  R1 配置 neighbor {ip-address | peer-group-name} advertise-map route-map-name1 non-exist-map route-map-name2

配置:
R1(config)#router bgp 1
R1(config-router)#nei 10.1.12.2 advertise-map lo2 non-exist-map lo1
R1(config-router)#exi
R1(config)#route-map lo1
R1(config-route-map)#match ip add pre lo1
R1(config-route-map)#exi
R1(config)#route-map lo2
R1(config-route-map)#match ip add pre lo2
R1(config-route-map)#exi
R1(config)#ip pre lo1 per 172.16.1.0/24
R1(config)#ip pre lo2 per 172.16.2.0/24
R1(config)#end
R1#
R1#sh run | b r b
router bgp 1
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 172.16.1.0 mask 255.255.255.0
 network 172.16.2.0 mask 255.255.255.0
 neighbor 10.1.12.2 remote-as 2
 neighbor 10.1.12.2 advertise-map lo2 non-exist-map lo1
 no auto-summary
!
ip classless
no ip http server
!
!
ip prefix-list lo1 seq 5 permit 172.16.1.0/24
!
ip prefix-list lo2 seq 5 permit 172.16.2.0/24
route-map lo2 permit 10
 match ip address prefix-list lo2
!
route-map lo1 permit 10
 match ip address prefix-list lo1
!

 

结果:
R1#sh ip bgp

BGP table version is 16, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.1.0/24    0.0.0.0                  0         32768 i

*> 172.16.2.0/24    0.0.0.0                  0         32768 i

 

R1#sh ip bgp nei 10.1.12.2 advertised-routes

BGP table version is 16, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.1.0/24    0.0.0.0                  0         32768 i

R1#

 

R2#sh ip bgp

BGP table version is 20, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.1.0/24    10.1.12.1                0             0 1 i

 

R1 lo1 存在的情况下,不通告 lo2 路由给 R2.

 

3.  R1 lo1 接口 shutdown lo1 消失 .

R1(config)#int lo1
R1(config-if)#sh
R1(config-if)#end
R1#sh ip bgp
BGP table version is 17, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.2.0/24    0.0.0.0                  0         32768 i

R1#
R1#sh ip bgp nei 10.1.12.2 advertised-routes

BGP table version is 18, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.2.0/24    0.0.0.0                  0         32768 i

 

R2#sh ip bgp

BGP table version is 22, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.2.0/24    10.1.12.1                0             0 1 i

 

R1 lo1 不存在的情况下,通告 lo2 路由给 R2.

 

 

扩展实验:

命令 aggregate-address address mask as-set summary-only advertise-map route-map-name

n   此处 advertise-map 解释为route-map-name— Route map used to determine the prefixes used to form the aggregate.
Route map 用于决定用来形成聚合路由的前缀.

 

实验说明:

R1 配置如下

interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Loopback1
 ip address 172.16.1.1 255.255.255.0
!
interface Loopback2
 ip address 172.16.2.1 255.255.255.0
!
interface Loopback3
 ip address 172.16.3.1 255.255.255.0
!
interface Serial1/1
 ip address 10.1.12.1 255.255.255.0
router bgp 1
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 172.16.1.0 mask 255.255.255.0
 network 172.16.2.0 mask 255.255.255.0
 network 172.16.3.0 mask 255.255.255.0
 aggregate-address 172.16.0.0 255.255.0.0 as-set summary-only advertise-map lo12

 neighbor 10.1.12.2 remote-as 2
 no auto-summary
!        
ip prefix-list lo1 seq 5 permit 172.16.1.0/24

!

ip prefix-list lo2 seq 5 permit 172.16.2.0/24

route-map lo12 permit 10

 match ip address prefix-list lo1 lo2

!

 

Network 三个loopback路由,同时生成聚合路由 172.16.0.0/16 summary-only 意思是指通告聚合路由(明细路由被抑制),advertise-map匹配的路由为形成聚合路由的条件(lo1lo2存在的情况下,此聚合路由产生).

 

实验现象:

1. 正常情况

R1#sh ip bgp
BGP table version is 8, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.0.0       0.0.0.0                       100  32768 i

s> 172.16.1.0/24    0.0.0.0                  0         32768 i

s> 172.16.2.0/24    0.0.0.0                  0         32768 i

s> 172.16.3.0/24    0.0.0.0                  0         32768 i

 

R2#sh ip bgp
BGP table version is 31, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.0.0       10.1.12.1                              0 1 i

R2#

 

注意: R1  172.16.3.0/24 也被抑制, R2 也收不到,是因为 172.16.3.0/24 虽然不属于条件通告中的路由,但是所形成的聚合路由包括此网段 , 因此也被抑制 .

 

R1#sh ip bgp 172.16.3.0
BGP routing table entry for 172.16.3.0/24, version 13
Paths: (1 available, best #1, table Default-IP-Routing-Table, Advertisements suppressed by an aggregate.)

  Not advertised to any peer
  Local
    0.0.0.0 from 0.0.0.0 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best

 

2.  lo1 shutdown 情况

R1#sh ip bgp
BGP table version is 9, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.0.0       0.0.0.0                       100  32768 i

s> 172.16.2.0/24    0.0.0.0                  0         32768 i

s> 172.16.3.0/24    0.0.0.0                  0         32768 i

 

R2#sh ip bgp
BGP table version is 31, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.0.0       10.1.12.1                              0 1 i

 

聚合路由依然存在 , 同时 172.16.3.0/24 情况如 1 .

 

3. lo1 lo2 全部 shutdown 情况

R1#sh ip bgp
BGP table version is 11, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
s> 172.16.3.0/24    0.0.0.0                  0         32768 i

R1#sh ip bgp 172.16.3.0

BGP routing table entry for 172.16.3.0/24, version 13
Paths: (1 available, best #1, table Default-IP-Routing-Table, Advertisements suppressed by an aggregate.)

  Not advertised to any peer
  Local
    0.0.0.0 from 0.0.0.0 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best

 

R2#sh ip bgp

 

R2#

 

此时聚合路由消失,因为做为聚合路由的条件 lo1 lo2 全部消失,所以正常 .

但此时出现疑问, lo3 并没有做为通告聚合路由的条件,在聚合路由消失的情况,仍然被抑制,并且会被一直抑制,软清邻居 clear ip bgp * s 无效 , 必须硬清邻居关系 clear ip bgp *, 重新建立邻居关系,才被通告出去 .

 

R1#clear ip bgp *

R1#
R1#
01:05:34: %BGP-5-ADJCHANGE: neighbor 10.1.12.2 Down User reset
R1#
01:06:12: %BGP-5-ADJCHANGE: neighbor 10.1.12.2 Up
R1#sh ip bgp

BGP table version is 2, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.3.0/24    0.0.0.0                  0         32768 i

R1#

 

R2#sh ip bgp

BGP table version is 33, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.3.0/24    10.1.12.1                0             0 1 i

R2#

 

 

解决如何在上述情况出现时,不需要手动硬清邻居关系而通告 lo3 的一种方法就是利用主实验里面的 neighbor {ip-address | peer-group-name} advertise-map route-map-name1 non-exist-map route-map-name2 命令 , 并且汇总时 summary-only 改为 suppress-map( 抑制 lo1 lo2 路由 )

 

实验配置如下:

R1#sh run | b r b
router bgp 1
 bgp router-id 1.1.1.1
 bgp cluster-id 2886730497
 bgp log-neighbor-changes
 network 172.16.1.0 mask 255.255.255.0
 network 172.16.2.0 mask 255.255.255.0
 network 172.16.3.0 mask 255.255.255.0
 aggregate-address 172.16.0.0 255.255.0.0 as-set advertise-map lo12 suppress-map lo12

 neighbor 10.1.12.2 remote-as 2
 neighbor 10.1.12.2 advertise-map lo3 non-exist-map lo12

 no auto-summary
!
ip prefix-list lo1 seq 5 permit 172.16.1.0/24

!

ip prefix-list lo2 seq 5 permit 172.16.2.0/24

!

ip prefix-list lo3 seq 5 permit 172.16.3.0/24

route-map lo12 permit 10

 match ip address prefix-list lo1 lo2

!
route-map lo3 permit 10

 match ip address prefix-list lo3

!

 

4. lo1 lo2 恢复 ,正常情况

R1#sh ip bgp
BGP table version is 8, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.0.0       0.0.0.0                       100  32768 i

s> 172.16.1.0/24    0.0.0.0                  0         32768 i

s> 172.16.2.0/24    0.0.0.0                  0         32768 i

*> 172.16.3.0/24    0.0.0.0                  0         32768 i

R1#
R1#sh ip bgp 172.16.3.0

BGP routing table entry for 172.16.3.0/24, version 8
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Not advertised to any peer

  Local
    0.0.0.0 from 0.0.0.0 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
R1#

 

R1 lo1 lo2 路由被抑制, lo3 路由未显示 S 抑制,但是条件路由通告中 lo1 lo2 存在时, lo3 不通告 , 因此 R2 只有聚合路由,无 lo3 路由 .

 

R2#sh ip bgp
BGP table version is 10, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.0.0       10.1.12.1                              0 1 i

 

5. lo1 lo2 shutdown 情况

R1#sh ip bgp

BGP table version is 12, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.3.0/24    0.0.0.0                  0         32768 i

R1#sh ip bgp 172.16.3.0

BGP routing table entry for 172.16.3.0/24, version 12
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Advertised to non peer-group peers:

  10.1.12.2
  Local
    0.0.0.0 from 0.0.0.0 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
R1#

 

R2#sh ip bgp

BGP table version is 12, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.3.0/24    10.1.12.1                0             0 1 i

 

R1 显示并通告 lo3 路由 .