r1#show run
 ip cef
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.0
!
interface e1/1
 no sh
 ip address 192.168.1.1 255.255.255.0
 !
router rip
 network 1.0.0.0
 network 192.168.1.0
!
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r2#show run
 
hostname r2
!
ip vrf comA
 rd 100:200
 route-target export 100:2000
 route-target import 100:2000
!
ip vrf comB
 rd 200:400
 route-target export 200:4000
 route-target import 200:4000
!
ip cef
!
!        
interface Loopback0
 ip address 2.2.2.2 255.255.255.0
 ip router isis
!
interface e1/0
 ip address 23.1.1.2 255.255.255.0
 ip router isis
 tag-switching ip
 no sh
!
interface e1/1
 ip vrf forwarding comA
 ip address 192.168.1.2 255.255.255.0
 no sh
!
interface e1/2
 ip vrf forwarding comB
 ip address 192.168.1.2 255.255.255.0
 no sh
!
router isis
 net 49.0001.0000.0000.0002.00
!
router rip
 !
 address-family ipv4 vrf comB
 redistribute bgp 100 metric 2
 network 192.168.1.0
 no auto-summary
 exit-address-family
 !
 address-family ipv4 vrf comA
 redistribute bgp 100 metric 1
 network 192.168.1.0
 no auto-summary
 exit-address-family
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 4.4.4.4 remote-as 100
 neighbor 4.4.4.4 update-source Loopback0
 no auto-summary
 !
 address-family ***v4
 neighbor 4.4.4.4 activate
 neighbor 4.4.4.4 send-community both
 exit-address-family
 !
 address-family ipv4 vrf comB
 redistribute rip
 no auto-summary
 no synchronization
 exit-address-family
 !
 address-family ipv4 vrf comA
 redistribute rip
 no auto-summary
 no synchronization
 exit-address-family
!
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r3#show run
ip cef

interface e1/0
 ip address 23.1.1.3 255.255.255.0
 ip router isis
 tag-switching ip
 no sh
!
interface e1/1
 ip address 34.1.1.3 255.255.255.0
 ip router isis
 tag-switching ip
 no sh
!
router isis
 net 49.0001.0000.0000.0003.00
!
!        
end
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r4#show run
Building configuration...
!
hostname r4
!
!
ip vrf comA
 rd 100:200
 route-target export 100:2000
 route-target import 100:2000
!
ip vrf comB
 rd 200:200
 route-target export 200:4000
 route-target import 200:4000
!
ip cef
!
!   
interface Loopback0
 ip address 4.4.4.4 255.255.255.0
 ip router isis
!
interface e1/0
 ip address 34.1.1.4 255.255.255.0
 ip router isis
 tag-switching ip
 no sh
!
interface e1/1
 ip vrf forwarding comA
 ip address 192.168.2.2 255.255.255.0
 no sh
!
interface e1/2
 ip vrf forwarding comB
 ip address 192.168.2.2 255.255.255.0
 no sh
!
router isis
 net 49.0001.0000.0000.0004.00
!
router rip
 !
 address-family ipv4 vrf comB
 redistribute bgp 100 metric 2
 network 192.168.2.0
 no auto-summary
 exit-address-family
 !
 address-family ipv4 vrf comA
 redistribute bgp 100 metric 1
 network 192.168.2.0
 no auto-summary
 exit-address-family
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 100
 neighbor 2.2.2.2 update-source Loopback0
 no auto-summary
 !
 address-family ***v4
 neighbor 2.2.2.2 activate
 neighbor 2.2.2.2 send-community both
 exit-address-family
 !
 address-family ipv4 vrf comB
 redistribute rip
 no auto-summary
 no synchronization
 exit-address-family
 !
 address-family ipv4 vrf comA
 redistribute rip
 no auto-summary
 no synchronization
 exit-address-family
!
!
end
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r5#show run
Building configuration...
hostname r5
!
!
ip cef
!
!  
interface Loopback0
 ip address 5.5.5.5 255.255.255.0
!
interface e1/1
 ip address 192.168.2.1 255.255.255.0
 no sh
!
router rip
 network 5.0.0.0
 network 192.168.2.0
!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r6#show run
ip cef
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.0
!
interface e1/1
 ip address 192.168.1.1 255.255.255.0
 no sh
!
router rip
 network 1.0.0.0
 network 192.168.1.0
!
 end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r7#show run
ip cef
!
interface Loopback0
 ip address 5.5.5.5 255.255.255.0
!
interface e1/1
 ip address 192.168.2.1 255.255.255.0
 no sh
!
router rip
 network 5.0.0.0
 network 192.168.2.0
!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
配置步骤:
 
运营商骨干网准备工作
首先说说运营商骨干网准备工作,配置主要分以下几个部分:
1、在PE和P上配置IGP,使骨干网连通。
2、在PE和P上配置MPLS,启动标签交换。
1、在PE和P上配置IGP。
在此选择EIGRP/OSPF/RIP/ISIS中任意一款路由协议均可,此例中使用ISIS。
 
2、在PE和P上配置MPLS
R2(config)# interface
R2(config-if)# mpls ip
R3(config)# interface
R3(config-if)# mpls ip
R3(config)# interface
R3(config-if)# mpls ip
R4(config)# interface
R4(config-if)# mpls ip
骨干网准备工作配置完毕!
客户端(CE)配置
接着来谈谈CE的配置,CE需要将客户的网络接入运营商,同时将自己的路由通告给PE,然后由PE通过骨干网将路由通告给该客户的其他CE。
在此例中,有两个客户:Customer_A和Customer_B,在通过MPLS×××时,它们彼此的路由信息不会互相干扰。
CE和PE之间可以采用RIP/EIGRP/OSPF/静态路由等方式互相通告路由,CE上的配置也很简单,只需要按照以往一样启动路由协议就够了。例如:R1和R5之间运行RIPv2,那么R1的配置如下:
R1(config)# router rip
R1(config-router)# version 2
R1(config-router)# no auto-summary
R1(config-router)# nework 172.16.0.0
R1(config-router)# nework 10.0.0.0

PE的配置(CE与PE之间运行RIPv2)
PE的配置主要分为以下几个步骤:(以R3配置为例,R5配置不再敷述)
1、创建VRF。
2、在相应的将接口加入VRF。
3、配置与CE间的路由协议。
4、配置与其他PE之间的MP-BGP。
5、配置重发布。
1、创建VRF。
R2(config)# ip vrf comA
R2(config-vrf)# rd 1:27
R2(config-vrf)# route-target export 100:27
R2(config-vrf)# route-target import 100:27
       
R2(config)# ip vrf comB
R2(config-vrf)# rd 1:37
R2(config-vrf)# route-target export 100:37
R2(config-vrf)# route-target import 100:37
2、在相应的将接口加入VRF。
R2(config)# interface
R2(config-if)# ip vrf forwarding comA
R2(config)# interface
R2(config-if)# ip vrf forwarding comB
3、配置与CE间的路由协议。
R2(config)# router rip
R2(config-router)# version 2
                  network 192.168.1.0
!
R2(config-router)# address-family ipv4 vrf comB
R2(config-router-af)# network 192.168.1.0
R2(config-router-af)# no auto-summary
R2(config-router-af)# version 2
R2(config-router-af)# exit-address-family
!
R2(config-router)# address-family ipv4 vrf comA
R2(config-router-af)# network 192.168.1.0
R2(config-router-af)# no auto-summary
R2(config-router-af)# version 2
R2(config-router-af)# exit-address-family
此时可以使用show ip route vrf XXX查看虚拟路由表是否学习到客户的路由。
4、配置与R4之间的MP-BGP。
R2(config)# router bgp 100
R2(config-router)# no synchronization
R2(config-router)# neighbor 4.4.4.4 remote-as 100
R2(config-router)# neighbor 4.4.4.4 update-source Loopback0
R2(config-router)# no auto-summary
!
R2(config-router)# address-family ***v4
R2(config-router-af)# neighbor 4.4.4.4 activate
R2(config-router-af)# neighbor 4.4.4.4 send-community both
R2(config-router-af)# exit-address-family
!
R2(config-router)# address-family ipv4 vrf comB
R2(config-router-af)# no auto-summary
R2(config-router-af)# no synchronization
R2(config-router-af)# exit-address-family
!
R2(config-router)# address-family ipv4 vrf comA
R2(config-router-af)# no auto-summary
R2(config-router-af)# no synchronization
R2(config-router-af)# exit-address-family
5、配置重发布。
R2(config)# router rip
R2(config-router)# address-family ipv4 vrf comB
R2(config-router-af)# redistribute bgp 100 metric 5
!
R2(config-router)# address-family ipv4 vrf comA
R2(config-router-af)# redistribute bgp 100 metric 5
!
R2(config)# router bgp 100
R2(config-router)# address-family ipv4 vrf comB
R2(config-router-af)# redistribute rip
!
R2(config-router)# address-family ipv4 vrf comA
R2(config-router-af)# redistribute rip
所有配置完毕。

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
测试:
r1# SHOW IP RO
Gateway of last resort is not set
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
R    5.0.0.0/8 [120/1] via 192.168.1.2, 00:00:14, Serial1/1
C    192.168.1.0/24 is directly connected, Serial1/1
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:14, Serial1/1
r1#ping 192.168.2.1    !!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 288/344/432 ms

r2#traceroute vrf comA 192.168.2.1
Type escape sequence to abort.
Tracing the route to 192.168.2.1
  1 23.1.1.3 [MPLS: Labels 17/19 Exp 0] 112 msec 116 msec 120 msec
  2 192.168.2.2 120 msec 116 msec 120 msec
  3 192.168.2.1 192 msec *  168 msec
r2#traceroute vrf comB 192.168.2.1
Type escape sequence to abort.
Tracing the route to 192.168.2.1
  1 23.1.1.3 [MPLS: Labels 17/21 Exp 0] 100 msec 116 msec 120 msec
  2 192.168.2.2 120 msec 116 msec 120 msec
  3 192.168.2.1 192 msec *  288 msec

r2#show ip route
     34.0.0.0/24 is subnetted, 1 subnets
i L1    34.1.1.0 [115/20] via 23.1.1.3, Serial1/0
     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
     4.0.0.0/24 is subnetted, 1 subnets
i L1    4.4.4.0 [115/30] via 23.1.1.3, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/0
r2#show ip ro vrf comA
Gateway of last resort is not set
R    1.0.0.0/8 [120/1] via 192.168.1.1, 00:00:13, Serial1/1
B    5.0.0.0/8 [200/1] via 4.4.4.4, 00:03:25
C    192.168.1.0/24 is directly connected, Serial1/1
B    192.168.2.0/24 [200/0] via 4.4.4.4, 00:03:25
r2#show ip ro vrf comB
Routing Table: comB
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
R    1.0.0.0/8 [120/1] via 192.168.1.1, 00:00:18, Serial1/2
B    5.0.0.0/8 [200/1] via 4.4.4.4, 00:03:28
C    192.168.1.0/24 is directly connected, Serial1/2
B    192.168.2.0/24 [200/0] via 4.4.4.4, 00:03:28
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MPLS
MPLS分为两个独立的部件:
数据层面---转发部件—根据分组携带的标签执行数据分组转发工作
控制层面—控制部件—创建和维护标签转发信息
 
FIB 转发信息库也叫IP转发表
 
标签绑定交换的实现:
TDP   cisco专用的标记分发协议
LDP  ietf定的标签分发协议
 
术语:
LSR 标签交换路由器;每个LSR都保持了两个表:
 
在ciscoIOS中;
         TIB 标记信息库(包含该LSR分配的所有标签与标签间的映射)
TFIB 标记转发信息库 (保存MPLS转发部件当前使用的标签)
 
在MPLS术语中
         LIB 标签信息数据库
 LFIB 标签转发信息库  
 
FEC 转发等价类 ,一组以相同方式、通过相同路径、以相同的转发处理方式转发的IP分组
LSP 标签交换路径;是面向连接的;
LIB    标签信息库
 
测试命令
在每台路由器接口上启用tag-switching ip或mpls ip
Show ip cef 192.168.2.0
Show tag forwarding-table
Show tag forwarding-table tags 30 detail
r2#debug tag tdp transport events   可查看hello分组;
TDP会话运行在TCP 711端口
LDP会话运行在TCP 646端口
Show tag-switching tdp neighbor
r2#debug tag-switching tdp bindings
r2#show tag-switching tdp bindings 192.168.7.0 24
r2#show tag forwarding-table tags 16 – 19
 
7.故障诊断:
1.快速检测
Show ip cef summary   是否全局启用CEF
Show mpls forwarding-table MPLS是否被启用
Show mpls interfaces 是否在所有接口上启用了MPLS
 
2.MPLS控制层面的故障诊断
2.1核对TDP参数
r2#show tag-switching tdp parameters
Protocol version: 1
Downstream tag generic region: min tag: 16; max tag: 100000
Session hold time: 180 sec; keep alive interval: 60 sec
Discovery hello: holdtime: 15 sec; interval: 5 sec
Discovery directed hello: holdtime: 90 sec; interval: 10 sec
Downstream on Demand max hop count: 255
Downstream on Demand Path Vector Limit: 255
TDP for directed sessions
LDP initial/maximum backoff: 15/120 sec
LDP loop detection: off
2.2验证TDP问候协议是否正常运行
r2#show tag-switching tdp discovery
 Local TDP Identifier:
    172.16.1.4:0
    Discovery Sources:
    Interfaces:
        Ethernet1/0 (tdp): xmit/recv
            TDP Id: 172.16.2.1:0; no route
        Ethernet1/1 (tdp): xmit/recv
            TDP Id: 172.16.1.1:0; no route
        Ethernet1/2 (tdp): xmit/recv
            TDP Id: 172.16.1.2:0; no route
        Ethernet1/3 (tdp): xmit/recv
            TDP Id: 172.16.1.3:0; no route
2.3检测TDP/LDP会话
出现no route的情况下用sh tag-switching tdp neighbor命令并无输出显示
原因是双方邻居路由器的router-id 的地址不可达,将地router-id址加入到ospf中后显示正常
r2#sh tag-switching tdp neighbor
    Peer TDP Ident: 172.16.1.1:0; Local TDP Ident 172.16.1.4:0
        TCP connection: 172.16.1.1.711 - 172.16.1.4.54013
        State: Oper; PIEs sent/rcvd: 0/4; Downstream
        Up time: 00:00:25
        TDP discovery sources:
          Ethernet1/1, Src IP addr: 192.168.1.1
        Addresses bound to peer TDP Ident:
          192.168.1.1     172.16.1.1  
2.4检测标签交换情况
Show tag-switching tdp bindings
 
3.MPLS数据层面的故障诊断
3.1 监视接口级CEF
r2(config-if)#no ip route-cache cef 接口禁用CEF
r2#sh cef interface e1/1
Ethernet1/1 is up (if_number 4)
 Corresponding hwidb fast_if_number 4
 Corresponding hwidb firstsw->if_number 4
 Internet address is 192.168.1.2/24
 ICMP redirects are always sent
 Per packet load-sharing is disabled
 IP unicast RPF check is disabled
 Inbound access list is not set
 Outbound access list is not set
 IP policy routing is disabled
 BGP based policy accounting is disabled
 Hardware idb is Ethernet1/1
 Fast switching type 1, interface type 61
 IP CEF switching enabled
 
MPLS×××
第一步:定义并配置VRF
第二步:定义并配置路由区分符
第三步:定义并配置导入/导出策略
第四步:配置PE到CE的链路
第五步:将CE接口与前面定义的VRF关联起来
第六步:配置多协议BGP
 
第一步:定义并配置VRF
r2(config)#ip vrf fastfoods
 
 
第二步:定义并配置路由区分符
r2(config-vrf)#rd 100:26   100服务提供商ASN   26唯一性的值
r2#sh ip ro vrf fastfoods
第三步:定义并配置导入/导出策略
route-target export 100:26
 route-target import 100:26
第四步:配置PE到CE的链路
1.静态路由
r2(config)#ip route vrf fastfoods 192.168.6.0 255.255.255.0 192.168.5.2
2.RIPV2
第五步:将PE路由器中与CE相连的接口同前面定义的VRF关联起来
interface e1/2
 ip vrf forwarding fastfoods
 ip address 192.168.1.2 255.255.255.0
第六步:配置多协议BGP
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 请用支持MPLS的7200 IOS    unzip-c7200-js-mz.123-20