Friday, 10 February 2017

OSPF as PE-Ce protocol-Sham Link- MPLs





PC1:-

PC1> ip 10.1.1.10 255.255.255.0 10.1.1.1
Checking for duplicate address...
PC1 : 10.1.1.10 255.255.255.0 gateway 10.1.1.1

R1:-

R1(config)#int fa0/0
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-if)#no shut

R1(config-if)#int fa2/0
R1(config-if)#ip add 12.12.12.1 255.255.255.0
R1(config-if)#no shut

R1(config-if)#int lo0
R1(config-if)#ip add 1.1.1.1 255.255.255.255

R1(config)#router ospf 1
R1(config-router)# log-adjacency-changes
R1(config-router)# network 1.1.1.1 0.0.0.0 area 0
R1(config-router)# network 10.1.1.1 0.0.0.0 area 0
R1(config-router)# network 12.12.12.1 0.0.0.0 area 0


R2:-

R2(config)#ip vrf cust1
R2(config-vrf)#rd 100:1
R2(config-vrf)#route-target 200:1

R2(config-vrf)#int fa2/0
R2(config-if)#ip vrf for cust1
R2(config-if)#ip add 12.12.12.2 255.255.255.0
R2(config-if)#no shut

R2(config-if)#int fa0/0
R2(config-if)#ip add 23.23.23.2 255.255.255.0
R2(config-if)#mpls ip
R2(config-if)#no shut

R2(config-if)#int lo0
R2(config-if)#ip add 2.2.2.2 255.255.255.255

R2(config-if)#mpls ldp router lo0 force

R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#net 23.23.23.2 0.0.0.0 are
R2(config-router)#net 23.23.23.2 0.0.0.0 area 0
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0

R2(config-if)#router bgp 1
R2(config-router)#neighbor 4.4.4.4 remote-as 1
R2(config-router)#neighbor 4.4.4.4 update-source lo0
R2(config-router)#address-family vpnv4
R2(config-router-af)#neighbor 4.4.4.4 activate
R2(config-router-af)#exit
R2(config-router)#address-family ipv4 vrf cust1
R2(config-router-af)#redistribute ospf 100 vrf cust1 metric 10  --<< metric set here, will not be used at remote end while redistributing bgp route to ospf
R2(config-router-af)#exit

R2(config-router)#router ospf 100 vrf cust1
R2(config-router)# redistribute bgp 1 subnets
R2(config-router)# network 12.12.12.2 0.0.0.0 area 0
R2(config-router)#domain-id 2.2.2.2

R2(config)#int lo1
R2(config-if)#ip vrf for cust1
R2(config-if)#ip add 22.22.22.22 255.255.255.255

R2(config-if)#router bgp 1
R2(config-router)#address ipv4 vrf cust1
R2(config-router-af)#net 22.22.22.22 mask 255.255.255.255 --< Need to advertise Sham link end point in BGP not in OSPF.
R2(config-router-af)#exit

R2(config-router)#router ospf 100 vrf cust1
R2(config-router)#area 0 sham-link 22.22.22.22 44.44.44.44

R3:-

R3(config)#int lo0
R3(config-if)#ip add 3.3.3.3 255.255.255.255
R3(config-if)#exit

R3(config)#mpls ldp router lo0 force

R3(config)#int fa0/0
R3(config-if)#ip add 23.23.23.3 255.255.255.0
R3(config-if)#mpls ip
R3(config-if)#no shut

R3(config-if)#int fa1/0
R3(config-if)#ip add 34.34.34.3 255.255.255.0
R3(config-if)#mpls ip
R3(config-if)#no shut

R3(config-if)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#net 23.23.23.3 0.0.0.0 area 0
R3(config-router)#net 34.34.34.3 0.0.0.0 are 0
R3(config-router)#net 3.3.3.3 0.0.0.0 area 0
R3(config-router)#exit

R4:-

R4(config)#int lo0
R4(config-if)#ip add 4.4.4.4 255.255.255.255

R4(config-if)#int fa1/0
R4(config-if)#ip add 34.34.34.4 255.255.255.0
R4(config-if)#mpls ip
R4(config-if)#no shut
R4(config-if)#exit

R4(config)#mpls ldp router lo0 force

R4(config)#ip vrf cust1
R4(config-vrf)#rd 1:1
R4(config-vrf)#route-target 200:1
R4(config-vrf)#exit

R4(config)#int fa2/0
R4(config-if)#ip vrf for cust1
R4(config-if)#ip add 45.45.45.4 255.255.255.0
R4(config-if)#no shut

R4(config-if)#router ospf 1
R4(config-router)#router-id 4.4.4.4
R4(config-router)#net 34.34.34.4 0.0.0.0 area 0
R4(config-router)#network 4.4.4.4 0.0.0.0 area 0

R4(config)#router bgp 1
R4(config-router)#neighbor 2.2.2.2 remote-as 1
R4(config-router)#neighbor 2.2.2.2 update-source lo0

R4(config-router)#address-family vpnv4
R4(config-router-af)#neighbor 2.2.2.2 activate

R4(config-router-af)#addres ipv4 vrf cust1
R4(config-router-af)#  redistribute ospf 100 vrf cust1
R4(config-router-af)#exit
R4(config-router)#exit

R4(config-router-af)#router ospf 100 vrf cust1
R4(config-router)#net 45.45.45.4 0.0.0.0 area 0
R4(config-router)#domain-id 4.4.4.4

R4(config)#int lo1
R4(config-if)#ip vrf for cust1
R4(config-if)#ip add 44.44.44.44 255.255.255.255

R4(config-if)#router bgp 1
R4(config-router)#address-family ipv4 vrf cust1
R4(config-router-af)#net 44.44.44.44 mask 255.255.255.255

R4(config-router-af)#router ospf 100 vrf cust1
R4(config-router)#area 0 sham-link 44.44.44.44 22.22.22.22

R5:-

R5(config)#int lo0
R5(config-if)#ip add 5.5.5.5 255.255.255.255

R5(config-if)#int fa2/0
R5(config-if)#ip add 45.45.45.5 255.255.255.0
R5(config-if)#no shut

R5(config)#int fa0/0
R5(config-if)#ip add 20.1.1.1 255.255.255.0
R5(config-if)#no shut

R5(config)#router ospf 1
R5(config-router)#net 5.5.5.5 0.0.0.0 area 0
R5(config-router)#net 45.45.45.5 0.0.0.0 area 0
R5(config-router)#net 20.1.1.1 0.0.0.0 area 0

Verification:-

PC1:-

PC1> ping 20.1.1.10
84 bytes from 20.1.1.10 icmp_seq=1 ttl=59 time=368.619 ms
84 bytes from 20.1.1.10 icmp_seq=2 ttl=59 time=347.316 ms
84 bytes from 20.1.1.10 icmp_seq=3 ttl=59 time=368.788 ms
84 bytes from 20.1.1.10 icmp_seq=4 ttl=59 time=416.798 ms
84 bytes from 20.1.1.10 icmp_seq=5 ttl=59 time=379.615 ms

PC1> trace 20.1.1.10
trace to 20.1.1.10, 8 hops max, press Ctrl+C to stop
 1   10.1.1.1   98.128 ms  32.396 ms  38.933 ms
 2   12.12.12.2   193.647 ms  120.998 ms  111.703 ms
 3   23.23.23.3   309.530 ms  294.889 ms  276.499 ms
 4   45.45.45.4   289.342 ms  309.988 ms  292.062 ms
 5   45.45.45.5   329.599 ms  272.541 ms  341.644 ms
 6   *20.1.1.10   345.620 ms (ICMP type:3, code:3, Destination port unreachable)

R1:-

R1#sh ip route
Codes: L - local, 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, H - NHRP
       + - replicated route, % - next hop override

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
O        5.5.5.5 [110/4] via 12.12.12.2, 00:05:40, FastEthernet2/0 -<< become internal routes.
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.1.1.0/24 is directly connected, FastEthernet0/0
L        10.1.1.1/32 is directly connected, FastEthernet0/0
      12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        12.12.12.0/24 is directly connected, FastEthernet2/0
L        12.12.12.1/32 is directly connected, FastEthernet2/0
      20.0.0.0/24 is subnetted, 1 subnets
O        20.1.1.0 [110/4] via 12.12.12.2, 00:05:40, FastEthernet2/0
      22.0.0.0/32 is subnetted, 1 subnets
O E2     22.22.22.22 [110/1] via 12.12.12.2, 00:07:55, FastEthernet2/0
      44.0.0.0/32 is subnetted, 1 subnets
O E2     44.44.44.44 [110/1] via 12.12.12.2, 00:06:30, FastEthernet2/0
      45.0.0.0/24 is subnetted, 1 subnets
O        45.45.45.0 [110/3] via 12.12.12.2, 00:05:40, FastEthernet2/0
R1#

R2:-

R2#sh ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/BDR        00:00:35    23.23.23.3      FastEthernet0/0
45.45.45.4        0   FULL/  -           -        44.44.44.44     OSPF_SL0  -<< new neighborship comes up on sham links
1.1.1.1           1   FULL/BDR        00:00:39    12.12.12.1      FastEthernet2/0

R2#sh ip bgp vpnv4 all summ
BGP router identifier 2.2.2.2, local AS number 1
BGP table version is 43, main routing table version 43
7 network entries using 1064 bytes of memory
7 path entries using 364 bytes of memory
6/6 BGP path/bestpath attribute entries using 792 bytes of memory
5 BGP extended community entries using 184 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 2404 total bytes of memory
BGP activity 13/6 prefixes, 15/8 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4            1     199     197       43    0    0 02:47:01        4

R2#show ip bgp vpnv4 all
BGP table version is 43, 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, m multipath, b backup-path, x best-external
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf cust1)
r>i5.5.5.5/32       4.4.4.4                  2    100      0 ?
*> 10.1.1.0/24      12.12.12.1              10         32768 ?
*> 12.12.12.0/24    0.0.0.0                  0         32768 ?
r>i20.1.1.0/24      4.4.4.4                  2    100      0 ?
*> 22.22.22.22/32   0.0.0.0                  0         32768 i
*>i44.44.44.44/32   4.4.4.4                  0    100      0 i
r>i45.45.45.0/24    4.4.4.4                  0    100      0 ?

R2#show ip route vrf cust1

Routing Table: cust1
Codes: L - local, 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, H - NHRP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      5.0.0.0/32 is subnetted, 1 subnets
O        5.5.5.5 [110/3] via 4.4.4.4, 00:07:36
      10.0.0.0/24 is subnetted, 1 subnets
O        10.1.1.0 [110/2] via 12.12.12.1, 00:53:18, FastEthernet2/0
      12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        12.12.12.0/24 is directly connected, FastEthernet2/0
L        12.12.12.2/32 is directly connected, FastEthernet2/0
      20.0.0.0/24 is subnetted, 1 subnets
O        20.1.1.0 [110/3] via 4.4.4.4, 00:07:36  --<< check the cost
      22.0.0.0/32 is subnetted, 1 subnets
C        22.22.22.22 is directly connected, Loopback1
      44.0.0.0/32 is subnetted, 1 subnets
B        44.44.44.44 [200/0] via 4.4.4.4, 00:08:27
      45.0.0.0/24 is subnetted, 1 subnets
O        45.45.45.0 [110/2] via 4.4.4.4, 00:07:36
R2#

R2#sh ip ospf sham-links
Sham Link OSPF_SL0 to address 44.44.44.44 is up
Area 0 source address 22.22.22.22
  Run as demand circuit
  DoNotAge LSA allowed. Cost of using 1 State POINT_TO_POINT,
  Timer intervals configured, Hello 10, Dead 40, Wait 40,
    Hello due in 00:00:04
    Adjacency State FULL (Hello suppressed)
    Index 2/2, retransmission queue length 0, number of retransmission 0
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 0, maximum is 0
    Last retransmission scan time is 0 msec, maximum is 0 msec

R3:-

R3#sh ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
4.4.4.4           1   FULL/BDR        00:00:35    34.34.34.4      FastEthernet1/0
2.2.2.2           1   FULL/DR         00:00:31    23.23.23.2      FastEthernet0/0

R3#show mpls ldp neighbor    
Peer LDP Ident: 4.4.4.4:0; Local LDP Ident 3.3.3.3:0
        TCP connection: 4.4.4.4.21070 - 3.3.3.3.646
        State: Oper; Msgs sent/rcvd: 101/102; Downstream
        Up time: 01:22:35
        LDP discovery sources:
          FastEthernet1/0, Src IP addr: 34.34.34.4
        Addresses bound to peer LDP Ident:
          34.34.34.4      4.4.4.4
    Peer LDP Ident: 2.2.2.2:0; Local LDP Ident 3.3.3.3:0
        TCP connection: 2.2.2.2.646 - 3.3.3.3.30173
        State: Oper; Msgs sent/rcvd: 102/100; Downstream
        Up time: 01:22:35
        LDP discovery sources:
          FastEthernet0/0, Src IP addr: 23.23.23.2
        Addresses bound to peer LDP Ident:
          23.23.23.2      2.2.2.2


R3#show mpls ldp discovery
 Local LDP Identifier:
    3.3.3.3:0
    Discovery Sources:
    Interfaces:
        FastEthernet0/0 (ldp): xmit/recv
            LDP Id: 2.2.2.2:0
        FastEthernet1/0 (ldp): xmit/recv
            LDP Id: 4.4.4.4:0

R3#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop
Label      Label      or Tunnel Id     Switched      interface
16         Pop Label  4.4.4.4/32       14366         Fa1/0      34.34.34.4
17         Pop Label  2.2.2.2/32       15433         Fa0/0      23.23.23.2

R4:-

R4#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/DR         00:00:31    34.34.34.3      FastEthernet1/0
12.12.12.2        0   FULL/  -           -        22.22.22.22     OSPF_SL0
5.5.5.5           1   FULL/DR         00:00:31    45.45.45.5      FastEthernet2/0

R4#show ip bgp vpnv4 all
BGP table version is 37, 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, m multipath, b backup-path, x best-external
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf cust1)
*> 5.5.5.5/32       45.45.45.5               2         32768 ?
r>i10.1.1.0/24      2.2.2.2                 10    100      0 ?
r>i12.12.12.0/24    2.2.2.2                  0    100      0 ?
*> 20.1.1.0/24      45.45.45.5               2         32768 ?
*>i22.22.22.22/32   2.2.2.2                  0    100      0 i
*> 44.44.44.44/32   0.0.0.0                  0         32768 i
*> 45.45.45.0/24    0.0.0.0                  0         32768 ?

R4#show ip bgp vpnv4 all  10.1.1.10/24
BGP routing table entry for 1:1:10.1.1.0/24, version 36
Paths: (1 available, best #1, table cust1, RIB-failure(17))
  Not advertised to any peer
  Local
    2.2.2.2 (metric 3) from 2.2.2.2 (2.2.2.2)
      Origin incomplete, metric 10, localpref 100, valid, internal, best
      Extended Community: RT:100:1 OSPF DOMAIN ID:0x0005:0x020202020200
        OSPF RT:0.0.0.0:2:0 OSPF ROUTER ID:12.12.12.2:0
      mpls labels in/out nolabel/19

R4#show ip route vrf cust1

Routing Table: cust1
Codes: L - local, 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, H - NHRP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      5.0.0.0/32 is subnetted, 1 subnets
O        5.5.5.5 [110/2] via 45.45.45.5, 00:25:27, FastEthernet2/0
      10.0.0.0/24 is subnetted, 1 subnets
O        10.1.1.0 [110/3] via 2.2.2.2, 00:09:03
      12.0.0.0/24 is subnetted, 1 subnets
O        12.12.12.0 [110/2] via 2.2.2.2, 00:09:03
      20.0.0.0/24 is subnetted, 1 subnets
O        20.1.1.0 [110/2] via 45.45.45.5, 00:25:27, FastEthernet2/0
      22.0.0.0/32 is subnetted, 1 subnets
B        22.22.22.22 [200/0] via 2.2.2.2, 00:11:19
      44.0.0.0/32 is subnetted, 1 subnets
C        44.44.44.44 is directly connected, Loopback1
      45.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        45.45.45.0/24 is directly connected, FastEthernet2/0
L        45.45.45.4/32 is directly connected, FastEthernet2/0

R5:-


R5#sh ip route
Codes: L - local, 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, H - NHRP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      5.0.0.0/32 is subnetted, 1 subnets
C        5.5.5.5 is directly connected, Loopback0
      10.0.0.0/24 is subnetted, 1 subnets
O        10.1.1.0 [110/4] via 45.45.45.4, 00:10:00, FastEthernet2/0
      12.0.0.0/24 is subnetted, 1 subnets
O        12.12.12.0 [110/3] via 45.45.45.4, 00:10:00, FastEthernet2/0
      20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        20.1.1.0/24 is directly connected, FastEthernet0/0
L        20.1.1.1/32 is directly connected, FastEthernet0/0
      22.0.0.0/32 is subnetted, 1 subnets
O E2     22.22.22.22 [110/1] via 45.45.45.4, 00:12:25, FastEthernet2/0
      44.0.0.0/32 is subnetted, 1 subnets
O E2     44.44.44.44 [110/1] via 45.45.45.4, 00:11:00, FastEthernet2/0
      45.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        45.45.45.0/24 is directly connected, FastEthernet2/0
L        45.45.45.5/32 is directly connected, FastEthernet2/0
R5#


OSPF as PE-CE protocol with different Domain-id - MPLS





PC1:-

PC1> ip 10.1.1.10 255.255.255.0 10.1.1.1
Checking for duplicate address...
PC1 : 10.1.1.10 255.255.255.0 gateway 10.1.1.1

R1:-

R1(config)#int fa0/0
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-if)#no shut

R1(config-if)#int fa2/0
R1(config-if)#ip add 12.12.12.1 255.255.255.0
R1(config-if)#no shut

R1(config-if)#int lo0
R1(config-if)#ip add 1.1.1.1 255.255.255.255

R1(config)#router ospf 1
R1(config-router)# log-adjacency-changes
R1(config-router)# network 1.1.1.1 0.0.0.0 area 0
R1(config-router)# network 10.1.1.1 0.0.0.0 area 0
R1(config-router)# network 12.12.12.1 0.0.0.0 area 0


R2:-

R2(config)#ip vrf cust1
R2(config-vrf)#rd 100:1
R2(config-vrf)#route-target 200:1

R2(config-vrf)#int fa2/0
R2(config-if)#ip vrf for cust1
R2(config-if)#ip add 12.12.12.2 255.255.255.0
R2(config-if)#no shut

R2(config-if)#int fa0/0
R2(config-if)#ip add 23.23.23.2 255.255.255.0
R2(config-if)#mpls ip
R2(config-if)#no shut

R2(config-if)#int lo0
R2(config-if)#ip add 2.2.2.2 255.255.255.255

R2(config-if)#mpls ldp router lo0 force

R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#net 23.23.23.2 0.0.0.0 are
R2(config-router)#net 23.23.23.2 0.0.0.0 area 0
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0

R2(config-if)#router bgp 1
R2(config-router)#neighbor 4.4.4.4 remote-as 1
R2(config-router)#neighbor 4.4.4.4 update-source lo0
R2(config-router)#address-family vpnv4
R2(config-router-af)#neighbor 4.4.4.4 activate
R2(config-router-af)#exit
R2(config-router)#address-family ipv4 vrf cust1
R2(config-router-af)#redistribute ospf 100 vrf cust1 metric 10  --<< metric set here, will be used at remote end while redistributing bgp route to ospf
R2(config-router-af)#exit
R2(config-router)#router ospf 100 vrf cust1
R2(config-router)# redistribute bgp 1 subnets
R2(config-router)# network 12.12.12.2 0.0.0.0 area 0
R2(config-router)#domain-id 2.2.2.2

R3:-

R3(config)#int lo0
R3(config-if)#ip add 3.3.3.3 255.255.255.255
R3(config-if)#exit

R3(config)#mpls ldp router lo0 force

R3(config)#int fa0/0
R3(config-if)#ip add 23.23.23.3 255.255.255.0
R3(config-if)#mpls ip
R3(config-if)#no shut

R3(config-if)#int fa1/0
R3(config-if)#ip add 34.34.34.3 255.255.255.0
R3(config-if)#mpls ip
R3(config-if)#no shut

R3(config-if)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#net 23.23.23.3 0.0.0.0 area 0
R3(config-router)#net 34.34.34.3 0.0.0.0 are 0
R3(config-router)#net 3.3.3.3 0.0.0.0 area 0
R3(config-router)#exit

R4:-

R4(config)#int lo0
R4(config-if)#ip add 4.4.4.4 255.255.255.255

R4(config-if)#int fa1/0
R4(config-if)#ip add 34.34.34.4 255.255.255.0
R4(config-if)#mpls ip
R4(config-if)#no shut
R4(config-if)#exit

R4(config)#mpls ldp router lo0 force

R4(config)#ip vrf cust1
R4(config-vrf)#rd 1:1
R4(config-vrf)#route-target 200:1
R4(config-vrf)#exit

R4(config)#int fa2/0
R4(config-if)#ip vrf for cust1
R4(config-if)#ip add 45.45.45.4 255.255.255.0
R4(config-if)#no shut

R4(config-if)#router ospf 1
R4(config-router)#router-id 4.4.4.4
R4(config-router)#net 34.34.34.4 0.0.0.0 area 0
R4(config-router)#network 4.4.4.4 0.0.0.0 area 0

R4(config)#router bgp 1
R4(config-router)#neighbor 2.2.2.2 remote-as 1
R4(config-router)#neighbor 2.2.2.2 update-source lo0

R4(config-router)#address-family vpnv4
R4(config-router-af)#neighbor 2.2.2.2 activate

R4(config-router-af)#addres ipv4 vrf cust1
R4(config-router-af)#  redistribute ospf 100 vrf cust1
R4(config-router-af)#exit
R4(config-router)#exit

R4(config-router-af)#router ospf 100 vrf cust1
R4(config-router)#net 45.45.45.4 0.0.0.0 area 0
R4(config-router)#domain-id 4.4.4.4

R5:-

R5(config)#int lo0
R5(config-if)#ip add 5.5.5.5 255.255.255.255

R5(config-if)#int fa2/0
R5(config-if)#ip add 45.45.45.5 255.255.255.0
R5(config-if)#no shut

R5(config)#int fa0/0
R5(config-if)#ip add 20.1.1.1 255.255.255.0
R5(config-if)#no shut

R5(config)#router ospf 1
R5(config-router)#net 5.5.5.5 0.0.0.0 area 0
R5(config-router)#net 45.45.45.5 0.0.0.0 area 0
R5(config-router)#net 20.1.1.1 0.0.0.0 area 0

Verification:-

PC1:-

PC1> ping 20.1.1.10
84 bytes from 20.1.1.10 icmp_seq=1 ttl=59 time=368.619 ms
84 bytes from 20.1.1.10 icmp_seq=2 ttl=59 time=347.316 ms
84 bytes from 20.1.1.10 icmp_seq=3 ttl=59 time=368.788 ms
84 bytes from 20.1.1.10 icmp_seq=4 ttl=59 time=416.798 ms
84 bytes from 20.1.1.10 icmp_seq=5 ttl=59 time=379.615 ms

PC1> trace 20.1.1.10
trace to 20.1.1.10, 8 hops max, press Ctrl+C to stop
 1   10.1.1.1   98.128 ms  32.396 ms  38.933 ms
 2   12.12.12.2   193.647 ms  120.998 ms  111.703 ms
 3   23.23.23.3   309.530 ms  294.889 ms  276.499 ms
 4   45.45.45.4   289.342 ms  309.988 ms  292.062 ms
 5   45.45.45.5   329.599 ms  272.541 ms  341.644 ms
 6   *20.1.1.10   345.620 ms (ICMP type:3, code:3, Destination port unreachable)

R1:-

R1#sh ip route
Codes: L - local, 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, H - NHRP
       + - replicated route, % - next hop override

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
O E2     5.5.5.5 [110/2] via 12.12.12.2, 00:01:41, FastEthernet2/0  -<<< become external routes and metric will be calculted from redistribution command. 
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.1.1.0/24 is directly connected, FastEthernet0/0
L        10.1.1.1/32 is directly connected, FastEthernet0/0
      12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        12.12.12.0/24 is directly connected, FastEthernet2/0
L        12.12.12.1/32 is directly connected, FastEthernet2/0
      20.0.0.0/24 is subnetted, 1 subnets
O E2     20.1.1.0 [110/2] via 12.12.12.2, 00:01:41, FastEthernet2/0  --<<<
      45.0.0.0/24 is subnetted, 1 subnets
O E2     45.45.45.0 [110/1] via 12.12.12.2, 00:01:41, FastEthernet2/0  --<<

R2:-

R2#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/BDR        00:00:31    23.23.23.3      FastEthernet0/0
1.1.1.1           1   FULL/BDR        00:00:35    12.12.12.1      FastEthernet2/0

R2#show ip bgp vpnv4 all summary
BGP router identifier 2.2.2.2, local AS number 1
BGP table version is 37, main routing table version 37
5 network entries using 760 bytes of memory
5 path entries using 260 bytes of memory
4/4 BGP path/bestpath attribute entries using 528 bytes of memory
4 BGP extended community entries using 160 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1708 total bytes of memory
BGP activity 11/6 prefixes, 13/8 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4            1     175     173       37    0    0 02:25:25        3

R2#show ip bgp vpnv4 all
BGP table version is 37, 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, m multipath, b backup-path, x best-external
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf cust1)
*>i5.5.5.5/32       4.4.4.4                  2    100      0 ?
*> 10.1.1.0/24      12.12.12.1              10         32768 ?
*> 12.12.12.0/24    0.0.0.0                  0         32768 ?
*>i20.1.1.0/24      4.4.4.4                  2    100      0 ?
*>i45.45.45.0/24    4.4.4.4                  0    100      0 ?
R2#show ip bgp vpnv4 all 5.5.5.5/32
BGP routing table entry for 1:1:5.5.5.5/32, version 36
Paths: (1 available, best #1, table cust1)
  Not advertised to any peer
  Local
    4.4.4.4 (metric 3) from 4.4.4.4 (4.4.4.4)
      Origin incomplete, metric 2, localpref 100, valid, internal, best
      Extended Community: RT:100:1 OSPF DOMAIN ID:0x0005:0x040404040200
        OSPF RT:0.0.0.0:2:0 OSPF ROUTER ID:45.45.45.4:0
      mpls labels in/out nolabel/21

R2#sh ip route vrf cust1

Routing Table: cust1
Codes: L - local, 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, H - NHRP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      5.0.0.0/32 is subnetted, 1 subnets
B        5.5.5.5 [200/2] via 4.4.4.4, 00:02:35
      10.0.0.0/24 is subnetted, 1 subnets
O        10.1.1.0 [110/2] via 12.12.12.1, 00:31:53, FastEthernet2/0
      12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        12.12.12.0/24 is directly connected, FastEthernet2/0
L        12.12.12.2/32 is directly connected, FastEthernet2/0
      20.0.0.0/24 is subnetted, 1 subnets
B        20.1.1.0 [200/2] via 4.4.4.4, 00:02:35
      45.0.0.0/24 is subnetted, 1 subnets
B        45.45.45.0 [200/0] via 4.4.4.4, 00:34:17

R3:-

R3#sh ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
4.4.4.4           1   FULL/BDR        00:00:35    34.34.34.4      FastEthernet1/0
2.2.2.2           1   FULL/DR         00:00:31    23.23.23.2      FastEthernet0/0

R3#show mpls ldp neighbor    
Peer LDP Ident: 4.4.4.4:0; Local LDP Ident 3.3.3.3:0
        TCP connection: 4.4.4.4.21070 - 3.3.3.3.646
        State: Oper; Msgs sent/rcvd: 101/102; Downstream
        Up time: 01:22:35
        LDP discovery sources:
          FastEthernet1/0, Src IP addr: 34.34.34.4
        Addresses bound to peer LDP Ident:
          34.34.34.4      4.4.4.4
    Peer LDP Ident: 2.2.2.2:0; Local LDP Ident 3.3.3.3:0
        TCP connection: 2.2.2.2.646 - 3.3.3.3.30173
        State: Oper; Msgs sent/rcvd: 102/100; Downstream
        Up time: 01:22:35
        LDP discovery sources:
          FastEthernet0/0, Src IP addr: 23.23.23.2
        Addresses bound to peer LDP Ident:
          23.23.23.2      2.2.2.2


R3#show mpls ldp discovery
 Local LDP Identifier:
    3.3.3.3:0
    Discovery Sources:
    Interfaces:
        FastEthernet0/0 (ldp): xmit/recv
            LDP Id: 2.2.2.2:0
        FastEthernet1/0 (ldp): xmit/recv
            LDP Id: 4.4.4.4:0

R3#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop
Label      Label      or Tunnel Id     Switched      interface
16         Pop Label  4.4.4.4/32       14366         Fa1/0      34.34.34.4
17         Pop Label  2.2.2.2/32       15433         Fa0/0      23.23.23.2

R4:-

R4#show ip bgp vpnv4 all summary
BGP router identifier 4.4.4.4, local AS number 1
BGP table version is 32, main routing table version 32
5 network entries using 760 bytes of memory
5 path entries using 260 bytes of memory
4/4 BGP path/bestpath attribute entries using 528 bytes of memory
4 BGP extended community entries using 160 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1708 total bytes of memory
BGP activity 11/6 prefixes, 13/8 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
2.2.2.2         4            1     176     178       32    0    0 02:27:48        2

R4#show ip bgp vpnv4 all
BGP table version is 32, 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, m multipath, b backup-path, x best-external
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf cust1)
*> 5.5.5.5/32       45.45.45.5               2         32768 ?
*>i10.1.1.0/24      2.2.2.2                 10    100      0 ?
*>i12.12.12.0/24    2.2.2.2                  0    100      0 ?
*> 20.1.1.0/24      45.45.45.5               2         32768 ?
*> 45.45.45.0/24    0.0.0.0                  0         32768 ?

R4#show ip route  vrf cust1

Routing Table: cust1
Codes: L - local, 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, H - NHRP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      5.0.0.0/32 is subnetted, 1 subnets
O        5.5.5.5 [110/2] via 45.45.45.5, 00:04:54, FastEthernet2/0
      10.0.0.0/24 is subnetted, 1 subnets
B        10.1.1.0 [200/10] via 2.2.2.2, 00:34:09
      12.0.0.0/24 is subnetted, 1 subnets
B        12.12.12.0 [200/0] via 2.2.2.2, 00:37:22
      20.0.0.0/24 is subnetted, 1 subnets
O        20.1.1.0 [110/2] via 45.45.45.5, 00:04:54, FastEthernet2/0
      45.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        45.45.45.0/24 is directly connected, FastEthernet2/0
L        45.45.45.4/32 is directly connected, FastEthernet2/0


R5:-

R5#sh ip route
Codes: L - local, 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, H - NHRP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      5.0.0.0/32 is subnetted, 1 subnets
C        5.5.5.5 is directly connected, Loopback0
      10.0.0.0/24 is subnetted, 1 subnets
O E2     10.1.1.0 [110/10] via 45.45.45.4, 00:00:04, FastEthernet2/0
      12.0.0.0/24 is subnetted, 1 subnets
O E2     12.12.12.0 [110/1] via 45.45.45.4, 00:00:04, FastEthernet2/0
      20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        20.1.1.0/24 is directly connected, FastEthernet0/0
L        20.1.1.1/32 is directly connected, FastEthernet0/0
      45.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        45.45.45.0/24 is directly connected, FastEthernet2/0
L        45.45.45.5/32 is directly connected, FastEthernet2/0