• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
Xin chào ! Nếu đây là lần đầu tiên bạn đến với diễn đàn, xin vui lòng danh ra một phút bấm vào đây để đăng kí và tham gia thảo luận cùng VnPro.

Announcement

Collapse
No announcement yet.

Lab MPLS cơ bản

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lab MPLS cơ bản





    I. Mô tả

    Trong bài lab này chúng ta sẽ thực hiện cấu hình MPLS cơ bản.

    II.Cấu hình

    Bước 1:Đầu tiên chúng ta chỉ quan tâm đến vùng area 0 gồm 3 router R1,R2 và R3. Chúng ta sẽ cấu hình ospf để các loopback của R2 và R3 thấy nhau.

    Code:
    R2(config)#[B]int lo 0[/B]
    R2(config-if)#[B]ip add 2.2.2.2 255.255.255.255[/B]
    R2(config-if)#i[B]p ospf 1 area 0[/B]
    
    R2(config)#i[B]nt e0/0[/B]
    R2(config-if)#[B]ip add 10.0.0.2 255.255.255.0[/B]
    R2(config-if)#[B]no shut[/B]
    R2(config-if)#i[B]p ospf 1 area 0[/B]


    Code:
    R1(config)#[B]int lo 0[/B]
    R1(config-if)#i[B]p add 1.1.1.1 255.255.255.255[/B]
    R1(config-if)#i[B]p ospf 1 area 0[/B]
    
    R1(config)#i[B]nt e0/0[/B]
    R1(config-if)#[B]ip add 10.0.0.1 255.255.255.0[/B]
    R1(config-if)#[B]no shut[/B]
    R1(config-if)#[B]ip ospf 1 area 0[/B]
    
    R1(config)#[B]int e0/1[/B]
    R1(config-if)#[B]ip add 10.0.1.1 255.255.255.0[/B]
    R1(config-if)#[B]no shut[/B]
    R1(config-if)#[B]ip ospf 1 area 0[/B]
    Code:
    R3(config)#[B]int lo0[/B]
    R3(config-if)#[B]ip add 3.3.3.3 255.255.255.255[/B]
    R3(config-if)[B]#ip ospf 1 area 0[/B]
    R3(config-if)#[B]exit[/B]
    
    R3(config)#[B]int e0/0[/B]
    R3(config-if)#[B]ip add 10.0.1.3 255.255.255.0[/B]
    R3(config-if)#[B]no shut[/B]
    R3(config-if)#[B]ip ospf 1 area 0[/B]
    Thực hiện ping test từ R2 sang R3 với source là loopback của R2.

    Code:
    R2#[B]ping 3.3.3.3 source lo0[/B]
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
    Packet sent with a source address of 2.2.2.2
    [B]!!!!![/B]
    [B]Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms[/B]
    Bước 2: Cấu hình LDP trên tất cả các cổng trong MPLS Core
    Để chạy MPLS chúng ta cần enable nó, có 2 cách để enable là enable trên cổng với lệnh mpls ip hoặc enable trong ospf với lệnh mpls ldp autoconfig.
    Code:
    R2(config)#[B]router ospf 1[/B]
    R2(config-router)#[B]mpls ldp autoconfig[/B]
    R2(config-router)#[B]exit[/B]
    [B]*Nov  4 08:54:47.446: %LDP-5-NBRCHG: LDP Neighbor 1.1.1.1:0 (1) is UP[/B]
    Code:
    R1(config)#[B]router ospf 1[/B]
    R1(config-router)#[B]mpls ldp aut[/B]
    R1(config-router)#[B]mpls ldp autoconfig[/B]
    [B]*Nov  4 08:54:47.466: %LDP-5-NBRCHG: LDP Neighbor 2.2.2.2:0 (1) is UP[/B]
    Code:
    R3(config)#[B]router ospf 1[/B]
    R3(config-router)#[B]mpls ldp autoconfig[/B]
    [B]*Nov  4 08:55:57.316: %SYS-5-CONFIG_I: Configured from console by console[/B]
    Kiểm tra cấu hình MPLS trên các cổng của R1 với lệnh show mpls interface.
    Code:
    R1#[B]show mpls interface[/B]
    Interface              IP            Tunnel   BGP Static Operational
    Ethernet0/0           [B] Yes (ldp)     [/B]No       No  No     Yes
    Ethernet0/1           [B] Yes (ldp)[/B]     No       No  No     Yes
    Kiểm tra LDP neighbors với lệnh show mpls ldp neighbors.

    Code:
    R1#[B]show mpls ldp neigh[/B]
        Peer LDP Ident: 2.2.2.2:0; Local LDP Ident 1.1.1.1:0
            TCP connection: 2.2.2.2.47575 - 1.1.1.1.646
            State: Oper; Msgs sent/rcvd: 12/12; Downstream
            Up time: 00:04:14
            LDP discovery sources:
              Ethernet0/0, Src IP addr: [B]10.0.0.2[/B]
            Addresses bound to peer LDP Ident:
            [B]  10.0.0.2        2.2.2.2[/B]
        Peer LDP Ident: 3.3.3.3:0; Local LDP Ident 1.1.1.1:0
            TCP connection: 3.3.3.3.49266 - 1.1.1.1.646
            State: Oper; Msgs sent/rcvd: 11/11; Downstream
            Up time: 00:03:09
            LDP discovery sources:
              Ethernet0/1, Src IP addr: [B]10.0.1.3[/B]
            Addresses bound to peer LDP Ident:
              [B]10.0.1.3        3.3.3.3[/B]
    Bước 3: Cấu hình BGP giữa R2 và R3

    Code:
    R2(config)#[B]router bgp 1[/B]
    R2(config-router)#[B]neighbor 3.3.3.3 remote-as 1[/B]
    R2(config-router)#[B]neighbor 3.3.3.3 update-source loopback0[/B]
    R2(config-router)#[B]no auto-summary[/B]
    R2(config-router)#[B]address-family vpnv4[/B]
    R2(config-router-af)#[B]neighbor 3.3.3.3 activate[/B]
    Code:
    R3(config)[B]#router bgp 1[/B]
    R3(config-router)#[B]neighbor 2.2.2.2 remote-as 1[/B]
    R3(config-router)#[B]neighbor 2.2.2.2 update-source lo0[/B]
    [B]*Nov  4 09:07:57.539: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up[/B]
    R3(config-router)#[B]no auto-summary[/B]
    R3(config-router)#a[B]ddress-family vpnv4[/B]
    R3(config-router-af)#[B]neighbor 2.2.2.2 activate[/B]
    [B]*Nov  4 09:09:50.401: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Down Capability changed
    *Nov  4 09:09:50.401: %BGP_SESSION-5-ADJCHANGE: neighbor 2.2.2.2 IPv4 Unicast topology base removed from session  Capability changed
    *Nov  4 09:09:50.974: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up[/B]
    //Quan sát các log để biết cấu hình thành công hay không. Trong log ở trên thì cấu hình đã thành công.
    Thực hiện kiểm tra sessions bgp giữa R2 và R3 qua lệnh show bgp vpnv4 unicast all summary.

    Code:
    R2#[B]show bgp vpnv4 unicast all summary[/B]
    BGP router identifier 2.2.2.2, local AS number 1
    BGP table version is 1, main routing table version 1
    
    Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
    3.3.3.3         4            1       6       6        1    0    0 00:00:59        0
    Bước 4: Tạo VRF, trong bước này ta bắt đầu quan tâm đến 2 router ở biên là R4 và R5.
    Theo mô hình thì R4 và R5 thuộc ospf area 2. Nó có local site là lớp mạng 192.168.1.0/24.

    Code:
    R4(config)#[B]int lo0[/B]
    R4(config-if)#[B]ip add 4.4.4.4 255.255.255.255[/B]
    R4(config-if)#i[B]p ospf 2 area 2[/B]
    R4(config)#[B]int e0/0[/B]
    R4(config-if)#[B]ip add 192.168.1.4 255.255.255.0[/B]
    R4(config-if)#[B]ip ospf 2 area 2[/B]
    R4(config-if)#[B]no shut[/B]
    VRF sẽ chia bảng định tuyến của chúng ta ra độc lập với tên RED.

    Code:
    R2(config)#[B]int e0/1[/B]
    R2(config-if)#[B]ip add 192.168.1.2 255.255.255.0[/B]
    R2(config-if)#[B]no shut[/B]
    
    R2(config)#[B]ip vrf RED[/B]
    R2(config-vrf)#[B]rd 4:4[/B]
    R2(config-vrf)[B]#route-target both 4:4[/B]
    R2(config)#i[B]nt e0/1[/B]
    R2(config-if)#[B]ip vrf forwarding RED[/B]
    %[B] Interface Ethernet0/1 IPv4 disabled and address(es) removed due to enabling VRF RED[/B]
    //Sau khi cấu hình vrf xong thì chúng ta sẽ bị mất ip cho cổng, vì thế cần cấu hình lại địa chỉ ip.
    R2(config-if)#[B]ip add 192.168.1.2 255.255.255.0[/B]
    Code:
    R2#[B]show run int e0/1[/B]
    Building configuration...
    
    Current configuration : 90 bytes
    !
    interface Ethernet0/1
     ip vrf forwarding RED
     ip address 192.168.1.2 255.255.255.0
    end
    Code:
    R2#show 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, l - LISP
           + - replicated route, % - next hop override
    
    Gateway of last resort is not set
    
          1.0.0.0/32 is subnetted, 1 subnets
    O        1.1.1.1 [110/11] via 10.0.0.1, 00:39:44, Ethernet0/0
          2.0.0.0/32 is subnetted, 1 subnets
    C        2.2.2.2 is directly connected, Loopback0
          3.0.0.0/32 is subnetted, 1 subnets
    O        3.3.3.3 [110/21] via 10.0.0.1, 00:39:44, Ethernet0/0
          10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
    C        10.0.0.0/24 is directly connected, Ethernet0/0
    L        10.0.0.2/32 is directly connected, Ethernet0/0
    O        10.0.1.0/24 [110/20] via 10.0.0.1, 00:39:44, Ethernet0/0
    Chúng ta cần cấu hình ospf trên cổng e0/1.

    Code:
    R2(config)#[B]int e0/1[/B]
    R2(config-if)#[B]ip ospf 2 area 2[/B]
    [B]*Nov  4 09:55:33.869: %OSPF-5-ADJCHG: Process 2, Nbr 4.4.4.4 on Ethernet0/1 from LOADING to FULL, Loading Done[/B]


    Tiến hành kiểm tra cấu hình.

    Code:
    R2#[B]show ip route vrf RED[/B]
    
    Routing Table: RED
    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, l - LISP
           + - replicated route, % - next hop override
    
    Gateway of last resort is not set
    
          4.0.0.0/32 is subnetted, 1 subnets
    O        4.4.4.4 [110/11] via 192.168.1.4, 00:00:47, Ethernet0/1
          192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
    C        192.168.1.0/24 is directly connected, Ethernet0/1
    L        192.168.1.2/32 is directly connected, Ethernet0/1
    Trên R5 và R3 chúng ta thực hiện tương tự R4 và R2.

    Code:
    R5(config)#[B]int lo0[/B]
    R5(config-if)#[B]ip add 5.5.5.5 255.255.255.255[/B]
    R5(config-if)#[B]ip ospf 2 area 2[/B]
    R5(config-if)#[B]exit[/B]
    R5(config)[B]#int e0/0[/B]
    R5(config-if)#[B]ip add 192.168.2.5 255.255.255.0[/B]
    R5(config-if)#i[B]p ospf 2 area 2[/B]
    R5(config-if)#[B]no shut[/B]
    R5(config-if)[B]#exit[/B]
    Code:
    R3(config)[B]#int e0/1[/B]
    R3(config-if)# [B] ip address 192.168.2.3 255.255.255.0[/B]
    R3(config-if)# [B]no shut[/B]
    Code:
    R3(config)#i[B]p vrf RED[/B]
    R3(config-vrf)#[B]rd 4:4[/B]
    R3(config-vrf)#[B]route-target both 4:4[/B]
    R3(config)#[B]int e0/1[/B]
    R3(config-if)#[B]ip vrf forwarding RED[/B]
    [B]% Interface Ethernet0/1 IPv4 disabled and address(es) removed due to enabling VRF RED[/B]
    R3(config-if)# [B]ip address 192.168.2.3 255.255.255.0[/B]
    Code:
    R3(config)#[B] int e0/1[/B]
    R3(config-if)#[B] ip ospf 2 area 2[/B]
    Kiểm tra cấu hình VRF trên R3.

    Code:
    R3#[B]show ip route vrf RED[/B]
    
    Routing Table: RED
    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, l - LISP
           + - 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/11] via 192.168.2.5, 00:07:38, Ethernet0/1
          192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
    C        192.168.2.0/24 is directly connected, Ethernet0/1
    L        192.168.2.3/32 is directly connected, Ethernet0/1
    Như vậy R1,R2 và R3 sẽ chạy OSPF cho tất cả các loopbacak của chúng. R2 và R3 giao tiếp với nhau qua BGP. LDP được kích hoạt trên tất cả các internal interface. Các external interface thuộc MPLS Core được đặt trong 1 VRF có tên là RED và các router biên sẽ được join vào VRF trên mỗi router R2 và R3.
    Thực hiện redistribute OSPF vào BGP trên R2.


    Code:
    R2(config)#[B]router bgp 1[/B]
    R2(config-router)#a[B]ddress-family ipv4 vrf RED[/B]
    R2(config-router-af)#r[B]edistribute ospf 2[/B]
    R2(config-router-af)#[B]exit[/B]
    Chúng ta làm tương tự trên R3.
    Code:
    R3(config)#[B]router bgp 1[/B]
    R3(config-router)#[B]address-family ipv4 vrf RED[/B]
    R3(config-router-af)#[B]redistribute ospf 2[/B]
    Code:
    R2#s[B]how ip bgp vpnv4 vrf RED[/B]
    BGP table version is 7, 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, f RT-Filter,
                  x best-external, a additional-path, c RIB-compressed,
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found
    
         Network          Next Hop            Metric LocPrf Weight Path
    Route Distinguisher: 4:4 (default for vrf RED)
     *>  4.4.4.4/32       192.168.1.4             11         32768 ?
     *>i 5.5.5.5/32       3.3.3.3                 11    100      0 ?
     *>  192.168.1.0      0.0.0.0                  0         32768 ?
     *>i 192.168.2.0      3.3.3.3                  0    100      0 ?
    Chúng ta có thể thấy địa chỉ 4.4.4.4/32 đã có trong bảng định tuyển BGP của vrf RED với next hop là 192.168.1.4 của R4 và 5.5.5.5 có nexthop là địa chỉ 3.3.3.3 của R3. Tương tự trên R3.

    Code:
    R3#[B]show ip BGP vpnv4 vrf RED[/B]
    BGP table version is 7, 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, m multipath, b backup-path, f RT-Filter,
                  x best-external, a additional-path, c RIB-compressed,
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found
    
         Network          Next Hop            Metric LocPrf Weight Path
    Route Distinguisher: 4:4 (default for vrf RED)
     *>i 4.4.4.4/32       2.2.2.2                 11    100      0 ?
     *>  5.5.5.5/32       192.168.2.5             11         32768 ?
     *>i 192.168.1.0      2.2.2.2                  0    100      0 ?
     *>  192.168.2.0      0.0.0.0                  0         32768 ?
    Cuối cùng, chúng ta cần redistribute ngược lại bgp vào ospf để có thể có kết nối end to end.

    Code:
    R2(config)#[B]router ospf 2[/B]
    R2(config-router)#[B]redistribute bgp 1 subnets[/B]
    Code:
    R3(config)#[B]router ospf 2[/B]
    R3(config-router)#[B]redistribute bgp 1 subnets[/B]
    Để chứng tỏ gói tin chạy trên MPLS và địa chuyển mạch nhãn mà không route, thực hiện lệnh trace từ R4 sang R5

    Code:
    R4#[B]trace 5.5.5.5[/B]
    Type escape sequence to abort.
    Tracing the route to 5.5.5.5
    VRF info: (vrf in name/id, vrf out name/id)
      1 192.168.1.2 1 msec 1 msec 0 msec
      [B]2[/B] [B]10.0.0.1 [MPLS: Labels 16/19 Exp 0] 2 msec 3 msec 3 msec
      3 192.168.2.3 [MPLS: Label 19 Exp 0] 2 msec 2 msec 2 msec[/B]
      4 192.168.2.5 3 msec 3 msec *








Working...
X