实验步骤:
Setp1:在mpls backbone中完成IGPospf1
Setp2:运行mplsbackbone
Setp3:配置vrfPE上,并且设置vrf×××客户RDRT
Setp4 为了让PE学习到CE的路由,所以应该在PECE之间运行动态路由协议(rip  static bgp  ospf
Setp5:建立mpibgp关系在R2R4之间
Setp6:将rip重分布进bgp中通过mpibgp传递(将路由从vrf中导出)
Setp7:再将mpibgp路由导入到所属于的vrf中,setp6setp7通过重分布来完成。
R1(config)#int s2/1
R1(config-if)#ip add <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />12.0.0.1 255.255.255.0
R1(config-if)#no shu
R1(config-if)#int lo0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#do ping 12.0.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.0.0.2, timeout is 2 seconds:
!!!!!
R1(config)#router rip
R1(config-router)#ver 2
R1(config-router)#no au
R1(config-router)#net 12.0.0.0
R1(config-router)#net 1.0.0.0
R1#sh ip route
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
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

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
     5.0.0.0/24 is subnetted, 1 subnets
R       5.5.5.0 [120/1] via 12.0.0.2, 00:00:10, Serial2/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1
     45.0.0.0/24 is subnetted, 1 subnets
R       45.0.0.0 [120/1] via 12.0.0.2, 00:00:10, Serial2/1
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#no router rip
R1(config)#ip route 0.0.0.0 0.0.0.0 s2/1
R1#sh ip route
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 0.0.0.0 to network 0.0.0.0
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1
S*   0.0.0.0/0 is directly connected, Serial2/1
R1#ping 5.5.5.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
!!!!!

 

 

R2(config)#int s2/1
R2(config-if)#ip add 12.0.0.2 255.255.255.0
R2(config-if)#no shu
R2(config-if)#int s2/2      
R2(config-if)#ip add 23.0.0.2 255.255.255.0
R2(config-if)#no shu
R2(config-if)#int lo0
R2(config-if)#ip add 2.2.2.2 255.255.255.255
Setp1R3R4一样

R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#net 23.0.0.0 0.0.0.255 a 0
R2(config-router)#net 2.2.2.2 0.0.0.0 a 0
Setp2

R2(config)#ip cef
R2(config)#mpls label range 200 299
R2(config)#mpls label protocol ldp
R2(config)#mpls ldp router-id lo0
R2(config)#int s2/2
R2(config-if)#mpls ip
Setp3

R2(config)#ip vrf ABC
R2(config-vrf)#rd 100:20
R2(config-vrf)#route-target export 100:20
R2(config-vrf)#int s2/1
R2(config-if)#ip vrf forwarding ABC
% Interface Serial2/1 IP address 12.0.0.2 removed due to enabling VRF ABC
R2(config-if)#ip add 12.0.0.2 255.255.255.0
R2(config-if)#do ping vrf ABC 12.0.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 72/82/120 ms
R2(config-if)#exit
Setp4

R2(config)#router rip
R2(config-router)#ver 2
R2(config-router)#no au
R2(config-router)#address-family ipv4 vrf ABC
R2(config-router-af)#ver 2
R2(config-router-af)#no au
R2(config-router-af)#net 12.0.0.0
R2(config-router-af)#do sh ip route vrf ABC
Routing Table: ABC
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
1.0.0.0/24 is subnetted, 1 subnets
R      1.1.1.0 [120/1] via 12.0.0.1, 00:00:17, Serial2/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1
Setp5

R2(config)#router bgp 234
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no au
R2(config-router)#no syn
R2(config-router)#nei 4.4.4.4 remote-as 234
R2(config-router)#nei 4.4.4.4 update-source lo0
R2(config-router)#no bgp default ipv4-unicast
R2(config-router)#address-family ***v4
R2(config-router-af)#nei 4.4.4.4 activate
Setp6

R2(config)#router bgp 234
R2(config-router)#address-family ipv4 vrf ABC
R2(config-router-af)#redistribute rip
Setp7

R2(config)#ip vrf ABC
R2(config-vrf)#route-target import 100:40
R2(config)#router rip
R2(config-router)#ver 2
R2(config-router)#address-family ipv4 vrf ABC
R2(config-router-af)#redistribute bgp 234 metric 1
PECE之间跑静态路由static

R2(config)#no router rip
R2(config)#ip route vrf ABC 1.1.1.0 255.255.255.0 s2/1
R2(config)#router bgp 234
R2(config-router)#address-family ipv4 vrf ABC
R2(config-router-af)#no redistribute rip
R2(config-router-af)#redistribute static
R2(config-router-af)#redistribute connected
     
R3(config)#int s2/1
R3(config-if)#ip add 23.0.0.3 255.255.255.0
R3(config-if)#no shu
R3(config-if)#int s2/2
R3(config-if)#ip add 34.0.0.3 255.255.255.0
R3(config-if)#no shu
R3(config-if)#int lo0
R3(config-if)#ip add 3.3.3.3 255.255.255.255
R3(config-if)#do ping 34.0.0.4

 

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 34.0.0.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 96/114/144 ms
R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#net 23.0.0.0 0.0.0.255 a 0
R3(config-router)#net 34.0.0.0 0.0.0.255 a 0
R3(config-router)#net 3.3.3.3 0.0.0.0 a 0
R3(config-router)#do sh ip route
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

 

     34.0.0.0/24 is subnetted, 1 subnets
C       34.0.0.0 is directly connected, Serial2/2
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 23.0.0.2, 00:00:04, Serial2/1
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 34.0.0.4, 00:00:04, Serial2/2
     23.0.0.0/24 is subnetted, 1 subnets
C       23.0.0.0 is directly connected, Serial2/1
R3(config)#ip cef
R3(config)#mpls label range 300 399
R3(config)#mpls label protocol ldp
R3(config)#mpls ldp router-id lo0
R3(config)#int s2/1
R3(config-if)#mpls ip
R3(config-if)#int s2/2
R3(config-if)#mpls ip
R3(config-if)#do sh mpls forwarding-table
Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop   
tag    tag or VC   or Tunnel Id      switched   interface             
300    Pop tag     2.2.2.2/32        0          Se2/1      point2point 
301    Pop tag     4.4.4.4/32        0          Se2/2      point2point

 

 

R4(config)#int s2/1
R4(config-if)#ip add 34.0.0.4 255.255.255.0
R4(config-if)#no shu
R4(config-if)#int s2/2
R4(config-if)#ip add 45.0.0.4 255.255.255.0
R4(config-if)#no shu
R4(config-if)#int lo0
R4(config-if)#ip add 4.4.4.4 255.255.255.255
R4(config-if)#do ping 45.0.0.5

 

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 45.0.0.5, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 72/92/120 ms
Setp1

R4(config)#router ospf 1
R4(config-router)#router-id 4.4.4.4
R4(config-router)#net 34.0.0.0 0.0.0.255 a 0
R4(config-router)#net 4.4.4.4 0.0.0.0 
R4(config-router)#net 4.4.4.4 0.0.0.0 a 0
R4#sh ip route
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

 

     34.0.0.0/24 is subnetted, 1 subnets
C       34.0.0.0 is directly connected, Serial2/1
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/129] via 34.0.0.3, 00:00:14, Serial2/1
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 34.0.0.3, 00:00:14, Serial2/1
     4.0.0.0/32 is subnetted, 1 subnets
C       4.4.4.4 is directly connected, Loopback0
     23.0.0.0/24 is subnetted, 1 subnets
O       23.0.0.0 [110/128] via 34.0.0.3, 00:00:14, Serial2/1
     45.0.0.0/24 is subnetted, 1 subnets
C       45.0.0.0 is directly connected, Serial2/2
Setp2

R4(config)#ip cef
R4(config)#mpls label range 400 499
R4(config)#mpls label protocol ldp
R4(config)#mpls ldp router-id lo0
R4(config)#int s2/1
R4(config-if)#mpls ip
R4(config-if)#do sh mpls forwarding-table
Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop   
tag    tag or VC   or Tunnel Id      switched   interface             
400    300         2.2.2.2/32        0          Se2/1      point2point 
401    Pop tag     3.3.3.3/32        0          Se2/1      point2point 
402    Pop tag     23.0.0.0/24       0          Se2/1      point2point 

 

Setp3

R4(config)#ip vrf ABC
R4(config-vrf)#rd 100:40
R4(config-vrf)#route-target export 100:40
R4(config-vrf)#int s2/2
R4(config-if)#ip vrf forwarding ABC
% Interface Serial2/2 IP address 45.0.0.4 removed due to enabling VRF ABC
R4(config-if)#ip add 45.0.0.4 255.255.255.0
R4(config-if)#do ping vrf ABC 45.0.0.5

 

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 45.0.0.5, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 72/82/120 ms
R4(config-if)#exit
Setp4

R4(config)#router rip
R4(config-router)#ver 2
R4(config-router)#no au
R4(config-router)#address-family ipv4 vrf ABC
R4(config-router-af)#ver 2
R4(config-router-af)#no au
R4(config-router-af)#net 45.0.0.0
R4(config-router-af)#do sh ip route vrf ABC

 

Routing Table: ABC
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

 

     5.0.0.0/24 is subnetted, 1 subnets
R       5.5.5.0 [120/1] via 45.0.0.5, 00:00:17, Serial2/2
     45.0.0.0/24 is subnetted, 1 subnets
C       45.0.0.0 is directly connected, Serial2/2
Setp5

R4(config)#router bgp 234
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#no au
R4(config-router)#no syn
R4(config-router)#nei 2.2.2.2 remote-as 234
R4(config-router)#nei 2.2.2.2 update-source lo0
R4(config-router)#no bgp default ipv4-unicast
R4(config-router)#address-family ***v4
R4(config-router-af)#nei 2.2.2.2 activate
Setp6

R4(config)#router bgp 234
R4(config-router)#address-family ipv4 vrf ABC
R4(config-router-af)#redistribute rip
Setp7

R4(config)#ip vrf ABC
R4(config-vrf)#route-target import 100:20
R4(config)#router rip
R4(config-router)#ver 2
R4(config-router)#address-family ipv4 vrf ABC
R4(config-router-af)#redistribute bgp 234 metric 1
R4(config)#router bgp 234

R4(config-router)#no bgp default route-target filter

R4#sh ip bgp *** all
BGP table version is 9, local router ID is 4.4.4.4
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:20
*>i1.1.1.0/24       2.2.2.2                  1    100      0 ?
*>i12.0.0.0/24      2.2.2.2                  0    100      0 ?
Route Distinguisher: 100:40 (default for vrf ABC)
*>i1.1.1.0/24       2.2.2.2                  1    100      0 ?
*> 5.5.5.0/24       45.0.0.5                 1         32768 ?
*>i12.0.0.0/24      2.2.2.2                  0    100      0 ?
*> 45.0.0.0/24      0.0.0.0                  0         32768 ?
R4#sh ip cef vrf ABC 1.1.1.1
1.1.1.0/24, version 9, epoch 0, cached adjacency to Serial2/1
0 packets, 0 bytes
  tag information set
    local tag: ×××-route-head
    fast tag rewrite with Se2/1, point2point, tags imposed: {300 203}
  via 2.2.2.2, 0 dependencies, recursive
    next hop 34.0.0.3, Serial2/1 via 2.2.2.2/32
    valid cached adjacency
    tag rewrite with Se2/1, point2point, tags imposed: {300 203}
PECE之间跑静态路由static

R4(config)#no router rip
R4(config)#ip route vrf ABC 5.5.5.0 255.255.255.0 s2/2
R4(config)#router bgp 234
R4(config-router)#address-family ipv4 vrf ABC
R4(config-router-af)#no redistribute rip
R4(config-router-af)#redistribute static
R4(config-router-af)#redistribute connected
R4(config-router)#do sh ip route vrf ABC         
Routing Table: ABC
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

 

     1.0.0.0/24 is subnetted, 1 subnets
B       1.1.1.0 [200/0] via 2.2.2.2, 00:02:18
     5.0.0.0/24 is subnetted, 1 subnets
S       5.5.5.0 is directly connected, Serial2/2
     12.0.0.0/24 is subnetted, 1 subnets
B       12.0.0.0 [200/0] via 2.2.2.2, 00:02:18
     45.0.0.0/24 is subnetted, 1 subnets
C       45.0.0.0 is directly connected, Serial2/2

 

 

 

R5(config)#int s2/2
R5(config-if)#ip add 45.0.0.5 255.255.255.0
R5(config-if)#no shu
R5(config-if)#int lo0
R5(config-if)#ip add 5.5.5.5 255.255.255.0
R5(config-if)#exit
R5(config)#router rip
R5(config-router)#ver 2
R5(config-router)#no au
R5(config-router)#net 45.0.0.0
R5(config-router)#net 5.0.0.0
R5(config-router)#do sh ip route
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

 

     1.0.0.0/24 is subnetted, 1 subnets
R       1.1.1.0 [120/1] via 45.0.0.4, 00:00:10, Serial2/2
     5.0.0.0/24 is subnetted, 1 subnets
C       5.5.5.0 is directly connected, Loopback0
     12.0.0.0/24 is subnetted, 1 subnets
R       12.0.0.0 [120/1] via 45.0.0.4, 00:00:10, Serial2/2
     45.0.0.0/24 is subnetted, 1 subnets
C       45.0.0.0 is directly connected, Serial2/2
R5(config-router)#exit
R5(config)#no router rip
R5(config)#
R5(config)#
R5(config)#ip route 0.0.0.0 0.0.0.0 s2/2
R5(config)#^Z
R5#sh ip route
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 0.0.0.0 to network 0.0.0.0
5.0.0.0/24 is subnetted, 1 subnets
C       5.5.5.0 is directly connected, Loopback0
     45.0.0.0/24 is subnetted, 1 subnets
C       45.0.0.0 is directly connected, Serial2/2
S*   0.0.0.0/0 is directly connected, Serial2/2
R5#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!