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]
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]
Để 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]
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
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]
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.
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
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]
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
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
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]
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
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]
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 ?
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 ?
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]
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 *