Cisco 跨域三层××× OptionC配置指导
 

1 OptionC方式跨域×××的理解

之前,我写了一篇OptionB的文档,并提供了相应的配置,对于该文档中相应的内容,我在这里就不再罗嗦了,本文开始对OptionC方式的跨域×××做分析。
 
OptionB方式中,×××的路由信息是通过自治系统之间的ASBR来保存和扩散的,当×××路由比较多的时候,会对ASBR产生巨大的压力;如果经过多个自治系统,每个ASBR上都会维护大量相同的×××路由,由于这些ASBR一般都承担着公网IP转发的任务,这样对设备的要求就更高了。从另一个方面来看,OptionB方式采用的是一种中继的方式,通过ASBR×××路由信息向其他自治系统扩散,这也把这些中间设备强加上必须要支持×××功能的要求,虽然对于设备而言,这是必须的,但是这样的实现方式个人觉得并不完全符合三层×××的思想,按照正常的理解,除了接入CEPE之外,其他设备是不应该看到×××信息的,这也是OptionC方式所解决的问题。
 
OptionC方式的思想就是在跨域的情况下,PE之间仍然可以像域内那样,在PEPE之间建立直接的MEBGP邻居,交换×××V4路由信息,这样就不需要中间设备再保存、维护和扩散×××路由信息。这里需要从两个方面去考虑:信令和转发。在信令层面上,实现跨域MEBGP邻居的建立,并交换×××路由信息并不是一件困难的事情,只要公网路由可达,建立起邻居,私网的×××路由信息就可以很轻松的发给对端邻居了。但是,在转发层面上,还有一个最重要的问题需要解决,那就是如何在跨域的情况下建立一条PEPE××× LSP,否则,即便有了×××路由信息,到了公网部分,根本无法识别数据的私网标签,转发层面上还是不通的。
 
这里,需要提到标签IPv4路由,在RFC3107[Carrying Label Information in BGP-4]中有定义。这里在ASBR之间传递的就不是普通的IP路由信息了,而是携带了标签的公网路由信息,这样,就会在公网上形成一个由BGP触发的公网LSP,在公网上也是靠标签交换就数据传送到目的地,而公网上无法识别的私网标签就可以被封装在内层作为内层标签被转发了。有兴趣的朋友可以看一下RFC3107中所定义的应用场景和具体的update的消息格式,该RFC内容不长,这里不作过多的阐述,下面列举一下普通的update和支持标签IPv4路由信息的update的格式即可。
 
普通update消息
 
Cisco跨域三层××× OptionC配置指导_第1张图片
 
标签ipv4格式的update消息
 
Cisco跨域三层××× OptionC配置指导_第2张图片

2 OptionC方式的数据转发

Cisco跨域三层××× OptionC配置指导_第3张图片

 
仍然沿用跟OptionB方式中大致类似的网络结构,如上图。
以从R6上的vrf30 ping R1上的vrf30为例,即ping vrf vrf30 10.0.30 .1 source 60.0.30.1,从R6àR1方向,IP数据会首先被封装上×××v4目的路由对应的标签,接着会被封装上标签IPv4路由信息对应的标签,最后才会被封装上LDP标签,其中LDP标签完成LDP域的标签交换,随后通过标签IPv4路由的标签完成EBGP域的标签交换,然后再进入对方自治系统的LDP域,最后通过私网标签完成×××域的标签交换,达到目的地。也就是说在整个数据传输过程中,最多的时候数据会被封装三层标签,即LDP | EBGP标签 | 私网标签。在上面的拓扑中,能够看到三层标签的位置为R6R5的出方向,理论上LDP域中都应该是三层标签头,但是由于存在空标签的缘故,有的位置只能显示的看到两层标签。在R5R6之间抓包如下,可以清楚的看到三层标签:
 
Cisco跨域三层××× OptionC配置指导_第4张图片
 
R6上显示各种标签信息,可以明显的看出图中的标签16LDP标签,标签29EBGP公网标签,标签18为私网路由标签,显示信息如下:
 
私网路由标签
 
R6#show bgp ***v4 unicast all labels                   
   Network          Next Hop      In label/Out label   
Route Distinguisher: 100:20 (vrf20)                    
   10.0.30 .0/24     202.1.1.1       nolabel/17         
   60.0.20.0/24     0.0.0 .0         19/aggregate(vrf20)
                   
Route Distinguisher: 100:30 (vrf30)                    
   10.0.30 .0/24     202.1.1.1       nolabel/18         
   60.0.30.0/24     0.0.0 .0         20/aggregate(vrf30)  
 
公网EBGP标签
 
R6#show bgp ipv4 unicast labels     
Network          Next Hop         In Label/Out Label   
80.1.2.0/24      202.1.1.4        nolabel/25           
80.2.3.0/24      202.1.1.4        nolabel/26           
80.2.3.2/32      202.1.1.4        nolabel/28           
80.5.6.0/24      0.0.0 .0          imp-null/nolabel     
202.1.1.1/32     202.1.1.4        nolabel/29           
202.1.1.2/32     202.1.1.4        nolabel/27           
202.1.1.6/32     0.0.0 .0          imp-null/nolabel     
 
LDP标签
 
R6#show mpls forwarding-table       
Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop       
tag    tag or VC   or Tunnel Id      switched   interface                 
16     Pop tag  80.4.5.0/24   0     Et4/0      80.5.6.1
17    16   202.1.1.4/32    0    Et4/0    80.5.6.1       
18     Pop tag  202.1.1.5/32  0     Et4/0      80.5.6.1       
19     Aggregate   60.0.20.0/24[V]   0                 
20     Aggregate   60.0.30.0/24[V]   0           
      
从上面的显示信息也可以清楚的看出路由的迭代关系与标签之间的关联,即到vrf30 10.0.30 .0/24的下一跳为202.1.1.1,到202.1.1.1的下一跳为202.1.1.4,通过路由迭代形成一个三层标签16 | 29 | 18 ,与抓包的数据完全一致。

3 OptionC方式的关键点

BGP4的扩展
通过RFC3107BGP4进行扩展,使得BGP发布路由信息时可以支持标签IPv4路由信息,所以在配置的时候也要配置支持标签IPv4路由信息的能力,如果不进行配置,那么只是普通的BGP,发布的路由信息也是普通的IPv4路由。
 
路由策略的创建:
ASBR上应用路由策略,对于从本ASPE接收的路由,在向对端ASBR发布时,分配MPLS 标签。对于向本ASPE 发布的路由,如果是带标签的IPv4路由,为其重新分配MPLS 标签。对IPv4 路由分配MPLS标签是通过路由策略控制的,只对满足某些条件的路由分配标签,其它路由还是普通IPv4 路由。缺省情况下,IPv4 路由不带MPLS 标签。
 

4 数据设计

由于一般的跨域×××配置示例都是两个AS,这里我故意调整成了三个AS,其实也没什么变化,就是多配置一些EBGP邻居而已。
 
Loopback地址202.1.1.X/32X=123456,即路由器序号;
接口地址80.X.Y.Z/24X/Y=路由器序号,Z12,路由器序号小的为1,大的为2
IGPPE-P-PE之间部署OSPFLDPASBR之间不起用任何IGP,只建立MEBGP邻居;
ASR1R2AS号为200R3AS号为300R4R6AS号为400
VrfR1上配置两个vrf
     Vrf20 RD=100:20  RT=100:20  路由为 10.0.30 .0/24
     Vrf30 RD=100:30  RT=100:30  路由为 10.0.30 .0/24
     配置为不同***相同的路由是客观验证一下***路由地址重叠的情况。
    R6上配置两个vrf
     Vrf20 RD=100:20  RT=100:20  路由为60.0.20.0/24
     Vrf30 RD=100:30  RT=100:30  路由为60.0.30.0/24
 

5 详细配置

为了节约版本,只罗列出6台路由器的相关配置,其他无关配置均不贴出来。具体的配置和显示信息可以参看最后附件中的文档。
[R1]
   
R1#show run                         
!                
version 12.4                        
!                
hostname R1                         
!                
ip cef                              
!                
ip vrf vrf10                        
 rd 100:10                          
 route-target export 100:10                            
 route-target import 100:10                            
!                
ip vrf vrf20                        
 rd 100:20                          
 route-target export 100:20                            
 route-target import 100:20                            
!                
ip vrf vrf30                        
 rd 100:30                          
 route-target export 100:30                            
 route-target import 100:30                            
!                
interface Loopback0                 
 ip address 202.1.1.1 255.255.255.255                  
!                
interface Ethernet4/0                
 ip address 80.1.2.1 255.255.255.0                     
 duplex full                        
 mpls ip                            
!                
interface Ethernet4/6               
 ip vrf forwarding vrf20                               
 ip address 10.0.30 .1 255.255.255.0                    
 duplex half                        
!                
interface Ethernet4/7               
 ip vrf forwarding vrf30                               
 ip address 10.0.30 .1 255.255.255.0                     
 duplex half                        
!                
router ospf 1                       
 log-adjacency-changes              
 network 80.1.2.0 0.0.0 .255 area 0                     
 network 202.1.1.1 0.0.0 .0 area 0                       
!                
router bgp 200                      
 bgp log-neighbor-changes                              
 neighbor 202.1.1.2 remote-as 200                      
 neighbor 202.1.1.2 update-source Loopback0                               
 neighbor 202.1.1.6 remote-as 400                      
 neighbor 202.1.1.6 ebgp-multihop 10                   
 neighbor 202.1.1.6 update-source Loopback0                               
 !               
 address-family ipv4                
 redistribute connected                                
 neighbor 202.1.1.2 activate                           
 neighbor 202.1.1.2 send-label                         
 no neighbor 202.1.1.6 activate                        
 no auto-summary                    
 no synchronization                 
 exit-address-family                
 !               
 address-family ***v4               
 neighbor 202.1.1.6 activate                           
 neighbor 202.1.1.6 send-community extended                                
 exit-address-family                
 !               
 address-family ipv4 vrf vrf30                         
 redistribute connected                                
 no synchronization                 
 exit-address-family                
 !                
 address-family ipv4 vrf vrf20                         
 redistribute connected                                
 no synchronization                 
 exit-address-family                
 !               
 address-family ipv4 vrf vrf10                          
 no synchronization                 
 exit-address-family                
!                
end  
 
[R2]
R2#show run      
!                
version 12.4     
!                
hostname R2      
!                
ip cef            
!                
interface Loopback0                 
 ip address 202.1.1.2 255.255.255.255                  
!                
interface Ethernet4/0               
 ip address 80.1.2.2 255.255.255.0                     
 duplex full     
 mpls ip         
!                
interface Ethernet4/1               
 ip address 80.2.3.1 255.255.255.0                     
 duplex full     
!                
router ospf 1                       
 log-adjacency-changes              
 network 80.1.2.0 0.0.0 .255 area 0                     
 network 202.1.1.2 0.0.0 .0 area 0                      
!                
router bgp 200                      
 no synchronization                 
 no bgp default route-target filter                     
 bgp log-neighbor-changes           
 redistribute connected             
 redistribute ospf 1                
 neighbor 80.2.3.2 remote-as 300    
 neighbor 80.2.3.2 route-map atol out                  
 neighbor 80.2.3.2 send-label       
 neighbor 202.1.1.1 remote-as 200                      
 neighbor 202.1.1.1 update-source Loopback0            
 neighbor 202.1.1.1 next-hop-self                      
 neighbor 202.1.1.1 route-map ltol out                 
 neighbor 202.1.1.1 send-label       
 no auto-summary                    
!                
route-map atol permit 10            
 set mpls-label                     
!                
route-map ltol permit 10            
 match mpls-label                   
 set mpls-label                      
end        
 
[R3]
R3#show run      
!                
version 12.4     
!                
hostname R3      
!                
ip cef           
!                
interface Loopback0                 
 ip address 202.1.1.3 255.255.255.255                  
!                
interface Ethernet4/1               
 ip address 80.2.3.2 255.255.255.0                     
 duplex full     
!                
interface Ethernet4/2               
 ip address 80.3.4.1 255.255.255.0                      
 duplex half     
!                
router bgp 300                      
 no synchronization                 
 no bgp default route-target filter                    
 bgp log-neighbor-changes           
 neighbor 80.2.3.1 remote-as 200     
 neighbor 80.2.3.1 route-map atol out                  
 neighbor 80.2.3.1 send-label       
 neighbor 80.3.4.2 remote-as 400    
 neighbor 80.3.4.2 route-map atol out                  
 neighbor 80.3.4.2 send-label       
 no auto-summary                     
!                
route-map atol permit 10            
 set mpls-label                     
!                
end              
            
 [R4]
R4#show run      
!                
version 12.4     
!                
hostname R4       
!                
ip cef           
!                
interface Loopback0                 
 ip address 202.1.1.4 255.255.255.255                  
!                
interface Ethernet4/2               
 ip address 80.3.4.2 255.255.255.0                      
 duplex half     
!                
interface Ethernet4/3               
 ip address 80.4.5.1 255.255.255.0                     
 duplex half     
 mpls ip         
!                
router ospf 1                       
 log-adjacency-changes              
 network 80.4.5.0 0.0.0 .255 area 0                     
 network 202.1.1.4 0.0.0 .0 area 0                      
!                
router bgp 400                      
 no synchronization                 
 no bgp default route-target filter                    
 bgp log-neighbor-changes           
 redistribute connected             
 redistribute ospf 1                
 neighbor 80.3.4.1 remote-as 300    
 neighbor 80.3.4.1 route-map atol out                  
 neighbor 80.3.4.1 send-label       
 neighbor 202.1.1.6 remote-as 400                      
 neighbor 202.1.1.6 update-source Loopback0            
 neighbor 202.1.1.6 next-hop-self                      
 neighbor 202.1.1.6 route-map ltol out                 
 neighbor 202.1.1.6 send-label      
 no auto-summary                    
!                
route-map atol permit 10            
 set mpls-label                     
!                
route-map ltol permit 10            
 match mpls-label                    
 set mpls-label                     
!                
end          
 
[R5]
R5#show run
!          
version 12.4                   
!          
hostname R5
!          
ip cef     
!          
interface Loopback0            
 ip address 202.1.1.5 255.255.255.255              
!          
interface Ethernet4/0          
 ip address 80.5.6.1 255.255.255.0                 
 duplex half                   
 mpls ip   
!          
interface Ethernet4/3          
 ip address 80.4.5.2 255.255.255.0                 
 duplex half                   
 mpls ip   
!          
router ospf 1                  
 log-adjacency-changes         
 network 80.4.5.0 0.0.0 .255 area 0                 
 network 80.5.6.0 0.0.0 .255 area 0                  
 network 202.1.1.5 0.0.0 .0 area 0                  
!          
end        
 
[R6]
R6#show run      
!                
version 12.4     
!                
hostname R6      
!                
ip cef           
!                
ip vrf vrf10     
 rd 100:10       
 route-target export 100:10         
 route-target import 100:10         
!                
ip vrf vrf20     
 rd 100:20       
 route-target export 100:20         
 route-target import 100:20         
!                
ip vrf vrf30     
 rd 100:30       
 route-target export 100:30         
 route-target import 100:30         
!                
interface Loopback0                 
 ip address 202.1.1.6 255.255.255.255                  
!                
interface FastEthernet0/0           
 no ip address                      
 shutdown        
 duplex half     
!                
interface Ethernet4/0               
 ip address 80.5.6.2 255.255.255.0                     
 duplex half     
 mpls ip         
!                
interface Ethernet4/6               
 ip vrf forwarding vrf20            
 ip address 60.0.20.1 255.255.255.0                     
 duplex half     
!                
interface Ethernet4/7               
 ip vrf forwarding vrf30            
 ip address 60.0.30.1 255.255.255.0                    
 duplex half     
!                
router ospf 1                        
 log-adjacency-changes              
 network 80.5.6.0 0.0.0 .255 area 0                     
 network 202.1.1.6 0.0.0 .0 area 0                      
!                
router bgp 400                      
 bgp log-neighbor-changes            
 neighbor 202.1.1.1 remote-as 200                      
 neighbor 202.1.1.1 ebgp-multihop 10                   
 neighbor 202.1.1.1 update-source Loopback0            
 neighbor 202.1.1.4 remote-as 400                      
 neighbor 202.1.1.4 update-source Loopback0            
 !               
 address-family ipv4                
 redistribute connected             
 no neighbor 202.1.1.1 activate     
 neighbor 202.1.1.4 activate        
 neighbor 202.1.1.4 send-label      
 no auto-summary                    
 no synchronization                 
 exit-address-family                
 !               
 address-family ***v4               
 neighbor 202.1.1.1 activate        
 neighbor 202.1.1.1 send-community extended            
 exit-address-family                
 !               
 address-family ipv4 vrf vrf30      
 redistribute connected             
 no synchronization                 
 exit-address-family                
 !               
 address-family ipv4 vrf vrf20       
 redistribute connected             
 no synchronization                 
 exit-address-family                
 !               
 address-family ipv4 vrf vrf10      
 redistribute connected             
 no synchronization                 
 exit-address-family                
!                
end            
 
 
根据朋友的提醒,在此增加从R6到R1的私网路由trace信息,可以清楚的看到沿途标签信息的变化:
R6#traceroute vrf vrf30
Protocol [ip]:   
Target IP address: 10.0.30.1 
Source address: 60.0.30.1    
Numeric display [n]:   
Resolve AS number in (G)lobal table, (V)RF or(N)one [G]:   
Timeout in seconds [3]:
Probe count [3]: 
Minimum Time to Live [1]:    
Maximum Time to Live [30]:   
Port Number [33434]:   
Loose, Strict, Record, Timestamp, Verbose[none]:
Type escape sequence to abort.
Tracing the route to 10.0.30.1
  1 80.5.6.1 [MPLS: Labels 16/20/18 Exp 0] 300 msec 456 msec 384 msec  
  2 80.4.5.1 [MPLS: Labels 20/18 Exp 0] 320 msec 336 msec 312 msec
  3 80.3.4.1 [MPLS: Labels 24/18 Exp 0] 280 msec 280 msec 328 msec
  4 80.2.3.1 [AS 200] [MPLS: Labels 17/18 Exp 0] 300 msec 264 msec 480 msec  
  5 10.0.30.1 376 msec 388 msec 580 msec