/*auto readmore*/ /*auto readmore*/ /* an hien script*/ // an hien password /*an hien ma chuong trinh cong tru */ /*Scrollbox thanh cuon*/ /***Nhung CODE***/ /* dòng xanh dòng trắng */ /* https://cdnjs.com/libraries/prism lay thu vien, can vao ten file ma goi 1. copy link vao vi du:prism-python.min.js 2. ten ngon nua la python */ /*=== New posts ===*/ /*header slider*/ /*=== bai viet lien quan===*/ /*===tabcode===*/
Showing posts with label GRE. Show all posts
Showing posts with label GRE. Show all posts

Bài 1: Tìm hiểu về MPLS/BGP Free core

Giới thiệu:

đang cập nhật...

Sơ đồ Lab:

Yêu cầu:
1. Cấu hình IP như sơ đồ
2. Chạy giao thức định tuyến trong IGP (giao thức nào cũng được), đảm bảo mọi IP trong vùng AS 200 phải thông nhau. Trong bài lab này ta chọn OSPF.
3. Cấu hình eBGP giữa các Router CE và PE (R1 với R2 và R5 với R6)
4. Cấu hình GRE giữa R2 với R5
5. Cấu hình iBGP giữa các router PE (R2 và R5) đảm bảo loopback 0 của R1 và R6 phải thông nhau
6. Xóa bỏ cấu hình ở yêu cầu 4, 5
7. Cấu hình iBGP giữa R2 và R5
8. Enable MPLS trên tất cả các interface kết nối giữa các router PE, P (R2, R3, R4, R5)

Các kiến thức sử dụng trong bài
: OSPF, GRE, BGP, MPLS

Cấu hình:
1. Cấu hình IP như sơ đồ:

R1:

interface Ethernet0/1
ip address 192.168.12.1 255.255.255.0
no shutdown
exit
interface Loopback0
ip address 192.168.1.1 255.255.255.0
end
write

R2:
interface Ethernet0/0
ip address 192.168.12.2 255.255.255.0
no shutdown
exit
interface Ethernet0/1
ip address 192.168.23.2 255.255.255.0
no shutdown
exit
interface Loopback0
ip address 192.168.2.1 255.255.255.0
end
write

R3:
interface Ethernet0/0
 ip address 192.168.23.3 255.255.255.0
no shutdown
exit
interface Ethernet0/1
 ip address 192.168.34.3 255.255.255.0
no shutdown
exit
interface Loopback0
 ip address 192.168.3.1 255.255.255.0
end
write

R4:
interface Ethernet0/0
ip address 192.168.34.4 255.255.255.0
no shutdown
exit
interface Ethernet0/1
ip address 192.168.45.4 255.255.255.0
no shutdown
exit
interface Loopback0
ip address 192.168.4.1 255.255.255.0
end
write

R5:
interface Ethernet0/0
 ip address 192.168.45.5 255.255.255.0
no shutdown
exit
interface Ethernet0/1
 ip address 192.168.56.5 255.255.255.0
no shutdown
exit
interface Loopback0
 ip address 192.168.5.1 255.255.255.0
end
write

R6:
interface Ethernet0/0
 ip address 192.168.56.6 255.255.255.0
no shutdown
exit
interface Loopback0
 ip address 192.168.6.1 255.255.255.0
end
write

2. Chạy giao thức định tuyến trong IGP (giao thức nào cũng được), đảm bảo mọi IP trong vùng AS 200 phải thông nhau. Trong bài lab này ta chọn OSPF.

R2:
router ospf 1
router-id 192.168.2.1
exit
interface range ethernet 0/1, loopback 0
ip ospf 1 area 0
do write

R3:
router ospf 1
router-id 192.168.3.1
exit
interface range ethernet 0/0-1, loopback 0
ip ospf 1 area 0
do write

R4:
router ospf 1
router-id 192.168.4.1
exit
interface range ethernet 0/0-1, loopback 0
ip ospf 1 area 0
do write

R5:
router ospf 1
router-id 192.168.5.1
exit
interface range ethernet 0/0, loopback 0
ip ospf 1 area 0
do write

Kiểm tra bảng định tuyến của các Router trong vùng AS 200 (R2, R3, R4, R5) để chắc chắn mọi địa chỉ phải đi đến được với nhau sau khi cấu hình OSPF


R2#show ip route ospf
O        192.168.3.1 [110/11] via 192.168.23.3, 15:24:42, Ethernet0/1
      192.168.4.0/32 is subnetted, 1 subnets
O        192.168.4.1 [110/21] via 192.168.23.3, 15:23:26, Ethernet0/1
      192.168.5.0/32 is subnetted, 1 subnets
O        192.168.5.1 [110/31] via 192.168.23.3, 15:23:16, Ethernet0/1
O     192.168.34.0/24 [110/20] via 192.168.23.3, 15:23:36, Ethernet0/1
O     192.168.45.0/24 [110/30] via 192.168.23.3, 15:23:26, Ethernet0/1
R3#show  ip route ospf
O        192.168.2.1 [110/11] via 192.168.23.2, 15:24:24, Ethernet0/0
      192.168.4.0/32 is subnetted, 1 subnets
O        192.168.4.1 [110/11] via 192.168.34.4, 15:23:17, Ethernet0/1
      192.168.5.0/32 is subnetted, 1 subnets
O        192.168.5.1 [110/21] via 192.168.34.4, 15:22:56, Ethernet0/1
O     192.168.45.0/24 [110/20] via 192.168.34.4, 15:23:06, Ethernet0/1
R4#show  ip route ospf 
O        192.168.2.1 [110/21] via 192.168.34.3, 15:23:46, Ethernet0/0
      192.168.3.0/32 is subnetted, 1 subnets
O        192.168.3.1 [110/11] via 192.168.34.3, 15:23:46, Ethernet0/0
      192.168.5.0/32 is subnetted, 1 subnets
O        192.168.5.1 [110/11] via 192.168.45.5, 15:23:34, Ethernet0/1
O     192.168.23.0/24 [110/20] via 192.168.34.3, 15:23:46, Ethernet0/0
R5#show ip route ospf
O        192.168.2.1 [110/31] via 192.168.45.4, 15:23:44, Ethernet0/0
      192.168.3.0/32 is subnetted, 1 subnets
O        192.168.3.1 [110/21] via 192.168.45.4, 15:23:44, Ethernet0/0
      192.168.4.0/32 is subnetted, 1 subnets
O        192.168.4.1 [110/11] via 192.168.45.4, 15:23:44, Ethernet0/0
O     192.168.23.0/24 [110/30] via 192.168.45.4, 15:23:44, Ethernet0/0
O     192.168.34.0/24 [110/20] via 192.168.45.4, 15:23:44, Ethernet0/0

3. Cấu hình eBGP giữa các Router CE và PE (R1 với R2 và R5 với R6).

R1: quảng bá loopback 0 vào eBGP cho router PE (R2) học
router bgp 100
 network 192.168.1.0 mask 255.255.255.0
 neighbor 192.168.12.2 remote-as 200

R2:
router bgp 200
neighbor 192.168.12.1 remote-as 100

R5:
router bgp 200
 neighbor 192.168.56.6 remote-as 300

R6: quảng bá loopback 0 vào eBGP cho router PE (R5) học
router bgp 300
 network 192.168.6.0 mask 255.255.255.0
 neighbor 192.168.56.5 remote-as 200

Kiểm tra trên các router PE (R2 và R5) đã học được loopback 0 sau khi chạy BGP

R2#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 200", distance 20, metric 0
  Tag 100, type external
  Last update from 192.168.12.1 00:07:40 ago
  Routing Descriptor Blocks:
  * 192.168.12.1, from 192.168.12.1, 00:07:40 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 100
      MPLS label: none
R2#show ip route bgp
B     192.168.1.0/24 [20/0] via 192.168.12.1, 00:09:45

R5#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 200", distance 20, metric 0
  Tag 300, type external
  Last update from 192.168.56.6 00:09:38 ago
  Routing Descriptor Blocks:
  * 192.168.56.6, from 192.168.56.6, 00:09:38 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 300
      MPLS label: none
R5#show ip route bgp
B     192.168.6.0/24 [20/0] via 192.168.56.6, 00:09:46

4. Cấu hình GRE giữa R2 với R5


Để tạo ra BGP free core trong vùng AS 200 chúng ta có rất nhiều cách: 
  • Có thể dùng GRE để thiết lập tunnel giữa các con PE router (trong bài lab này là R2 với R5), được thực hiện ở yêu cầu số 4 
  • Hoặc enable MPLS trên các interface đấu nối giữa các router PE và router CE (noted: interface loopback không hỗ trợ enable MPLS), sẽ thực hiện ở yêu cầu số 6

Thiết lập tunnel giữa R2 và R5, ip address của tunnel 0 trên R2 là 192.168.25.2
R2:
!
interface Tunnel0
 ip address 192.168.25.2 255.255.255.0
tunnel mode gre ip
 tunnel source 192.168.2.1
 tunnel destination 192.168.5.1
end


Thiết lập tunnel giữa R2 và R5, ip address của tunnel 0 trên R5 là 192.168.25.5
R5:
!
interface Tunnel0
 ip address 192.168.25.5 255.255.255.0
tunnel mode gre ip
 tunnel source 192.168.5.1
 tunnel destination 192.168.2.1
end

Kiểm tra hoạt động của tunnel:
R2#show interfaces tunnel 0
Tunnel0 is up, line protocol is up 
  Hardware is Tunnel
  Internet address is 192.168.25.2/24
  MTU 17916 bytes, BW 100 Kbit/sec, DLY 50000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation TUNNEL, loopback not set
  Keepalive not set
  Tunnel source 192.168.2.1, destination 192.168.5.1
  Tunnel protocol/transport GRE/IP
  (...)

R5#show interfaces tunnel 0
Tunnel0 is up, line protocol is up 
  Hardware is Tunnel
  Internet address is 192.168.25.5/24
  MTU 17916 bytes, BW 100 Kbit/sec, DLY 50000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation TUNNEL, loopback not set
  Keepalive not set
  Tunnel source 192.168.5.1, destination 192.168.2.1
  Tunnel protocol/transport GRE/IP
   (...)


5. Cấu hình iBGP giữa các router PE (R2 và R5) đảm bảo loopback 0 của R1 và R6 phải thông nhau

R2:
router bgp 200
 neighbor 192.168.25.5 remote-as 200
 neighbor 192.168.25.5 next-hop-self

R5:
router bgp 200
 neighbor 192.168.25.2 remote-as 200
 neighbor 192.168.25.2 next-hop-self

Kiểm tra kết nối giữa loopback 0 (IP: 192.168.1.1) của R1 và loopback 0 (IP: 192.168.6.1) của R6
R1#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 100", distance 20, metric 0
  Tag 200, type external
  Last update from 192.168.12.2 00:13:16 ago
  Routing Descriptor Blocks:
  * 192.168.12.2, from 192.168.12.2, 00:13:16 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 200
      MPLS label: none
R1#traceroute 192.168.6.1 source 192.168.1.1 numeric 
Type escape sequence to abort.
Tracing the route to 192.168.6.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.12.2 1 msec 0 msec 1 msec
  2 192.168.25.5 1 msec 1 msec 1 msec
  3 192.168.56.6 1 msec *  1 msec
R1#ping 192.168.6.1 source 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/3 ms

R6#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 300", distance 20, metric 0
  Tag 200, type external
  Last update from 192.168.56.5 00:17:52 ago
  Routing Descriptor Blocks:
  * 192.168.56.5, from 192.168.56.5, 00:17:52 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 200
      MPLS label: none
R6#traceroute 192.168.1.1 source 192.168.6.1 numeric
Type escape sequence to abort.
Tracing the route to 192.168.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.56.5 1 msec 1 msec 0 msec
  2 192.168.25.2 1 msec 2 msec 2 msec
  3 192.168.12.1 6 msec *  2 msec
R6#ping 192.168.1.1 source 192.168.6.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.6.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

Đến đây 2 loopback 0 của R1 và R6 đã thông nhau thông qua BGP free core. Ta có thể bắt gói trên các interface của các router P (R3 và R4) để phân tích:


Ta thấy trong phần IP header có source là 192.168.2.1 và destination là 192.168.5.1 cả router P học được từ OSPF. Và để 2 loopback o của R1 và R6 thông nhau nhờ vào thiết lập GRE giữa R2 và R5. và chính tunnel của GRE trong trường hợp này là tạo BGP free core.

6. Xóa bỏ cấu hình ở yêu cầu 4, 5

  • Remove cấu hình GRE trên R2 và R5
R2, R5:
no interface Tunnel0

  • Remove cấu hình iBGP giữa R2 với R5

R2:
router bgp 200
no neighbor 192.168.25.5 next-hop-self
no neighbor 192.168.25.5 remote-as 200

R5:
router bgp 200
no neighbor 192.168.25.2 next-hop-self
no neighbor 192.168.25.2 remote-as 200

7. Cấu hình iBGP giữa R2 và R5

Dùng IP trên interface loopback 0 của R2 và R5 thể thiết lập neighbor cho iBGP

R2:
router bgp 200
 neighbor 192.168.5.1 remote-as 200
 neighbor 192.168.5.1 update-source Loopback0
 neighbor 192.168.5.1 next-hop-self

R5:
router bgp 200
 neighbor 192.168.2.1 remote-as 200
 neighbor 192.168.2.1 update-source Loopback0
 neighbor 192.168.2.1 next-hop-self


  • Kiểm tra thiết lập neighbor sau khi cấu hình iBGP

R2#show ip bgp summary 
(...)
Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.5.1      4          200         9         8        7    0    0 00:03:10        1
192.168.12.1    4          100     302     301        7    0    0 04:29:43        1
R5#show ip bgp summary
(...)
Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.2.1      4          200         8         9        5    0    0 00:02:54        1
192.168.56.6    4          300     300     298        5    0    0 04:26:38        1



  • Kiểm tra kết nối giữa 2 loopback 0 của R1 và R6

R1#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 100", distance 20, metric 0
  Tag 200, type external
  Last update from 192.168.12.2 00:20:58 ago
  Routing Descriptor Blocks:
  * 192.168.12.2, from 192.168.12.2, 00:20:58 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 200
      MPLS label: none
R2#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 200", distance 200, metric 0
  Tag 300, type internal
  Last update from 192.168.5.1 00:18:22 ago
  Routing Descriptor Blocks:
  * 192.168.5.1, from 192.168.5.1, 00:18:22 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 300
      MPLS label: none

R6#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 300", distance 20, metric 0
  Tag 200, type external
  Last update from 192.168.56.5 00:25:51 ago
  Routing Descriptor Blocks:
  * 192.168.56.5, from 192.168.56.5, 00:25:51 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 200
      MPLS label: none
R5#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 200", distance 200, metric 0
  Tag 100, type internal
  Last update from 192.168.2.1 00:27:28 ago
  Routing Descriptor Blocks:
  * 192.168.2.1, from 192.168.2.1, 00:27:28 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 100
      MPLS label: none

R1 và R6 đã học được các lớp mạng loopback 0 đã quảng bá nhờ vào kết nối iBGP giữa R2 và R5. Tuy nhiên khi tracertroute 192.168.6.1 từ R1, route này sẽ không đi đến được

R1#traceroute 192.168.6.1 source 192.168.1.1 numeric
Type escape sequence to abort.
Tracing the route to 192.168.6.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.12.2 0 msec 6 msec 0 msec
  2  *  *  *
  3  *  *  *
  4  *  *  *
  5  *  *  *
   (...)

vì các con router P (R3, R4) không chạy BGP với R2 và R5 nên nó không có thông tin về route này nên gói tin sẽ bị drop.

R3#show ip route 192.168.6.1
% Network not in table

Lỗi này gọi là back hole, R3 và R4 là "hố đen" đã hút mất gói tin khi chuyển qua đường đi của nó.

Để khắc phục lỗi này chúng ta có rất nhiều kỹ thuật ví dụ như: cho các router P (R3, R4) tham gia vào định tuyến BGP, hay redistribute BGP vào OSPF ở trên các router PE (R2, R5), tuy nhiên sẽ tốn rất nhiều tài nguyên. 

Yêu cầu 8 sẽ dùng MPLS để giải quyết vấn đề này.

8. Enable MPLS trên tất cả các interface kết nối giữa các router PE, P (R2, R3, R4, R5)

R2:
interface Ethernet0/1
mpls ip

R3, R4:
interface range ethernet 0/0-1
mpls ip

R5:
interface Ethernet0/0
mpls ip

  • Kiểm tra kết nối sau khi enable mpls

R1#ping 192.168.6.1 source 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
R1#traceroute 192.168.6.1 source 192.168.1.1 numeric
Type escape sequence to abort.
Tracing the route to 192.168.6.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.12.2 1 msec 1 msec 0 msec
  2 192.168.23.3 [MPLS: Label 18 Exp 0] 2 msec 1 msec 2 msec
  3  *  *  *
  4 192.168.45.5 1 msec 2 msec 1 msec
  5 192.168.56.6 2 msec *  2 msec

R6#ping 192.168.1.1 source 192.168.6.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.6.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
R6#traceroute 192.168.1.1 source 192.168.6.1 numeric 
Type escape sequence to abort.
Tracing the route to 192.168.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.56.5 1 msec 0 msec 0 msec
  2 192.168.45.4 [MPLS: Label 16 Exp 0] 1 msec 2 msec 1 msec
  3  *  *  *
  4 192.168.23.2 2 msec 1 msec 1 msec
  5 192.168.12.1 1 msec *  2 msec
Vậy các loopback 0 của R1 và R6 đã thông nhau nhờ sử dụng kỹ thuật MPLS. Khi chúng ta enable MPLS các router sẽ dùng label để forward gói tin.

R2#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 200", distance 200, metric 0
  Tag 300, type internal
  Last update from 192.168.5.1 02:44:26 ago
  Routing Descriptor Blocks:
  * 192.168.5.1, from 192.168.5.1, 02:44:26 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 300
      MPLS label: none

Để đến được 192.168.6.1 thì phải thông qua next hop là 192.168.5.1. Thông thường router sẽ kiểm tra trong bảng routing để quyết định forward đến next hop nào, cổng nào, ở đây MPLS dùng nhãn để forward gói tin.

R2#show  mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         No Label   192.168.3.1/32   0             Et0/1      192.168.23.3
17         17              192.168.4.1/32   0             Et0/1      192.168.23.3
18         18              192.168.5.1/32   0             Et0/1      192.168.23.3
19         Pop Label  192.168.34.0/24  0            Et0/1      192.168.23.3
20         19              192.168.45.0/24  0             Et0/1      192.168.23.3

cũng có thể kiểm tra bảng CEF (cisco express forwarding) để biết được từ R1 đến địa chỉ 192.168.6.1 dùng nhãn là số bao nhiêu và thông qua cổng nào (xem bài Quá trình trao đổi nhãn trong MPLS)

R2#show ip cef 192.168.6.1
192.168.6.0/24
  nexthop 192.168.23.3 Ethernet0/1 label 18

Phân tích gói tin trên whileshark



Ta thấy MPLS header chèn vào giữa lớp Ethernet và lớp Internet, đó cũng chính là lý do người ta gọi MPLS hoạt động ở lớp 2.5.

Trong các router P (R3, R4) cũng dùng nhãn để forward gói tin
R3#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         No Label   192.168.2.1/32   20931         Et0/0      192.168.23.2
17         No Label   192.168.4.1/32   0                 Et0/1      192.168.34.4
18         18              192.168.5.1/32   22092         Et0/1      192.168.34.4
19         Pop Label  192.168.45.0/24  0                Et0/1      192.168.34.4

Riêng R4 thì nhãn sẽ được remove ra trước, sau đó chuyển gói tin IP cho PE (R5). Tại sao R4 làm vậy sẽ được thảo luận trong phần Quá trình trao đổi nhãn trong MPLS.
R4#show mpls forwarding-table 
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         16             192.168.2.1/32   22317         Et0/0      192.168.34.3
17         No Label   192.168.3.1/32      0             Et0/0      192.168.34.3
18         No Label   192.168.5.1/32   21239        Et0/1      192.168.45.5
19         Pop Label  192.168.23.0/24    0             Et0/0      192.168.34.3

R5 nhận được gói tin IP không có lable và forward cho R6 như bình thường. Khi R6 nhận được thì trả lời ICMP reply và sẽ kết thúc tại R5.
R5#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 200", distance 200, metric 0
  Tag 100, type internal
  Last update from 192.168.2.1 03:35:59 ago
  Routing Descriptor Blocks:
  * 192.168.2.1, from 192.168.2.1, 03:35:59 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 100
      MPLS label: none
R5 biết rằng để đến 192.168.1.1 sẽ dùng next-hop là 192.168.2.1.
R5#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         16              192.168.2.1/32   0                 Et0/0      192.168.45.4
17         17              192.168.3.1/32   0                 Et0/0      192.168.45.4
18         No Label   192.168.4.1/32   0                 Et0/0      192.168.45.4
19         19              192.168.23.0/24  0                Et0/0      192.168.45.4
20         Pop Label  192.168.34.0/24  0                Et0/0      192.168.45.4

R5 sẽ thêm lable 16 vào gói tin IP và forward ra cổng Et0/0 để đến router P (R4)
R5#show  ip cef 192.168.1.1
192.168.1.0/24
  nexthop 192.168.45.4 Ethernet0/0 label 16

Router R4 sẽ forward sang R3
R4#show mpls forwarding-table 
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         16             192.168.2.1/32   211146        Et0/0      192.168.34.3
17         No Label   192.168.3.1/32       0             Et0/0      192.168.34.3
18         No Label   192.168.5.1/32   196413       Et0/1      192.168.45.5
19         Pop Label  192.168.23.0/24     0             Et0/0      192.168.34.3

R3 sẽ remove lable và forward đến R2 qua interface Et0/0
R3#show mpls forwarding-table 
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     
Switched      interface           
16         No Label   192.168.2.1/32   
196480        Et0/0      192.168.23.2
17         No Label   192.168.4.1/32        0             Et0/1      192.168.34.4
18         18         192.168.5.1/32        211588        Et0/1      192.168.34.4
19         Pop Label  192.168.45.0/24      0            Et0/1      192.168.34.4

R2 forward gói tin IP không lable đến R1.

Hy vọng rằng chúng ta hiểu, biết sử dụng MPLS để tạo ra tunnel giữa các con router PE để tạo BGP free core.

Xong!


Bài 1: Tìm hiểu về MPLS/BGP Free core

Giới thiệu:

đang cập nhật...

Sơ đồ Lab:

Yêu cầu:
1. Cấu hình IP như sơ đồ
2. Chạy giao thức định tuyến trong IGP (giao thức nào cũng được), đảm bảo mọi IP trong vùng AS 200 phải thông nhau. Trong bài lab này ta chọn OSPF.
3. Cấu hình eBGP giữa các Router CE và PE (R1 với R2 và R5 với R6)
4. Cấu hình GRE giữa R2 với R5
5. Cấu hình iBGP giữa các router PE (R2 và R5) đảm bảo loopback 0 của R1 và R6 phải thông nhau
6. Xóa bỏ cấu hình ở yêu cầu 4, 5
7. Cấu hình iBGP giữa R2 và R5
8. Enable MPLS trên tất cả các interface kết nối giữa các router PE, P (R2, R3, R4, R5)

Các kiến thức sử dụng trong bài
: OSPF, GRE, BGP, MPLS

Cấu hình:
1. Cấu hình IP như sơ đồ:

R1:

interface Ethernet0/1
ip address 192.168.12.1 255.255.255.0
no shutdown
exit
interface Loopback0
ip address 192.168.1.1 255.255.255.0
end
write

R2:
interface Ethernet0/0
ip address 192.168.12.2 255.255.255.0
no shutdown
exit
interface Ethernet0/1
ip address 192.168.23.2 255.255.255.0
no shutdown
exit
interface Loopback0
ip address 192.168.2.1 255.255.255.0
end
write

R3:
interface Ethernet0/0
 ip address 192.168.23.3 255.255.255.0
no shutdown
exit
interface Ethernet0/1
 ip address 192.168.34.3 255.255.255.0
no shutdown
exit
interface Loopback0
 ip address 192.168.3.1 255.255.255.0
end
write

R4:
interface Ethernet0/0
ip address 192.168.34.4 255.255.255.0
no shutdown
exit
interface Ethernet0/1
ip address 192.168.45.4 255.255.255.0
no shutdown
exit
interface Loopback0
ip address 192.168.4.1 255.255.255.0
end
write

R5:
interface Ethernet0/0
 ip address 192.168.45.5 255.255.255.0
no shutdown
exit
interface Ethernet0/1
 ip address 192.168.56.5 255.255.255.0
no shutdown
exit
interface Loopback0
 ip address 192.168.5.1 255.255.255.0
end
write

R6:
interface Ethernet0/0
 ip address 192.168.56.6 255.255.255.0
no shutdown
exit
interface Loopback0
 ip address 192.168.6.1 255.255.255.0
end
write

2. Chạy giao thức định tuyến trong IGP (giao thức nào cũng được), đảm bảo mọi IP trong vùng AS 200 phải thông nhau. Trong bài lab này ta chọn OSPF.

R2:
router ospf 1
router-id 192.168.2.1
exit
interface range ethernet 0/1, loopback 0
ip ospf 1 area 0
do write

R3:
router ospf 1
router-id 192.168.3.1
exit
interface range ethernet 0/0-1, loopback 0
ip ospf 1 area 0
do write

R4:
router ospf 1
router-id 192.168.4.1
exit
interface range ethernet 0/0-1, loopback 0
ip ospf 1 area 0
do write

R5:
router ospf 1
router-id 192.168.5.1
exit
interface range ethernet 0/0, loopback 0
ip ospf 1 area 0
do write

Kiểm tra bảng định tuyến của các Router trong vùng AS 200 (R2, R3, R4, R5) để chắc chắn mọi địa chỉ phải đi đến được với nhau sau khi cấu hình OSPF


R2#show ip route ospf
O        192.168.3.1 [110/11] via 192.168.23.3, 15:24:42, Ethernet0/1
      192.168.4.0/32 is subnetted, 1 subnets
O        192.168.4.1 [110/21] via 192.168.23.3, 15:23:26, Ethernet0/1
      192.168.5.0/32 is subnetted, 1 subnets
O        192.168.5.1 [110/31] via 192.168.23.3, 15:23:16, Ethernet0/1
O     192.168.34.0/24 [110/20] via 192.168.23.3, 15:23:36, Ethernet0/1
O     192.168.45.0/24 [110/30] via 192.168.23.3, 15:23:26, Ethernet0/1
R3#show  ip route ospf
O        192.168.2.1 [110/11] via 192.168.23.2, 15:24:24, Ethernet0/0
      192.168.4.0/32 is subnetted, 1 subnets
O        192.168.4.1 [110/11] via 192.168.34.4, 15:23:17, Ethernet0/1
      192.168.5.0/32 is subnetted, 1 subnets
O        192.168.5.1 [110/21] via 192.168.34.4, 15:22:56, Ethernet0/1
O     192.168.45.0/24 [110/20] via 192.168.34.4, 15:23:06, Ethernet0/1
R4#show  ip route ospf 
O        192.168.2.1 [110/21] via 192.168.34.3, 15:23:46, Ethernet0/0
      192.168.3.0/32 is subnetted, 1 subnets
O        192.168.3.1 [110/11] via 192.168.34.3, 15:23:46, Ethernet0/0
      192.168.5.0/32 is subnetted, 1 subnets
O        192.168.5.1 [110/11] via 192.168.45.5, 15:23:34, Ethernet0/1
O     192.168.23.0/24 [110/20] via 192.168.34.3, 15:23:46, Ethernet0/0
R5#show ip route ospf
O        192.168.2.1 [110/31] via 192.168.45.4, 15:23:44, Ethernet0/0
      192.168.3.0/32 is subnetted, 1 subnets
O        192.168.3.1 [110/21] via 192.168.45.4, 15:23:44, Ethernet0/0
      192.168.4.0/32 is subnetted, 1 subnets
O        192.168.4.1 [110/11] via 192.168.45.4, 15:23:44, Ethernet0/0
O     192.168.23.0/24 [110/30] via 192.168.45.4, 15:23:44, Ethernet0/0
O     192.168.34.0/24 [110/20] via 192.168.45.4, 15:23:44, Ethernet0/0

3. Cấu hình eBGP giữa các Router CE và PE (R1 với R2 và R5 với R6).

R1: quảng bá loopback 0 vào eBGP cho router PE (R2) học
router bgp 100
 network 192.168.1.0 mask 255.255.255.0
 neighbor 192.168.12.2 remote-as 200

R2:
router bgp 200
neighbor 192.168.12.1 remote-as 100

R5:
router bgp 200
 neighbor 192.168.56.6 remote-as 300

R6: quảng bá loopback 0 vào eBGP cho router PE (R5) học
router bgp 300
 network 192.168.6.0 mask 255.255.255.0
 neighbor 192.168.56.5 remote-as 200

Kiểm tra trên các router PE (R2 và R5) đã học được loopback 0 sau khi chạy BGP

R2#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 200", distance 20, metric 0
  Tag 100, type external
  Last update from 192.168.12.1 00:07:40 ago
  Routing Descriptor Blocks:
  * 192.168.12.1, from 192.168.12.1, 00:07:40 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 100
      MPLS label: none
R2#show ip route bgp
B     192.168.1.0/24 [20/0] via 192.168.12.1, 00:09:45

R5#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 200", distance 20, metric 0
  Tag 300, type external
  Last update from 192.168.56.6 00:09:38 ago
  Routing Descriptor Blocks:
  * 192.168.56.6, from 192.168.56.6, 00:09:38 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 300
      MPLS label: none
R5#show ip route bgp
B     192.168.6.0/24 [20/0] via 192.168.56.6, 00:09:46

4. Cấu hình GRE giữa R2 với R5


Để tạo ra BGP free core trong vùng AS 200 chúng ta có rất nhiều cách: 
  • Có thể dùng GRE để thiết lập tunnel giữa các con PE router (trong bài lab này là R2 với R5), được thực hiện ở yêu cầu số 4 
  • Hoặc enable MPLS trên các interface đấu nối giữa các router PE và router CE (noted: interface loopback không hỗ trợ enable MPLS), sẽ thực hiện ở yêu cầu số 6

Thiết lập tunnel giữa R2 và R5, ip address của tunnel 0 trên R2 là 192.168.25.2
R2:
!
interface Tunnel0
 ip address 192.168.25.2 255.255.255.0
tunnel mode gre ip
 tunnel source 192.168.2.1
 tunnel destination 192.168.5.1
end


Thiết lập tunnel giữa R2 và R5, ip address của tunnel 0 trên R5 là 192.168.25.5
R5:
!
interface Tunnel0
 ip address 192.168.25.5 255.255.255.0
tunnel mode gre ip
 tunnel source 192.168.5.1
 tunnel destination 192.168.2.1
end

Kiểm tra hoạt động của tunnel:
R2#show interfaces tunnel 0
Tunnel0 is up, line protocol is up 
  Hardware is Tunnel
  Internet address is 192.168.25.2/24
  MTU 17916 bytes, BW 100 Kbit/sec, DLY 50000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation TUNNEL, loopback not set
  Keepalive not set
  Tunnel source 192.168.2.1, destination 192.168.5.1
  Tunnel protocol/transport GRE/IP
  (...)

R5#show interfaces tunnel 0
Tunnel0 is up, line protocol is up 
  Hardware is Tunnel
  Internet address is 192.168.25.5/24
  MTU 17916 bytes, BW 100 Kbit/sec, DLY 50000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation TUNNEL, loopback not set
  Keepalive not set
  Tunnel source 192.168.5.1, destination 192.168.2.1
  Tunnel protocol/transport GRE/IP
   (...)


5. Cấu hình iBGP giữa các router PE (R2 và R5) đảm bảo loopback 0 của R1 và R6 phải thông nhau

R2:
router bgp 200
 neighbor 192.168.25.5 remote-as 200
 neighbor 192.168.25.5 next-hop-self

R5:
router bgp 200
 neighbor 192.168.25.2 remote-as 200
 neighbor 192.168.25.2 next-hop-self

Kiểm tra kết nối giữa loopback 0 (IP: 192.168.1.1) của R1 và loopback 0 (IP: 192.168.6.1) của R6
R1#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 100", distance 20, metric 0
  Tag 200, type external
  Last update from 192.168.12.2 00:13:16 ago
  Routing Descriptor Blocks:
  * 192.168.12.2, from 192.168.12.2, 00:13:16 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 200
      MPLS label: none
R1#traceroute 192.168.6.1 source 192.168.1.1 numeric 
Type escape sequence to abort.
Tracing the route to 192.168.6.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.12.2 1 msec 0 msec 1 msec
  2 192.168.25.5 1 msec 1 msec 1 msec
  3 192.168.56.6 1 msec *  1 msec
R1#ping 192.168.6.1 source 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/3 ms

R6#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 300", distance 20, metric 0
  Tag 200, type external
  Last update from 192.168.56.5 00:17:52 ago
  Routing Descriptor Blocks:
  * 192.168.56.5, from 192.168.56.5, 00:17:52 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 200
      MPLS label: none
R6#traceroute 192.168.1.1 source 192.168.6.1 numeric
Type escape sequence to abort.
Tracing the route to 192.168.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.56.5 1 msec 1 msec 0 msec
  2 192.168.25.2 1 msec 2 msec 2 msec
  3 192.168.12.1 6 msec *  2 msec
R6#ping 192.168.1.1 source 192.168.6.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.6.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

Đến đây 2 loopback 0 của R1 và R6 đã thông nhau thông qua BGP free core. Ta có thể bắt gói trên các interface của các router P (R3 và R4) để phân tích:


Ta thấy trong phần IP header có source là 192.168.2.1 và destination là 192.168.5.1 cả router P học được từ OSPF. Và để 2 loopback o của R1 và R6 thông nhau nhờ vào thiết lập GRE giữa R2 và R5. và chính tunnel của GRE trong trường hợp này là tạo BGP free core.

6. Xóa bỏ cấu hình ở yêu cầu 4, 5

  • Remove cấu hình GRE trên R2 và R5
R2, R5:
no interface Tunnel0

  • Remove cấu hình iBGP giữa R2 với R5

R2:
router bgp 200
no neighbor 192.168.25.5 next-hop-self
no neighbor 192.168.25.5 remote-as 200

R5:
router bgp 200
no neighbor 192.168.25.2 next-hop-self
no neighbor 192.168.25.2 remote-as 200

7. Cấu hình iBGP giữa R2 và R5

Dùng IP trên interface loopback 0 của R2 và R5 thể thiết lập neighbor cho iBGP

R2:
router bgp 200
 neighbor 192.168.5.1 remote-as 200
 neighbor 192.168.5.1 update-source Loopback0
 neighbor 192.168.5.1 next-hop-self

R5:
router bgp 200
 neighbor 192.168.2.1 remote-as 200
 neighbor 192.168.2.1 update-source Loopback0
 neighbor 192.168.2.1 next-hop-self


  • Kiểm tra thiết lập neighbor sau khi cấu hình iBGP

R2#show ip bgp summary 
(...)
Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.5.1      4          200         9         8        7    0    0 00:03:10        1
192.168.12.1    4          100     302     301        7    0    0 04:29:43        1
R5#show ip bgp summary
(...)
Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.2.1      4          200         8         9        5    0    0 00:02:54        1
192.168.56.6    4          300     300     298        5    0    0 04:26:38        1



  • Kiểm tra kết nối giữa 2 loopback 0 của R1 và R6

R1#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 100", distance 20, metric 0
  Tag 200, type external
  Last update from 192.168.12.2 00:20:58 ago
  Routing Descriptor Blocks:
  * 192.168.12.2, from 192.168.12.2, 00:20:58 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 200
      MPLS label: none
R2#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 200", distance 200, metric 0
  Tag 300, type internal
  Last update from 192.168.5.1 00:18:22 ago
  Routing Descriptor Blocks:
  * 192.168.5.1, from 192.168.5.1, 00:18:22 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 300
      MPLS label: none

R6#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 300", distance 20, metric 0
  Tag 200, type external
  Last update from 192.168.56.5 00:25:51 ago
  Routing Descriptor Blocks:
  * 192.168.56.5, from 192.168.56.5, 00:25:51 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 200
      MPLS label: none
R5#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 200", distance 200, metric 0
  Tag 100, type internal
  Last update from 192.168.2.1 00:27:28 ago
  Routing Descriptor Blocks:
  * 192.168.2.1, from 192.168.2.1, 00:27:28 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 100
      MPLS label: none

R1 và R6 đã học được các lớp mạng loopback 0 đã quảng bá nhờ vào kết nối iBGP giữa R2 và R5. Tuy nhiên khi tracertroute 192.168.6.1 từ R1, route này sẽ không đi đến được

R1#traceroute 192.168.6.1 source 192.168.1.1 numeric
Type escape sequence to abort.
Tracing the route to 192.168.6.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.12.2 0 msec 6 msec 0 msec
  2  *  *  *
  3  *  *  *
  4  *  *  *
  5  *  *  *
   (...)

vì các con router P (R3, R4) không chạy BGP với R2 và R5 nên nó không có thông tin về route này nên gói tin sẽ bị drop.

R3#show ip route 192.168.6.1
% Network not in table

Lỗi này gọi là back hole, R3 và R4 là "hố đen" đã hút mất gói tin khi chuyển qua đường đi của nó.

Để khắc phục lỗi này chúng ta có rất nhiều kỹ thuật ví dụ như: cho các router P (R3, R4) tham gia vào định tuyến BGP, hay redistribute BGP vào OSPF ở trên các router PE (R2, R5), tuy nhiên sẽ tốn rất nhiều tài nguyên. 

Yêu cầu 8 sẽ dùng MPLS để giải quyết vấn đề này.

8. Enable MPLS trên tất cả các interface kết nối giữa các router PE, P (R2, R3, R4, R5)

R2:
interface Ethernet0/1
mpls ip

R3, R4:
interface range ethernet 0/0-1
mpls ip

R5:
interface Ethernet0/0
mpls ip

  • Kiểm tra kết nối sau khi enable mpls

R1#ping 192.168.6.1 source 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
R1#traceroute 192.168.6.1 source 192.168.1.1 numeric
Type escape sequence to abort.
Tracing the route to 192.168.6.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.12.2 1 msec 1 msec 0 msec
  2 192.168.23.3 [MPLS: Label 18 Exp 0] 2 msec 1 msec 2 msec
  3  *  *  *
  4 192.168.45.5 1 msec 2 msec 1 msec
  5 192.168.56.6 2 msec *  2 msec

R6#ping 192.168.1.1 source 192.168.6.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.6.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
R6#traceroute 192.168.1.1 source 192.168.6.1 numeric 
Type escape sequence to abort.
Tracing the route to 192.168.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.56.5 1 msec 0 msec 0 msec
  2 192.168.45.4 [MPLS: Label 16 Exp 0] 1 msec 2 msec 1 msec
  3  *  *  *
  4 192.168.23.2 2 msec 1 msec 1 msec
  5 192.168.12.1 1 msec *  2 msec
Vậy các loopback 0 của R1 và R6 đã thông nhau nhờ sử dụng kỹ thuật MPLS. Khi chúng ta enable MPLS các router sẽ dùng label để forward gói tin.

R2#show ip route 192.168.6.1
Routing entry for 192.168.6.0/24
  Known via "bgp 200", distance 200, metric 0
  Tag 300, type internal
  Last update from 192.168.5.1 02:44:26 ago
  Routing Descriptor Blocks:
  * 192.168.5.1, from 192.168.5.1, 02:44:26 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 300
      MPLS label: none

Để đến được 192.168.6.1 thì phải thông qua next hop là 192.168.5.1. Thông thường router sẽ kiểm tra trong bảng routing để quyết định forward đến next hop nào, cổng nào, ở đây MPLS dùng nhãn để forward gói tin.

R2#show  mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         No Label   192.168.3.1/32   0             Et0/1      192.168.23.3
17         17              192.168.4.1/32   0             Et0/1      192.168.23.3
18         18              192.168.5.1/32   0             Et0/1      192.168.23.3
19         Pop Label  192.168.34.0/24  0            Et0/1      192.168.23.3
20         19              192.168.45.0/24  0             Et0/1      192.168.23.3

cũng có thể kiểm tra bảng CEF (cisco express forwarding) để biết được từ R1 đến địa chỉ 192.168.6.1 dùng nhãn là số bao nhiêu và thông qua cổng nào (xem bài Quá trình trao đổi nhãn trong MPLS)

R2#show ip cef 192.168.6.1
192.168.6.0/24
  nexthop 192.168.23.3 Ethernet0/1 label 18

Phân tích gói tin trên whileshark



Ta thấy MPLS header chèn vào giữa lớp Ethernet và lớp Internet, đó cũng chính là lý do người ta gọi MPLS hoạt động ở lớp 2.5.

Trong các router P (R3, R4) cũng dùng nhãn để forward gói tin
R3#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         No Label   192.168.2.1/32   20931         Et0/0      192.168.23.2
17         No Label   192.168.4.1/32   0                 Et0/1      192.168.34.4
18         18              192.168.5.1/32   22092         Et0/1      192.168.34.4
19         Pop Label  192.168.45.0/24  0                Et0/1      192.168.34.4

Riêng R4 thì nhãn sẽ được remove ra trước, sau đó chuyển gói tin IP cho PE (R5). Tại sao R4 làm vậy sẽ được thảo luận trong phần Quá trình trao đổi nhãn trong MPLS.
R4#show mpls forwarding-table 
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         16             192.168.2.1/32   22317         Et0/0      192.168.34.3
17         No Label   192.168.3.1/32      0             Et0/0      192.168.34.3
18         No Label   192.168.5.1/32   21239        Et0/1      192.168.45.5
19         Pop Label  192.168.23.0/24    0             Et0/0      192.168.34.3

R5 nhận được gói tin IP không có lable và forward cho R6 như bình thường. Khi R6 nhận được thì trả lời ICMP reply và sẽ kết thúc tại R5.
R5#show ip route 192.168.1.1
Routing entry for 192.168.1.0/24
  Known via "bgp 200", distance 200, metric 0
  Tag 100, type internal
  Last update from 192.168.2.1 03:35:59 ago
  Routing Descriptor Blocks:
  * 192.168.2.1, from 192.168.2.1, 03:35:59 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 100
      MPLS label: none
R5 biết rằng để đến 192.168.1.1 sẽ dùng next-hop là 192.168.2.1.
R5#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         16              192.168.2.1/32   0                 Et0/0      192.168.45.4
17         17              192.168.3.1/32   0                 Et0/0      192.168.45.4
18         No Label   192.168.4.1/32   0                 Et0/0      192.168.45.4
19         19              192.168.23.0/24  0                Et0/0      192.168.45.4
20         Pop Label  192.168.34.0/24  0                Et0/0      192.168.45.4

R5 sẽ thêm lable 16 vào gói tin IP và forward ra cổng Et0/0 để đến router P (R4)
R5#show  ip cef 192.168.1.1
192.168.1.0/24
  nexthop 192.168.45.4 Ethernet0/0 label 16

Router R4 sẽ forward sang R3
R4#show mpls forwarding-table 
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     Switched      interface           
16         16             192.168.2.1/32   211146        Et0/0      192.168.34.3
17         No Label   192.168.3.1/32       0             Et0/0      192.168.34.3
18         No Label   192.168.5.1/32   196413       Et0/1      192.168.45.5
19         Pop Label  192.168.23.0/24     0             Et0/0      192.168.34.3

R3 sẽ remove lable và forward đến R2 qua interface Et0/0
R3#show mpls forwarding-table 
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop 
Label      Label      or Tunnel Id     
Switched      interface           
16         No Label   192.168.2.1/32   
196480        Et0/0      192.168.23.2
17         No Label   192.168.4.1/32        0             Et0/1      192.168.34.4
18         18         192.168.5.1/32        211588        Et0/1      192.168.34.4
19         Pop Label  192.168.45.0/24      0            Et0/1      192.168.34.4

R2 forward gói tin IP không lable đến R1.

Hy vọng rằng chúng ta hiểu, biết sử dụng MPLS để tạo ra tunnel giữa các con router PE để tạo BGP free core.

Xong!

Cisco, Dynamic Multipoint VPN - DMVPN Phase 1 OSPF Routing

Giới thiệu: Trước đây chúng ta đã có chủ đề DMVPN Phase 1 căn bản để thiết lập tunnel giữa các site với nhau. Và trước đó chúng ta đã có chủ đề dùng EIGRP để quảng bá các loopback 0 của các router: R1, R2, R3, đảm bảo rằng các loopback 0 phải ping thấy nhau. Hôm nay chúng ta dùng giao thức OSPF để quảng bá các loopback 0 của các router.

Bài Lab

Các kiến thức sử dụng trong bài: cấu hình DMVPN Phase 1 căn bản, OSPF

1. Kiểm tra trước khi vào cấu hình dùng giao thức OSPF để quảng bá (sử dụng tiếp theo bài DMVPN Phase 1 căn bản)
R1#show dmvpn | begin 172.16.0.
     1 2.2.2.2              172.16.0.2    UP 02:19:26     D
     1 3.3.3.3              172.16.0.3    UP 01:55:56     D

Cisco, Dynamic Multipoint VPN - DMVPN Phase 1 EIGRP Routing

Giới thiệu: Trước đây chúng ta đã có chủ đề DMVPN Phase 1 căn bản để thiết lập tunnel giữa các site với nhau. Hôm nay chúng ta cùng nhau đi tiếp sau khi tunnel đã thiết lập chúng sẽ dùng giao thức EIGRP để quảng bá các loopback 0 của các router: R1, R2, R3, đảm bảo rằng các loopback 0 phải ping thấy nhau.

Bài Lab

Các kiến thức sử dụng trong bài: cấu hình DMVPN Phase 1 căn bản, EIGRP

Cisco, Dynamic Multipoint VPN - DMVPN Phase 1 Basic Configuration - HUB, SPOKES

Giới thiệu: Ở bài GRE VPN căn bản vì đó là GRE theo kiểu kết nối point-to-point nên có bao nhiêu site thì ở Router chính phải tạo ra bấy nhiêu tunnel. Tiếp theo chúng ta tìm hiểu về multipoint GRE - mGRE hay Dynamic Multipoint VPN - DMVPN cho phép tạo một tunnel nhưng có thể kết nối được nhiều site, DMVPN có rất nhiều phase và mỗi phase có cách hoạt động sẽ khác nhau. Chủ đề này chúng ta chỉ dừng lại các router R1, R2, R3 thiết lập được tunnel.

Bài Lab:


Các kiến thứ dùng trong bài: OSPF, DMVPN

Bài 1, Cisco, GRE VPN Basic

Giới thiệu: Khi nói đến nối các site lại với nhau thông qua môi trường internet chúng ta có rất nhiều cách trong đó có VPN. VPN có rất nhiều loại tuy nhiên trong chủ đề hôm nay chúng tôi nói về GRE (Generic Routing Enscapsulution). GRE là kỹ thuật đường hầm ở lớp thứ 3 của mô hình OSI cho phép đóng gói dữ liệu của nhiều loại giao thức khác nhau như IP, IPX, ..., các giao thức định tuyến để truyền qua một mạng IP. Khi đóng gói dữ liệu, mặc định GRE chèn thêm 24 bytes gồm 20 IP header và 4 bytes cho GRE header. Các đặc tính của GRE được mô tả như hình.

Cisco, Dynamic Multipoint VPN (DMVPN) Phase 2 - HUB, SPOKES, mGRE Protection and Routing




Các kiến thức dùng trong bài lab: ospf, mGRE, static route

Yêu cầu:
1. Đấu dây và đặt IP như hình (qui ước cách đặt ip theo số của Router),  cấu hình OSPF sao cho các IP public phải ping thấy nhau


Gợi ý cấu hình

  • R1
!
interface Ethernet0/1
 ip address 1.1.1.1 255.255.255.0
 ip ospf 1 area 0
end
!
interface Loopback0
 ip address 192.168.1.1 255.255.255.0
end
!
router ospf 1
router-id 1.1.1.1
  • R2

!
interface Ethernet0/2
 ip address 2.2.2.2 255.255.255.0
 ip ospf 1 area 0
end
!
interface Loopback0
 ip address 192.168.2.1 255.255.255.0
end
!
router ospf 1
router-id 2.2.2.2
  • R3
!
interface Ethernet0/3
 ip address 3.3.3.3 255.255.255.0
 ip ospf 1 area 0
end
!
interface Loopback0
 ip address 192.168.3.1 255.255.255.0
end
!
router ospf 1
router-id 3.3.3.3
  • R4
!
interface Ethernet0/1
 ip address 1.1.1.4 255.255.255.0
 ip ospf 1 area 0
end

!
interface Ethernet0/2
 ip address 2.2.2.4 255.255.255.0
 ip ospf 1 area 0
end

!
interface Ethernet0/3
 ip address 3.3.3.4 255.255.255.0
 ip ospf 1 area 0
end

!

router ospf 1
router-id 4.4.4.4


!Kiểm tra sau khi cấu hình OSPF
!R1
R1#show ip route ospf
đã xóa 1 số dòng không cần thiết
      2.0.0.0/24 is subnetted, 1 subnets
O        2.2.2.0 [110/20] via 1.1.1.4, 00:01:32, Ethernet0/1
      3.0.0.0/24 is subnetted, 1 subnets
O        3.3.3.0 [110/20] via 1.1.1.4, 00:01:32, Ethernet0/1
!R2
R2#show ip route ospf 
đã xóa 1 số dòng không cần thiết
      1.0.0.0/24 is subnetted, 1 subnets
O        1.1.1.0 [110/20] via 2.2.2.4, 00:00:53, Ethernet0/2
      3.0.0.0/24 is subnetted, 1 subnets
O        3.3.3.0 [110/20] via 2.2.2.4, 00:02:42, Ethernet0/2
!R3
R3#show ip route ospf
đã xóa 1 số dòng không cần thiết
      1.0.0.0/24 is subnetted, 1 subnets
O        1.1.1.0 [110/20] via 3.3.3.4, 00:01:17, Ethernet0/3
      2.0.0.0/24 is subnetted, 1 subnets
O        2.2.2.0 [110/20] via 3.3.3.4, 00:03:06, Ethernet0/3

2. Cấu hình mGRE giữa R1, R2, R3 
Gợi ý cấu hình

  • R1

!
interface Tunnel0
 description ===mGRE - DMVPN Tunnel===
 ip address 172.16.0.1 255.255.255.0
 no ip redirects
 ip nhrp authentication cisco
 ip nhrp map multicast dynamic
 ip nhrp network-id 1
 tunnel source 1.1.1.1
 tunnel mode gre multipoint
end

  • R2

!
interface Tunnel0
 description ===R2 mGRE - DMVPN Tunnel===
 ip address 172.16.0.2 255.255.255.0
 no ip redirects
 ip nhrp authentication cisco
 ip nhrp map multicast dynamic
 ip nhrp map 172.16.0.1 1.1.1.1
 ip nhrp network-id 1
 ip nhrp nhs 172.16.0.1
 tunnel source Ethernet0/2
 tunnel mode gre multipoint
end
  • R3
!
interface Tunnel0
 description ===R3 mGRE - DMVPN Tunnel===
 ip address 172.16.0.3 255.255.255.0
 no ip redirects
 ip nhrp authentication cisco
 ip nhrp map multicast dynamic
 ip nhrp map 172.16.0.1 1.1.1.1
 ip nhrp network-id 1
 ip nhrp nhs 172.16.0.1
 tunnel source Ethernet0/3
 tunnel mode gre multipoint
end

Kiểm tra sau khi cấu hình mGRE
!R1
R1#show dmvpn 
đã xóa 1 số dòng không cần thiết
Interface: Tunnel0, IPv4 NHRP Details 
Type:Hub, NHRP Peers:2, 

 # Ent  Peer NBMA Addr Peer Tunnel Add State  UpDn Tm Attrb
 ----- --------------- --------------- ----- -------- -----
     1 2.2.2.2              172.16.0.2    UP 01:31:58     D
     1 3.3.3.3              172.16.0.3    UP 01:27:41     D

R1#show ip nhrp 
172.16.0.2/32 via 172.16.0.2
   Tunnel0 created 01:36:55, expire 01:43:04
   Type: dynamic, Flags: unique registered used 
   NBMA address: 2.2.2.2 
172.16.0.3/32 via 172.16.0.3
   Tunnel0 created 01:33:23, expire 01:47:23
   Type: dynamic, Flags: unique registered used 
   NBMA address: 3.3.3.3 
!R2

R2#show dmvpn 
đã xóa 1 số dòng không cần thiết
Interface: Tunnel0, IPv4 NHRP Details 
Type:Spoke, NHRP Peers:2, 

 # Ent  Peer NBMA Addr Peer Tunnel Add State  UpDn Tm Attrb
 ----- --------------- --------------- ----- -------- -----
     1 1.1.1.1              172.16.0.1    UP 01:34:10     S
     1 3.3.3.3              172.16.0.3    UP 01:29:44     D
!Tunnel được thiết lập từ SPOKES đến HUB là S

R2#show ip nhrp 
172.16.0.1/32 via 172.16.0.1
   Tunnel0 created 01:39:02, never expire 
   Type: static, Flags: used 
   NBMA address: 1.1.1.1 
172.16.0.2/32 via 172.16.0.2
   Tunnel0 created 01:34:08, expire 00:25:51
   Type: dynamic, Flags: router unique local 
   NBMA address: 2.2.2.2 
    (no-socket) 
172.16.0.3/32 via 172.16.0.3
   Tunnel0 created 01:35:34, expire 00:25:51
   Type: dynamic, Flags: router implicit used 
   NBMA address: 3.3.3.3 
!R3

R3#show dmvpn 
đã xóa 1 số dòng không cần thiết
Interface: Tunnel0, IPv4 NHRP Details 
Type:Spoke, NHRP Peers:2, 

 # Ent  Peer NBMA Addr Peer Tunnel Add State  UpDn Tm Attrb
 ----- --------------- --------------- ----- -------- -----
     1 1.1.1.1              172.16.0.1    UP 01:31:05     S
     1 2.2.2.2              172.16.0.2    UP 01:30:56     D
!Tunnel được thiết lập từ SPOKES đến HUB là S

R3#show ip nhrp 
172.16.0.1/32 via 172.16.0.1
   Tunnel0 created 01:33:35, never expire 
   Type: static, Flags: used 
   NBMA address: 1.1.1.1 
172.16.0.2/32 via 172.16.0.2
   Tunnel0 created 01:33:26, expire 00:26:33
   Type: dynamic, Flags: router used 
   NBMA address: 2.2.2.2 

3. Cấu hình static route để các loopback 0 phải ping thấy nhau
Gợi ý cấu hình:
!R1
ip route 192.168.2.0 255.255.255.0 172.16.0.2
ip route 192.168.3.0 255.255.255.0 172.16.0.3

!R2
ip route 192.168.1.0 255.255.255.0 172.16.0.1
ip route 192.168.3.0 255.255.255.0 172.16.0.3

!R3
ip route 192.168.1.0 255.255.255.0 172.16.0.1
ip route 192.168.2.0 255.255.255.0 172.16.0.2

Kiểm tra sau khi cấu hình static route
!R1
R1#show ip route static 
đã xóa 1 số dòng không cần thiết
S     192.168.2.0/24 [1/0] via 172.16.0.2
S     192.168.3.0/24 [1/0] via 172.16.0.3
R1#ping 192.168.2.1 source 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
R1#ping 192.168.3.1 source 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

!R2
R2#show ip route static 
đã xóa 1 số dòng không cần thiết
S     192.168.1.0/24 [1/0] via 172.16.0.1
S     192.168.3.0/24 [1/0] via 172.16.0.3
R2#ping 192.168.3.1 source 192.168.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.2.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
R2#ping 192.168.1.1 source 192.168.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.2.1 
!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
!R3
R3#show ip route static 
đã xóa 1 số dòng không cần thiết
S     192.168.1.0/24 [1/0] via 172.16.0.1
S     192.168.2.0/24 [1/0] via 172.16.0.2
R3#ping 192.168.2.1 source 192.168.3.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.3.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
R3#ping 192.168.1.1 source 192.168.3.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.3.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

4. Protecting - Encrypting DMVPN mGRE Tunnel with IPSEC
!Gợi ý cấu hình:
!R1, R2, R3
crypto isakmp policy 1
 encr 3des
 hash md5
 authentication pre-share
 group 2
crypto isakmp key cisco address 0.0.0.0     
crypto ipsec transform-set TS esp-3des esp-md5-hmac
 mode tunnel
crypto ipsec profile protect-gre
 set security-association lifetime seconds 86400
 set transform-set TS
! gán vào interface tunnel 0
interface Tunnel0
 tunnel protection ipsec profile protect-gre

!Kiểm tra
R1#show crypto session 
Crypto session current status

Interface: Tunnel0
Session status: UP-ACTIVE     
Peer: 3.3.3.3 port 500 
  IKEv1 SA: local 1.1.1.1/500 remote 3.3.3.3/500 Active 
  IPSEC FLOW: permit 47 host 1.1.1.1 host 3.3.3.3 
        Active SAs: 2, origin: crypto map

Interface: Tunnel0
Session status: UP-ACTIVE     
Peer: 2.2.2.2 port 500 
  IKEv1 SA: local 1.1.1.1/500 remote 2.2.2.2/500 Active 
  IPSEC FLOW: permit 47 host 1.1.1.1 host 2.2.2.2 
        Active SAs: 2, origin: crypto map


!R2#show crypto session 
Crypto session current status

Interface: Tunnel0
Session status: UP-ACTIVE     
Peer: 3.3.3.3 port 500 
  IKEv1 SA: local 2.2.2.2/500 remote 3.3.3.3/500 Active 
  IKEv1 SA: local 2.2.2.2/500 remote 3.3.3.3/500 Active 
  IPSEC FLOW: permit 47 host 2.2.2.2 host 3.3.3.3 
        Active SAs: 6, origin: crypto map

Interface: Tunnel0
Session status: UP-ACTIVE     
Peer: 1.1.1.1 port 500 
  IKEv1 SA: local 2.2.2.2/500 remote 1.1.1.1/500 Active 
  IPSEC FLOW: permit 47 host 2.2.2.2 host 1.1.1.1 
        Active SAs: 2, origin: crypto map

!R3#show crypto session 
Crypto session current status

Interface: Tunnel0
Session status: UP-ACTIVE     
Peer: 2.2.2.2 port 500 
  IKEv1 SA: local 3.3.3.3/500 remote 2.2.2.2/500 Active 
  IKEv1 SA: local 3.3.3.3/500 remote 2.2.2.2/500 Active 
  IPSEC FLOW: permit 47 host 3.3.3.3 host 2.2.2.2 
        Active SAs: 6, origin: crypto map

Interface: Tunnel0
Session status: UP-ACTIVE     
Peer: 1.1.1.1 port 500 
  IKEv1 SA: local 3.3.3.3/500 remote 1.1.1.1/500 Active 
  IPSEC FLOW: permit 47 host 3.3.3.3 host 1.1.1.1 
        Active SAs: 2, origin: crypto map


! so sánh kết quả trước và sau khi cấu hình IPSec

Cisco, Dynamic Multipoint VPN (DMVPN) Phase 2 - HUB, SPOKES, mGRE Protection and Routing




Các kiến thức dùng trong bài lab: ospf, mGRE, static route

Yêu cầu:
1. Đấu dây và đặt IP như hình (qui ước cách đặt ip theo số của Router),  cấu hình OSPF sao cho các IP public phải ping thấy nhau

/*header slide*/