实验拓扑:



CCIELAB之MPLS_×××_第1张图片



第一步:建立VRF

 

R2/R4:

 

ip vrf ***                         命名vrf为“***”
rd 100:1                           设置RD
route-target export 100:1设置出口路由标记
route-target import 100:1设置入口路由标记     注:一端的出口标记和对端的入口标记需一致!

 

 

第二步:将CE接口设置成vrf转发
 

R2:
interface FastEthernet0/1
ip vrf forwarding ***
ip address 12.1.1.2 255.255.255.0

 

 
R4:
interface FastEthernet0/0
ip vrf forwarding ***
ip address 45.1.1.4 255.255.255.0


 

注意:在配置完 “ ip vrf forwarding ***”后,接口上原先配置的ip地址会消失,需重新配置。

 


第三步:配置mpls域的igp
 

R2:
router eigrp 10
network 2.2.2.2 0.0.0.0
network 23.1.1.2 0.0.0.0
no auto-summary
eigrp router-id 2.2.2.2

 

 


R3:

router eigrp 10
network 3.3.3.3 0.0.0.0
network 23.1.1.3 0.0.0.0
network 34.1.1.3 0.0.0.0
no auto-summary
eigrp router-id 3.3.3.3
!

 

 

R4:

router eigrp 10
network 4.4.4.4 0.0.0.0
network 34.1.1.4 0.0.0.0
no auto-summary
eigrp router-id 4.4.4.4

配置IGP的目的是为了是mpls域内路由互通,为配置MP-BGP做准备

 



第四步:配置mpbgp:
 

R2:

router bgp 100
bgp router-id 2.2.2.2
no bgp default ipv4-unicast
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
!
address-family ***v4                                  配置***v4地址簇,与p路由器建立***v4邻居
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community both      配置扩展团体属性的发送包括了route-tag,***标签等信息
exit-address-family
!
address-family ipv4 vrf ***                         配置vrf地址簇,将CE点的路由协议重分发进mpbgp
redistribute eigrp 100
no synchronization
exit-address-family

 

R3:

router bgp 100
bgp router-id 3.3.3.3
no bgp default ipv4-unicast
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback0
neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 update-source Loopback0
!
address-family ***v4                                  配置***v4邻居的反射,解决iGP水平分割问题,也可以不配反射,以R2-4建立全互联邻居关系代替 
neighbor 2.2.2.2 activate
neighbor 2.2.2.2 send-community both
neighbor 2.2.2.2 route-reflector-client
neighbor 4.4.4.4 activate
neighbor 4.4.4.4 send-community both
neighbor 4.4.4.4 route-reflector-client
exit-address-family

 

 

R4:

router bgp 100
bgp router-id 4.4.4.4
no bgp default ipv4-unicast
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
!
address-family ***v4
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community both
exit-address-family
!
address-family ipv4 vrf ***
redistribute ospf 1 vrf *** match internal external 1 external 2   重分发ospf时注意匹配范围(inter or external)
no synchronization
exit-address-family

 



第五步:配置site端的路由
 

site1:
R2:
 
router eigrp 100
no auto-summary
!
address-family ipv4 vrf ***                                      指定vrf地址簇的配置
redistribute bgp 100 metric 10000 100 255 1 1500   将mpbgp路由重                                                                                             分发进CE端
network 12.1.1.2 0.0.0.0
no auto-summary
autonomous-system 100                                       通告自治系统号(
必须配置!)
exit-address-family
!

 

 

R1:

router eigrp 100
network 1.1.1.1 0.0.0.0
network 12.1.1.1 0.0.0.0
no auto-summary
eigrp router-id 1.1.1.1
!

 

 


site2:

 R4:

router ospf 1 vrf ***                                      ospf不能在进程下配置ipv4vrf地址簇,需在起进程时配置!
router-id 4.4.4.4
log-adjacency-changes
redistribute bgp 100 metric-type 1 subnets  将mpbgp路由充分发进ce端
network 45.1.1.4 0.0.0.0 area 0

R5:

 

router ospf 1
router-id 5.5.5.5
log-adjacency-changes
network 5.5.5.5 0.0.0.0 area 0
network 45.1.1.5 0.0.0.0 area 0
!

 


第六步:配置mpls转发
R2/R3/R4
全局:
ip cef                                 开启cef转发,一定要配置!!

mpls label range x00 x99                    指定本地标签的分配范围,以便于管理,  也可由系统自动分配
mpls label protocol ldp                        cisco路由器默认标签分配协议为tdp,这里改为ldp协议
mpls ip                                                使路由器支持mpls 转发  默认已配置
mpls ldp router-id Loopback0 force     设置标签分配的源端口

 

接口下(PE和p端的接口)

 

mpls ip                                                 在接口上启用mpls

 




现象:
1.查看R1的路由表:

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     5.0.0.0/32 is subnetted, 1 subnets
D EX    5.5.5.5 [170/307200] via 12.1.1.2, 01:09:39, FastEthernet0/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/1
     45.0.0.0/24 is subnetted, 1 subnets
D EX    45.1.1.0 [170/307200] via 12.1.1.2, 01:09:39, FastEthernet0/1

查看R5的路由表:


Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
O E1    1.1.1.1 [110/409610] via 45.1.1.4, 01:10:11, FastEthernet0/0
     5.0.0.0/32 is subnetted, 1 subnets
C       5.5.5.5 is directly connected, Loopback0
     12.0.0.0/24 is subnetted, 1 subnets
O E1    12.1.1.0 [110/11] via 45.1.1.4, 01:10:10, FastEthernet0/0
     45.0.0.0/24 is subnetted, 1 subnets
C       45.1.1.0 is directly connected, FastEthernet0/0


查看R2的vrf路由表:
show ip vrf *** route :

     1.0.0.0/32 is subnetted, 1 subnets
D       1.1.1.1 [90/409600] via 12.1.1.1, 01:14:33, FastEthernet0/1
     5.0.0.0/32 is subnetted, 1 subnets
B       5.5.5.5 [200/11] via 4.4.4.4, 01:13:04
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/1
     45.0.0.0/24 is subnetted, 1 subnets
B       45.1.1.0 [200/0] via 4.4.4.4, 01:13:04


R2的bgp ***v4表:

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

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 100:1 (default for vrf ***)
*> 1.1.1.1/32       12.1.1.1            409600         32768 ?
*>i5.5.5.5/32       4.4.4.4                 11    100      0 ?
*> 12.1.1.0/24      0.0.0.0                  0         32768 ?
*>i45.1.1.0/24      4.4.4.4                  0    100      0 ?

R2的mpls转发表
R2#sh mpls forwarding-table
Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop
tag    tag or VC   or Tunnel Id      switched   interface
200    Pop tag     3.3.3.3/32        0          Fa0/0      23.1.1.3
201    Pop tag     34.1.1.0/24       0          Fa0/0      23.1.1.3
203    Untagged    1.1.1.1/32[V]     0          Fa0/1      12.1.1.1
204    Aggregate   12.1.1.0/24[V]    1164
205    302         4.4.4.4/32        0          Fa0/0      23.1.1.3


R3(p路由器)的***v4 bgp表:
R3#sh ip bgp ***v4 all

BGP table version is 5, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 100:1
*>i1.1.1.1/32       2.2.2.2             409600    100      0 ?
*>i5.5.5.5/32       4.4.4.4                 11    100      0 ?
*>i12.1.1.0/24      2.2.2.2                  0    100      0 ?
*>i45.1.1.0/24      4.4.4.4                  0    100      0 ?

R4的各表略




R4前往R1:

R4#traceroute vrf *** 1.1.1.1

Type escape sequence to abort.
Tracing the route to 1.1.1.1

  1 34.1.1.3 [MPLS: Labels 300/203 Exp 0] 132 msec 180 msec 188 msec
  2 12.1.1.2 [MPLS: Label 203 Exp 0] 100 msec 112 msec 84 msec
  3 12.1.1.1 128 msec *  124 msec


可以看到,从R2发出的包带有双层标签 内层为203 外层为300;其中203为R2为1.1.1.1的路由分配的***v4标签,300为R3分配的普通mpls标签 而当报文到达R3时,因为“次末跳弹出机制(PHP)”报文将弹出上层标签(普通mpls标签300),到达R2后就剩下了***v4标签(203),此时再根据***v4标签查找标签转发表 发现出口无标签,于是直接以ip报文形式传给了R1


(可能是因为模拟器的缘故,在R5上tracertR1时,返回的信息没有标签信息,但是debug可以看到是通过标签转发的)