Cisco三层×××流量导入TE隧道转发
 
Maa nj 2007-12-31 
 
『一点祝福』
2007年终于走到了最后一天,在这之前,从没想到过自己会只身来到南京,来到这个陌生的异地,或许因缘际会吧,只为认识你,或许有一天自己终将离开,或许这一天会很快,但是在以后自己所有的日子里,我都会默默的为你祝福,得到属于自己的幸福。
 
最近做了一个MPLS网络的项目,其中一些总结,想写出来分享一下。
 
该网络的核心部署MPLS TE和三层×××,其中三层×××的私网流量通过MPLS TE隧道进行转发,由于MPLS TE隧道具有资源预留和带宽保证等优势,能够为私网流量转发提供比较好的质量保证,通过TE隧道支持FRR快速重路由切换,当核心网络链路或者节点失效发生时,通过TE FRR切换,可以达到50ms级的流量快速倒换,最大限度的保证核心网络的流量转发。
 
正因为如此,才由MPLS TE隧道代替了平常三层×××中的LDP,作为私网流量在公网转发的通道,所以在整个核心网络的部署中,是不需要部署LDP的。三层×××的配置和TE的基本配置都很普遍了,因此不是要提到的重点,本文要提的重点,是私网流量引入TE隧道的方式以及对该方式的理解。
 
 
  Cisco三层×××流量导入TE隧道转发_第1张图片
 
 
如图所示,R1R2R3上均部署MPLS TER1R3作为PE设备部署三层×××IGP路由协议采用OSPF。在部署好之后,我们可以在两个PE上看到对应的私网路由信息,如下:
 
R1#show ip route vrf ***1                                                                                                           
                                                                                                                                   
Routing Table: ***1                                                                                                                 
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP                                                                     
       D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area                                                              
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2                                                              
       E1 - OSPF external type 1, E2 - OSPF external type 2                                                                        
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2                                                        
       ia - IS-IS inter area, * - candidate default, U - per-user static route                                                     
       o - ODR, P - periodic downloaded static route                                                                                
                                                                                                                                   
Gateway of last resort is not set                                                                                                   
                                                                                                                                   
     13.0.0 .0/24 is subnetted, 1 subnets                                                                                            
C       13.1.2 .0 is directly connected, Ethernet4/7                                                                                
     31.0.0.0/24 is subnetted, 1 subnets                                                                                            
B       31.1.2.0 [200/0] via 202.1.1.3, 01:54:45                  
 
 
R3#show ip route vrf ***1                                                                                                          
                                                                                                                                    
Routing Table: ***1                                                                                                                 
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP                                                                     
       D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area                                                               
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2                                                              
       E1 - OSPF external type 1, E2 - OSPF external type 2                                                                         
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2                                                       
       ia - IS-IS inter area, * - candidate default, U - per-user static route                                                      
       o - ODR, P - periodic downloaded static route                                                                               
                                                                                                                                    
Gateway of last resort is not set                                                                                                  
                                                                                                                                    
     13.0.0 .0/24 is subnetted, 1 subnets                                                                                           
B       13.1.2 .0 [200/0] via 202.1.1.1, 01:56:41                                                                                    
     31.0.0.0/24 is subnetted, 1 subnets                                                                                           
C       31.1.2.0 is directly connected, Ethernet4/7                                                                                 
R3#                            
 
可以看出这时私网路由都指向了对端PEBGP建链的loopback地址,但是只是有了私网路由,在转发层面上还是不可能通的,因为这个时候私网标签是不能指导公网转发的,但是又必须保证私网标签在到达对端PE之前不会被错误的剥掉,这时就需要公网标签封装在私网标签之外,完成在公网这一段的数据报文转发,以前是LDP的标签,那么现在没有LDP,自然就是TE的标签了,其实这个时候,回想一下,私网流量的转发原理无非就是如此了,不管你外层需要嵌套多少层标签,也只是为了保证BGP分配的私网标签能够正确的被携带到对端PE
 
那么这个时候,需要做的只是在两端PE上配置一条到对端PE BGP建立地址的静态路由指向TE隧道。为什么这样做呢,让我再连贯起来说上一下就清楚了。比如,我在R1上查看到R3上私网地址31.1.2.0/24的路由下一跳是指向202.1.1.3的,这个时候给数据封装一层私网标签;但是202.1.1.3这个地址并不是R1的地址,会继续查路由表,查到下一跳为TE隧道,而该TE隧道是本地的直连接口,于是再封装一层TE隧道的出标签作为公网标签进行转发。这里其实是一个路由迭代的问题,在迭代的过程中也确定了内层标签和外层标签的位置,而这个时候有了公网标签,私网流量自然也能通过TE隧道进行转发了。
 
在本文中,配置静态路由就是一种将私网流量引入TE隧道转发的方式;同样的,如果TE隧道支持自动路由,那么通过自动路由的方式也是可以将私网流量引入TE隧道转发的。其实,不论是静态路由还是自动路由,其本质是将BGP的建链地址发布到路由表中,然后通过路由迭代将私网流量引进隧道。
 
但是这样的方式,目前看来只是一个实现,因为这样还是有很大局限的,因为所有不同的×××都会通过同一个TE隧道进行转发,同一隧道对于所有的×××提供的都是相同的服务质量和带宽资源。还有其他的方式,比如在vrf下面指定该vrf流量选择的TE隧道,这样就可以根据不同的×××选择不同的TE隧道转发,还有就是根据策略路由指定不同的×××进入合适的TE隧道等等,由于局限于目前手上的版本,因此只能做这样最简单的实现,但是这里提到这些是希望提醒大家,不要因为我的讲述而限制了大家的思维。
 
后面是我得一个简单配置,提供给有兴趣的朋友做参考。
 
R1配置』
R1#show run
Building configuration... 
Current configuration : 2071 bytes 
! 
version 12.4
! 
hostname R1
! 
ip vrf ***1
 rd 100:1
 route-target export 100:1
 route-target import 100:1
! 
! 
mpls traffic-eng tunnels
! 
interface Tunnel1
 ip unnumbered Loopback1
 tunnel destination 202.1.1.3
 tunnel mode mpls traffic-eng
 tunnel mpls traffic-eng path-option 16 dynamic
 no routing dynamic 
! 
interface Loopback1 
 ip address 202.1.1.1 255.255.255.255 
! 
interface Ethernet4/0
 ip address 80.1.2.1 255.255.255.0 
 duplex half
 mpls traffic-eng tunnels 
! 
interface Ethernet4/7
 ip vrf forwarding ***1
 ip address 13.1.2 .1 255.255.255.0 
 duplex half
! 
router ospf 1 
 mpls traffic-eng router-id Loopback1 
 mpls traffic-eng area 0
 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 100
 no synchronization 
 bgp log-neighbor-changes 
 neighbor 202.1.1.3 remote-as 100
 neighbor 202.1.1.3 update-source Loopback1 
 no auto-summary 
 !
 address-family ***v4
 neighbor 202.1.1.3 activate 
 neighbor 202.1.1.3 send-community extended 
 exit-address-family
 !
 address-family ipv4 vrf ***1
 redistribute connected
 no synchronization 
 exit-address-family
! 
ip route 202.1.1.3 255.255.255.255 Tunnel1
 
R2配置』
R2#show run
Building configuration... 
Current configuration : 1369 bytes 
! 
version 12.4
! 
hostname R2
! 
mpls traffic-eng tunnels
! 
interface Loopback1 
 ip address 202.1.1.2 255.255.255.255 
! 
interface Ethernet4/0
 ip address 80.1.2.2 255.255.255.0 
 duplex half
 mpls traffic-eng tunnels 
! 
interface Ethernet4/1
 ip address 80.2.3.1 255.255.255.0 
 duplex half
 mpls traffic-eng tunnels 
! 
router ospf 1 
 mpls traffic-eng router-id Loopback1 
 mpls traffic-eng area 0
 log-adjacency-changes 
 network 80.1.2.0 0.0.0 .255 area 0 
 network 80.2.3.0 0.0.0 .255 area 0 
R3配置』
R3#show run                                                                                                                        
Building configuration...                                                                                                           
Current configuration : 2045 bytes                                                                                                 
!                                                                                                                                   
version 12.4                                                                                                                       
!                                                                                                                                   
hostname R3                                                                                                                        
!                                                                                                                                   
ip vrf ***1                                                                                                                        
 rd 100:1                                                                                                                           
 route-target export 100:1                                                                                                         
 route-target import 100:1                                                                                                         
!                                                                                                                                  
!                                                                                                                                  
mpls traffic-eng tunnels                                                                                                            
!                                                                                                                                  
interface Tunnel1                                                                                                                   
 ip unnumbered Loopback1                                                                                                           
 tunnel destination 202.1.1.1                                                                                                       
 tunnel mode mpls traffic-eng                                                                                                      
 tunnel mpls traffic-eng path-option 16 dynamic                                                                                     
 no routing dynamic                                                                                                                
!                                                                                                                                   
interface Loopback1                                                                                                                
 ip address 202.1.1.3 255.255.255.255                                                                                               
!                                                                                                                                  
interface Ethernet4/1                                                                                                               
 ip address 80.2.3.2 255.255.255.0                                                                                                 
 duplex half                                                                                                                        
 mpls traffic-eng tunnels                                                                                                          
!                                                                                                                                   
interface Ethernet4/7                                                                                                              
 ip vrf forwarding ***1                                                                                                             
 ip address 31.1.2.1 255.255.255.0                                                                                                 
 duplex half                                                                                                                        
!                                                                                                                                  
router ospf 1                                                                                                                       
 mpls traffic-eng router-id Loopback1                                                                                              
 mpls traffic-eng area 0                                                                                                           
 log-adjacency-changes                                                                                                              
 network 80.2.3.0 0.0.0 .255 area 0                                                                                                 
 network 202.1.1.3 0.0.0 .0 area 0                                                                                                   
!                                                                                                                                  
router bgp 100                                                                                                                      
 no synchronization                                                                                                                
 bgp log-neighbor-changes                                                                                                           
 neighbor 202.1.1.1 remote-as 100                                                                                                  
 neighbor 202.1.1.1 update-source Loopback1                                                                                         
 no auto-summary                                                                                                                   
 !                                                                                                                                  
 address-family ***v4                                                                                                              
 neighbor 202.1.1.1 activate                                                                                                        
 neighbor 202.1.1.1 send-community extended                                                                                        
 exit-address-family                                                                                                                
 !                                                                                                                                 
 address-family ipv4 vrf ***1                                                                                                       
 redistribute connected                                                                                                            
 no synchronization                                                                                                                 
 exit-address-family                                                                                                               
!                                                                                                                                   
ip route 202.1.1.1 255.255.255.255 Tunnel1                                                                                         
 
R1上显示隧道1的出标签』
R1#show mpls traffic-eng tunnels tunnel 1                                                                                          
                                                                                                                                    
Name: R1_t1                               (Tunnel1) Destination: 202.1.1.3                                                         
  Status:                                                                                                                           
    Admin: up         Oper: up     Path: valid       Signalling: connected                                                         
                                                                                                                                    
    path option 16, type dynamic (Basis for Setup, path weight 20)                                                                 
                                                                                                                                    
  Config Parameters:                                                                                                               
    Bandwidth: 0        kbps (Global)  Priority: 7  7   Affinity: 0x0/0xFFFF                                                        
    Metric Type: TE (default)                                                                                                      
    AutoRoute:  disabled  LockDown: disabled  Loadshare: 0        bw-based                                                         
    auto-bw: disabled                                                                                                              
                                                                                                                                    
  InLabel  :  -                                                                                                                    
  OutLabel : Ethernet4/0, 16                                                                                                        
  RSVP Signalling Info:                                                                                                            
       Src 202.1.1.1, Dst 202.1.1.3, Tun_Id 1, Tun_Instance 11                                                                     
    RSVP Path Info:                                                                                                                
      My Address: 80.1.2.1                                                                                                          
      Explicit Route: 80.1.2.2 80.2.3.1 80.2.3.2 202.1.1.3                                                                         
      Record Route:  NONE                                                                                                          
      Tspec: ave rate=0 kbits, burst=1000 bytes, peak rate=0 kbits                                                                 
    RSVP Resv Info:                                                                                                                
      Record Route:  NONE                                                                                                          
      Fspec: ave rate=0 kbits, burst=1000 bytes, peak rate=0 kbits                                                                 
  Shortest Unconstrained Path Info:                                                                                                
    Path Weight: 20 (TE)                                                                                                            
    Explicit Route: 80.1.2.1 80.1.2.2 80.2.3.1 80.2.3.2                                                                            
                    202.1.1.3                                                                                                       
  History:                                                                                                                         
    Tunnel:                                                                                                                         
      Time since created: 3 hours, 41 minutes                                                                                      
      Time since path change: 3 hours, 39 minutes                                                                                   
    Current LSP:                                                                                                                   
      Uptime: 3 hours, 39 minutes                                                                                                   
R1#                  
 
R1上显示私网标签』
R1#show bgp ***v4 unicast vrf ***1 labels                                                                                          
   Network          Next Hop      In label/Out label                                                                                
Route Distinguisher: 100:1 (***1)                                                                                                  
   13.1.2 .0/24      0.0.0 .0         18/aggregate(***1)                                                                              
   31.1.2.0/24      202.1.1.3       nolabel/18         
 
『两层嵌套标签』
 Cisco三层×××流量导入TE隧道转发_第2张图片