Lab BGP Summary

BGP的汇总有2种:
A.汇总:summary
静态路由手工汇总指向null 0,再network引入BGP。
如果明细路由断了,汇总仍然会被引入,且缺乏灵活性。

命令network要求路由选择表中有与指定的前缀或掩码完全匹配的条目,为满足这种要求,可配置一条指向接口null0的静态路由,如果IGP执行汇总,则路由选择中可能已以有这样的静态路由。
命令network告诉BGP通告哪些网络,而不如何通告,仅当描写的网络号出现在IP路由选择中后,BGP才会通告它,如下图所示。

B.聚合:aggregate
聚合路由在本路由器上生成一条聚合路由,下一跳为0.0.0.0。
aggregate-address 172.16.12.0 255.255.252.0 ?                                
advertise-map    Set condition to advertise attribute                        
as-set           Generate AS set path information                            
attribute-map    Set attributes of aggregate                                 
route-map        Set parameters of aggregate                                 
summary-only     Filter more specific routes from updates                    
suppress-map     Conditionally filter more specific routes from updates nlri 
<cr>                                                                         
Advertise-map
只对advertise-map里面匹配的路由进行聚合。当advertise-map里面匹配的明细路由全部消失后,即使聚合路由范围内还有其他明细路由,聚合路由也将消失。当与as-set合用时,只继承advertise-map里面匹配的明细路由的属性。如果用summary-only,会将所有的明细包括没有在advertise-map里面匹配的路由一起抑制。
As-set
聚合路由继承明细路由的属性,包括:as-path、local_preference、community、origin-code。与advertise-map合用,只继承advertise-map里面匹配的明细路由的属性。如果继承了as-path属性,继承的as-path如果没有在大括号{ }中显示,则有几个算几个AS;如果继承AS是在大括号中排列的,那么只算一个AS号。只关心AS的号码,不关心顺序。
As-path、as-seq(as-path)原子聚合不带任何AS。AS-SET首先是区别于atomic-aggregate,产生了AS的序列,序列中无分先后顺序,这一点也不同于有明确顺序的AS-SEQEUENCE
Attribute-map和route-map
这两个参数一样,可以将聚合路由的属性清除掉(除了as-path属性),添加自己需要添加的属性。Attribute-map 与 as-set的合用时,能否将聚合的路由的属性重置。(OK可以改)
Summary-only
将聚合路由所包括的所有路由都抑制掉,被抑制的路由在bgp的转发表里,显示为s,代表suppress的意思。发送更新时,只发送聚合路由。可以与
>neighbor 1.1.1.1 unsuppress-map XX合用,对特定邻居漏过特定的明细路由。
>Suppress-map,将suppress-map里面匹配的路由抑制掉,被抑制的路由在bgp的转发表里,显示为s,代表suppress的意思。发送更新时,只发送聚合路由和没有被抑制的明细路由。可以与neighbor 1.1.1.1 unsuppress-map XX合用,对特定邻居漏过特定的明细路由。

Lab


主要命令:
aggregate-address {ip-address mask}
aggregate-address {ip-address mask} as-set
aggregate-address {ip-address mask} summary-only
aggregate-address {ip-address mask} as-set summary-only
aggregate-address {ip-address mask} as-set suppress-map {route-map name}
实验目的:掌握
1 路由聚合属性 as-set的含义
2 路由聚合属性 summary-only的含义
3 路由聚合属性 suppress-map,as-set suppress-map的含义
 
step 1 加载基础配置
  
先查看BGP表:验证宣告的网络都被学到。


以上输出说明:
1 在R1 R4接受到“192.168.0.0/24”聚合路由,通过AS-PATH属性可以看出,执行地址聚合的路由器R2称为新路由的创造者,原来AS-PATH属性丢失
2 R4同时接收了4条明细路由在显示的AS-PATH序列中,路由的始发AS在列表的末端(右端),每个接收到该路由,并把他传递给其他AS的BGP对等体会把它自己的AS追加到列表的开头(左侧)
3 BGP路由器下一跳为“0.0.0.0” 表示该BGP路由起源本地,WEIGHT值为”32768”
4 因为所有BGP路由条目的代码为“>”,所以所有BGP路由条目都为最优。
 
R2:
router bgp 200
aggregate-address 192.168.0.0 255.255.252.0

AS-SET属性:
 该属性可以让BGP聚合路由不丢失原来的AS-PATH参数,从而避免路由环路,在R2上操作如下:
R2(config-router)#aggregate-address 192.168.0.0 255.255.252.0 as-set
查看R1 R4路由表:


 
1输出表明R4接收到了汇总路由“192.168.0.0/22”中,AS-PATH包含了被聚合路由的所有AS号码的集合“{100,300}”
2 聚合路由正是由于携带了所有的AS,所以在R1的BGP表中没有出现,当然在R3的BGP表中也不会出现。
 
技术要点:
BGP使用AS-PATH属性作为路由更新的一部分来确保没有路由环路,因为在BGP对等体之间传递的每条路由都携带它所经过的AS号码序列表,如果该路由被通告给它始发的AS,该AS路由器将在AS序列表中看到自己的AS,它将不接收该路由,以下的输出充分的说明这一点。

说明R2仍然向R1发送聚合“192.168.0.0/22”

如果要完成R1# show ip bgp neighbor 12.12.12.2 receive-routes 必须先完成下面的命令:
R1(config-route)#neighbor 12.12.12.2 soft-reconfiguration inbound  
以上输出说明:R1没有接收聚合路由1.1.1.0/22 因为它发现聚合路由条目的AS-PATH属性列表{100,300}中包含自己的AS号为100,所以不接收,仅仅接收了AS300的路由。同理,R3也不会接收该聚合路由。
 
(3)summary-only 属性
首先直接使用
R2(config-router)#aggregate-address 192.168.0.0 255.255.252.0 summary-only 
来查看效果。

R2抑制了明细路由的扩散,并把明细路由标记为“S”
 
然后使用
R2(config-router)#aggregate-address 192.168.0.0 255.255.252.0 as-set summary-only


以上输出表明:
1 R2上所有被聚合的明细路由全被抑制,标记“s”.R1上也没有聚合路由.
2 R4只接收一条聚合“192.168.0.0/22”.
 
(4) 抑制部分明细路由
 如果有特殊的要求,在聚合后只抑制部分明细路由,参数“suppress-map”可以完成。本实验要求R2聚合后,R1的两条明细路由被抑制,而R3的明细路由可以传递给R4,路由R2的配置如下:
 
R2(config)#ip prefix-list 1 seq 5 permit 192.168.0.0/24                                 
R2(config)#ip prefix-list 1 seq 10 permit 192.168.1.0/24                                
R2(config)#route-map SUP permit 10                                                      
R2(config-route-map)#match ip address prefix-list 1                                     
R2(config)#router bgp 200                                                               
R2(config-route)#aggregate-address 192.168.0.0 255.255.252.0 as-set suppress-map SUP   


以上输出说明:
1 由于在R2上将R1的明细路由“192.168.0.0/24”“ 192.168.1.0/24”抑制,所以R3 R4不被接收到
2 由于在R2上没有将明细路由”192.168.2.0/24”’ 192.168.3.0/24’抑制,又没有配置‘summary-only’属性,所以R4全部接收的”192.168.2.0/24”’ 192.168.3.0/24’的路由。
3 由于配置了“as-set”属性,只有R4接收到汇总路由“1.1.0.0/22”
 
(5)as-set + suppress-map +summary-only  研究
R2(config-route)#aggregate-address 192.168.0.0 255.255.252.0 as-set summary-only suppress-map SUP
 
与上面的实验是一样的效果! 这里 summsry-only 没有起到任何作用!
 
如果向实现 联通!  
可以在R2上加三条默认路由:
R2(config)#ip route 0.0.0.0 0.0.0.0 24.0.0.4
R2(config)#ip route 0.0.0.0 0.0.0.0 12.0.0.1
R2(config)#ip route 0.0.0.0 0.0.0.0 23.0.0.3
并且R2宣告默认路由
如果使用#default-information origint 
R2#sho ip route                                          
Gateway of last resort is 24.0.0.4 to network 0.0.0.0    
     23.0.0.0/24 is subnetted, 1 subnets                 
C       23.0.0.0 is directly connected, Serial1/1        
     24.0.0.0/24 is subnetted, 1 subnets                 
C       24.0.0.0 is directly connected, Serial1/2        
B    192.168.0.0/24 [20/0] via 12.0.0.1, 00:23:05        
     12.0.0.0/24 is subnetted, 1 subnets                 
C       12.0.0.0 is directly connected, Serial1/0        
B    192.168.1.0/24 [20/0] via 12.0.0.1, 00:23:05        
B    192.168.2.0/24 [20/0] via 23.0.0.3, 00:23:05        
B    192.168.3.0/24 [20/0] via 23.0.0.3, 00:23:05        
S*   0.0.0.0/0 [1/0] via 24.0.0.4                        
               [1/0] via 12.0.0.1                        
               [1/0] via 23.0.0.3                        
 
R1#sho ip route                                          
Gateway of last resort is 12.0.0.2 to network 0.0.0.0    
C    192.168.0.0/24 is directly connected, Loopback2     
     12.0.0.0/24 is subnetted, 1 subnets                 
C       12.0.0.0 is directly connected, Serial1/0        
C    192.168.1.0/24 is directly connected, Loopback1     
B    192.168.2.0/24 [20/0] via 12.0.0.2, 00:22:24        
B    192.168.3.0/24 [20/0] via 12.0.0.2, 00:22:24        
B*   0.0.0.0/0 [20/0] via 12.0.0.2, 00:05:17             
 
R1#ping 24.0.0.4                                                           
Type escape sequence to abort.                                             
Sending 5, 100-byte ICMP Echos to 24.0.0.4, timeout is 2 seconds:          
!!!!!                                                                      
Success rate is 100 percent (5/5), round-trip min/avg/max = 144/229/332 ms 
R1#ping 23.0.0.3                                                           
Type escape sequence to abort.                                             
Sending 5, 100-byte ICMP Echos to 23.0.0.3, timeout is 2 seconds:          
!!!!!                                                                      
Success rate is 100 percent (5/5), round-trip min/avg/max = 120/229/312 ms 

===================================================================

R1=================================


hostname r1
!
!
interface Loopback0
 ip address 192.168.0.1 255.255.255.0
!
interface Loopback1
 ip address 192.168.1.1 255.255.255.0
!
interface Ethernet0/0
 no ip address
 no shut
!
interface Ethernet0/0.12
 encapsulation dot1Q 12
 ip address 12.1.1.1 255.255.255.0
!

!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 192.168.0.0
 network 192.168.1.0
 neighbor 12.1.1.2 remote-as 200
 no auto-summary
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
!
!
!

R2========================================

!
interface Ethernet0/0
 no ip address
 no shut
!
interface Ethernet0/0.12
 encapsulation dot1Q 12
 ip address 12.1.1.2 255.255.255.0
!
interface Ethernet0/0.23
 encapsulation dot1Q 23
 ip address 23.1.1.2 255.255.255.0
!
interface Ethernet0/0.24
 encapsulation dot1Q 24
 ip address 24.1.1.2 255.255.255.0
!
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 12.1.1.1 remote-as 100
 neighbor 23.1.1.3 remote-as 300
 neighbor 24.1.1.4 remote-as 400
 no auto-summary

R3===================================

!
interface Loopback0
 ip address 192.168.2.2 255.255.255.0
!
interface Loopback1
 ip address 192.168.3.3 255.255.255.0
!
interface Ethernet0/0
 no ip address
 no shut
!
interface Ethernet0/0.23
 encapsulation dot1Q 23
 ip address 23.1.1.3 255.255.255.0
!
!
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 network 192.168.2.0
 network 192.168.3.0
 neighbor 23.1.1.2 remote-as 200
 no auto-summary

R4=====================================

!
interface Ethernet0/0
 no ip address
 no shut
!
interface Ethernet0/0.24
 encapsulation dot1Q 24
 ip address 24.1.1.4 255.255.255.0
!
!
router bgp 400
 no synchronization
 bgp log-neighbor-changes
 neighbor 24.1.1.2 remote-as 200
 no auto-summary
 

原文地址:https://www.cnblogs.com/cyrusxx/p/12824214.html