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.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lab MPLS cơ bản

    Lab MPLS cơ bản
    1. Sơ đồ bài lab
    Click image for larger version

Name:	dataurl394634.png
Views:	22
Size:	25.2 KB
ID:	431056
    1. Yêu cầu
    1. Cấu hình OSPF để R1, R2, R3 có thể đi đến nhau được
    2. Cấu hình bật giao thức phân phối nhãn LDP trên các cổng router R1, R2, R3
    3. Cấu hình iBGP giữa R2 và R3
    4. Tạo VRF trên R2 và R3, cấu hình định tuyến OSPF với R4 và R5 sau đó kiểm tra hoạt động MPLS
    1. 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.
    R1(config)#int lo 0
    R1(config-if)#ip add 1.1.1.1 255.255.255.255
    R1(config-if)#ip ospf 1 area 0

    R1(config)#int e0/0
    R1(config-if)#ip add 10.0.0.1 255.255.255.0
    R1(config-if)#no shut
    R1(config-if)#ip ospf 1 area 0

    R1(config)#int e0/1
    R1(config-if)#ip add 10.0.1.1 255.255.255.0
    R1(config-if)#no shut
    R1(config-if)#ip ospf 1 area 0
    R2(config)#int lo 0
    R2(config-if)#ip add 2.2.2.2 255.255.255.255
    R2(config-if)#ip ospf 1 area 0

    R2(config)#int e0/0
    R2(config-if)#ip add 10.0.0.2 255.255.255.0
    R2(config-if)#no shut
    R2(config-if)#ip ospf 1 area 0
    R3(config)#int lo0
    R3(config-if)#ip add 3.3.3.3 255.255.255.255
    R3(config-if)#ip ospf 1 area 0
    R3(config-if)#exit

    R3(config)#int e0/0
    R3(config-if)#ip add 10.0.1.3 255.255.255.0
    R3(config-if)#no shut
    R3(config-if)#ip ospf 1 area 0
    Thực hiện ping test từ R2 sang R3 với source là loopback của R2.
    R2#ping 3.3.3.3 source lo0
    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
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
    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 giao thức LDP, 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.
    R1(config)#router ospf 1
    R1(config-router)#mpls ldp autoconfig
    *Nov 4 08:54:47.466: %LDP-5-NBRCHG: LDP Neighbor 2.2.2.2:0 (1) is UP
    R2(config)#router ospf 1
    R2(config-router)#mpls ldp autoconfig
    R2(config-router)#exit
    *Nov 4 08:54:47.446: %LDP-5-NBRCHG: LDP Neighbor 1.1.1.1:0 (1) is UP
    R3(config)#router ospf 1
    R3(config-router)#mpls ldp autoconfig
    *Nov 4 08:55:57.316: %SYS-5-CONFIG_I: Configured from console by console
    Kiểm tra cấu hình MPLS trên các cổng của R1 với lệnh show mpls interface.
    R1#show mpls interface
    Interface IP Tunnel BGP Static Operational
    Ethernet0/0 Yes (ldp) No No No Yes
    Ethernet0/1 Yes (ldp) No No No Yes
    Kiểm tra LDP neighbors với lệnh show mpls ldp neighbors
    R1#show mpls ldp neigh
    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: 10.0.0.2
    Addresses bound to peer LDP Ident:
    10.0.0.2 2.2.2.2
    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: 10.0.1.3
    Addresses bound to peer LDP Ident:
    10.0.1.3 3.3.3.3
    Bước 3: Cấu hình BGP giữa R2 và R3
    R2(config)#router bgp 1
    R2(config-router)#neighbor 3.3.3.3 remote-as 1
    R2(config-router)#neighbor 3.3.3.3 update-source loopback0
    R2(config-router)#no auto-summary
    R2(config-router)#address-family vpnv4
    R2(config-router-af)#neighbor 3.3.3.3 activate
    R3(config)#router bgp 1
    R3(config-router)#neighbor 2.2.2.2 remote-as 1
    R3(config-router)#neighbor 2.2.2.2 update-source lo0
    *Nov 4 09:07:57.539: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up
    R3(config-router)#no auto-summary
    R3(config-router)#address-family vpnv4
    R3(config-router-af)#neighbor 2.2.2.2 activate
    *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

    //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.
    R2#show bgp vpnv4 unicast all summary
    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.
    R4(config)#int lo0
    R4(config-if)#ip add 4.4.4.4 255.255.255.255
    R4(config-if)#ip ospf 2 area 2
    R4(config)#int e0/0
    R4(config-if)#ip add 192.168.1.4 255.255.255.0
    R4(config-if)#ip ospf 2 area 2
    R4(config-if)#no shut
    VRF sẽ chia bảng định tuyến của chúng ta ra độc lập với tên RED
    R2(config)#ip vrf RED
    R2(config-vrf)#rd 4:4
    R2(config-vrf)#route-target both 4:4
    R2(config)#int e0/1
    R2(config-if)#ip vrf forwarding RED
    % Interface Ethernet0/1 IPv4 disabled and address(es) removed due to enabling VRF RED
    //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 địa chỉ ip.
    R2(config-if)#ip add 192.168.1.2 255.255.255.0
    R2(config-if)#no shut
    R2#show run int e0/1
    Building configuration...

    Current configuration : 90 bytes
    !
    interface Ethernet0/1
    ip vrf forwarding RED
    ip address 192.168.1.2 255.255.255.0
    end
    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.
    R2(config)#int e0/1
    R2(config-if)#ip ospf 2 area 2
    *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
    Tiến hành kiểm tra cấu hình.
    R2#show ip route vrf RED

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

    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.
    R2(config)#router bgp 1
    R2(config-router)#address-family ipv4 vrf RED
    R2(config-router-af)#redistribute ospf 2
    R2(config-router-af)#exit
    Chúng ta làm tương tự trên R3.
    R3(config)#router bgp 1
    R3(config-router)#address-family ipv4 vrf RED
    R3(config-router-af)#redistribute ospf 2
    R2#show ip bgp vpnv4 vrf RED
    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. Tương tự trên R3.
    R3#show ip BGP vpnv4 vrf RED
    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 ?
    Địa chỉ 5.5.5.5/32 đã có trong bảng định tuyến BGP của vrf RED với next hop là 192.168.2.5 của R5
    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.
    R2(config)#router ospf 2
    R2(config-router)#redistribute bgp 1 subnets


    R3(config)#router ospf 2
    R3(config-router)#redistribute bgp 1 subnets
    Để 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
    R4#trace 5.5.5.5
    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
    2 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
    4 192.168.2.5 3 msec 3 msec *
Working...
X