/*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===*/

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.

Cách chuyển đổi địa chỉ Multicast sang MAC address


Địa chỉ MAC address 48 bits được chia thành 6 octets (12 số hexa), 3 octets đầu tiên (cũng có thể gọi là prefix) được đăng ký và quản lý bởi IEEE (gọi là Mmanufacturer), 3 opticts còn lại lại do nhà sản xuất tự quản lý và đánh số (gọi là Sspecific device). Một địa chỉ MAC address có dạng:

  • MM:MM:MM:SS:SS:SS
  • MM-MM-MM-SS-SS-SS
  • MMMM.MMSS.SSSS
Cách chuyển đổi địa chỉ Multicast sang MAC address

Nữa đầu (3 bytes, 24 bits) thường được fixed cố định có dạng 01:00:5E, nữa còn lại là 23 bits của địa chỉ Multicast.

Ví dụ: đổi địa chỉ ipv4 228.10.24.5 sang MAC address. 

1. Đổi địa chỉ IP Address sang nhị phân: 1110 0100.0000 1010.0001 1000.0000 0101 thấy 4 bits đầu tiền thường là 1110 cho các địa chỉ multicast.
2. Thay 4 bits đầu 1110 này với 6 số hexa (24bits) 01-00-5E
3. Thay 5 bits tiếp 0100.0 theo bằng 1 số 0 
4. Kết hợp số 0 ở bước 3 với 23 bits còn lại 0000 1010.0001 1000.0000 0101 đổi sang dạng hexa
5. Nối 6 số hexa ở bước 2 và dãy số hexa sau khi tính toán ở bước 4 ta được địa MAC address của địa chỉ multicast group là: 01-00-5E-0A-18-05



Tương tự: Địa chỉ multicast group của HSRP 224.0.0.2 chuyển thành MAC address có dạng 01-00-5E-00-00-02

Cách chuyển đổi địa chỉ Multicast sang MAC address


Địa chỉ MAC address 48 bits được chia thành 6 octets (12 số hexa), 3 octets đầu tiên (cũng có thể gọi là prefix) được đăng ký và quản lý bởi IEEE (gọi là Mmanufacturer), 3 opticts còn lại lại do nhà sản xuất tự quản lý và đánh số (gọi là Sspecific device). Một địa chỉ MAC address có dạng:

  • MM:MM:MM:SS:SS:SS
  • MM-MM-MM-SS-SS-SS
  • MMMM.MMSS.SSSS
Cách chuyển đổi địa chỉ Multicast sang MAC address

Nữa đầu (3 bytes, 24 bits) thường được fixed cố định có dạng 01:00:5E, nữa còn lại là 23 bits của địa chỉ Multicast.

Cisco, EtherChannel, Aggregation switch link, LACP, PAgP


Giới thiệu Người ta có thể sử dụng nhiều đường đấu nối song song nhau nhằm mục đích dự phòng, tăng băng thông đấu nối giữa các switch, về lý thuyết và chi tiết các đặc tính được thảo luận trong phần Lý thuyết EtherChannel.

Sơ đồ bài lab:


Các kiến thức sử dụng trong bài lab: EtherChannel, Aggregation switch link, LACP, PAgP.

YÊU CẦU:
1. Cấu hình EtherChannel group 1 cho 4 cổng Ethernet0/0 đến Ethernet0/3, sử dụng giao thức LACP
2. Cấu hình EtherChannel group 23 cho 4 cổng Ethernet1/0 đến Ethernet1/3, sử dụng giao thức PAgP

THỰC HIỆN:
1. Cấu hình EtherChannel group 1 cho 4 cổng Ethernet0/0 đến Ethernet0/3, sử dụng giao thức LACP


a. Cấu hình căn bản:
Sw1
interface port-channel 1
exit
!
interface range ethernet 0/0-3
shutdown
channel-protocol lacp
channel-group 1 mode active
no shutdown

Sw2
interface port-channel 1
exit
!
interface range ethernet 0/0-3
shutdown
channel-protocol lacp
channel-group 1 mode passive
no shutdown


  • kiểm tra

Sw1#show etherchannel summary
Flags: D - down     P - bundled in port-channel
I - stand-alone s - suspended
H - Hot-standby (LACP only)
R - Layer3    S - Layer2
U - in use         f - failed to allocate aggregator
đã xóa 1 số dòng
Number of channel-groups in use: 1
Number of aggregators: 1
Group Port-channel Protocol Ports
------+-------------+-----------+-----------------------------------------------
1         Po1(SU)         LACP      Et1/0(P)      Et1/1(P)     Et1/2(P)       Et1/3(P)

Sw1#show etherchannel 1 port-channel
          Port-channels in the group:
         ---------------------------
Port-channel: Po1 (Primary Aggregator)
------------
Age of the Port-channel     = 0d:00h:05m:39s
Logical slot/port = 16/0           Number of ports = 4
HotStandBy port = null
Port state             = Port-channel Ag-Inuse
Protocol              = LACP
Port security       = Disabled
Ports in the Port-channel:
Index       Load       Port    EC state    No of bits
------+------+------+------------------+-----------
     0      00       Et0/0     Active           0
     0      00      Et0/1      Active           0
     0      00      Et0/2      Active           0
     0      00      Et0/3      Active           0
Time since last port bundled: 0d:00h:05m:35s Et0/3

Lý thuyết: LACP cho phép 8 cổng cùng tham gia vào EtherChannel (bundle port channel) nếu ta cấu hình số lượng lớn hơn 8 thì tại một thời điểm chỉ có 8 cổng active, các cổng còn lại ở chế độ Hot-Standby. LACP cho phép 8 active8 Hot-Standby
Tham khảo tại trang Cisco EtherChannel

b. Giới hạn số lượng cổng tham gia vào EtherChannel là 2

Sw1:
interface Port-channel1
 lacp max-bundle 2
!

  • kiểm tra
Sw1#show etherchannel summary
       Flags: D - down P - bundled in port-channel
       I - stand-alone s - suspended
       H - Hot-standby (LACP only)
       R - Layer3 S - Layer2
       U - in use f - failed to allocate aggregator
       M - not in use, minimum links not met
       u - unsuitable for bundling
       w - waiting to be aggregated
       d - default port
Number of channel-groups in use: 1
Number of aggregators:        1
Group Port-channel Protocol Ports
------+-------------+-----------+-----------------------------------------------
1    Po1(SU)     LACP     Et0/0(P)     Et0/1(P)     Et0/2(H)     Et0/3(H)

Sw2#show etherchannel summary
Flags: D - down P - bundled in port-channel
       I - stand-alone s - suspended
      H - Hot-standby (LACP only)
      R - Layer3 S - Layer2
      U - in use f - failed to allocate aggregator
      M - not in use, minimum links not met
      u - unsuitable for bundling
      w - waiting to be aggregated
      d - default portNumber of channel-groups in use: 1
Number of aggregators: 1
Group Port-channel Protocol Ports
------+-------------+-----------+-----------------------------------------------
1       Po1(SU)       LACP       Et0/0(P)       Et0/1(P)       Et0/2(w)       Et0/3(w)

Giải thích kết quả show: Trên Sw1 cấu hình max-bundle 2 nên trên con switch này 2 port sẽ ở trạng thái HHot-standby, còn trên switch 2 nó cứ thương lượng mà không nhận được phản hồi từ switch 1 nên có 2 port ở trạng thái w - waiting to be aggregated

c. Thay đổi độ ưu tiên trên interface của switch 1:
  • ethernet 0/1: 100
  • ethernet 0/2: 200
  • ethernet 0/3: 300
Sw1:
interface Ethernet0/1
 lacp port-priority 100
interface Ethernet0/2
 lacp port-priority 200
interface Ethernet0/3
 lacp port-priority 300

  • kiểm tra

Sw1#show etherchannel summary
Flags: D - down P - bundled in port-channel
     I - stand-alone s - suspended
     H - Hot-standby (LACP only)
     R - Layer3 S - Layer2
     U - in use f - failed to allocate aggregator
     M - not in use, minimum links not met
     u - unsuitable for bundling
     w - waiting to be aggregated
     d - default port
Number of channel-groups in use: 1
Number of aggregators: 1
Group Port-channel Protocol Ports
------+-------------+-----------+-----------------------------------------------
1      Po1(SU)      LACP      Et0/0(H)      Et0/1(P)      Et0/2(P)      Et0/3(H) 

Sw2#show etherchannel summary
Flags: D - down P - bundled in port-channel
     I - stand-alone s - suspended
     H - Hot-standby (LACP only)
     R - Layer3 S - Layer2
     U - in use f - failed to allocate aggregator
     M - not in use, minimum links not met
     u - unsuitable for bundling
     w - waiting to be aggregated
     d - default port
Number of channel-groups in use: 1
Number of aggregators: 1
Group Port-channel Protocol Ports
------+-------------+-----------+-----------------------------------------------
1      Po1(SU)      LACP      Et0/0(w)      Et0/1(P)      Et0/2(P)      Et0/3(w)

Giải thích: cho port nào tham gia vào EtherChannel LACP xét: độ ưu tiên của interface trước (mặt định 32768)  nếu bằng nhau xét MAC của interface nếu nhỏ hơn sẽ được tham gia vào EtherChannel trước. Với cấu hình trên là port E0/1 và E0/2 tham giao bundle của etherchannel nếu 1 trong 2 port bị down thì E0/3 sẽ tham gia vào bundle (độ ưu tiên của port e0/3 = 300 < port e0/0 = 32768). Port nào có độ ưu tiên thấp hơn sẽ điều khiển etherchannel đó.

2. Cấu hình EtherChannel group 23 cho 4 cổng Ethernet1/0 đến Ethernet1/3, sử dụng giao thức PAgP

  • Cấu hình

Sw2, Sw3:
interface port-channel 23
exit
!
interface range ethernet 1/0-3
shutdown
channel-protocol pagp
channel-group 23 mode desirable
no shutdown

  • kiểm tra
Sw3#show  etherchannel summary 
đã xóa 1 số dòng
Number of channel-groups in use: 1
Number of aggregators:           1
Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
23     Po23(SU)        PAgP      Et1/0(P)    Et1/1(P)    Et1/2(P)    Et1/3(P


Xong!

LACP on Juniper 

Cisco, First Hop Redundancy Protocol (FHRP), Hot Standby Router Protocol (HSRP)



Các kiến thức sử dụng trong bài Lab: Spanning Tree Protocol, VLAN, Trunking, router on a stick, HSRP, floating static route, Nat overload, Access List, IP SLA

YÊU CẦU:
1. Cấu hình Rapid-PVST+ và Port Fast trên Switch 12 để đảm bảo sự chuyển đổi dự phòng của HSRP được nhanh hơn (mặt định switch phải mất 30s-50s để chuyển thành port fordward dữ liệu), tạo và gán vlan tương ứng cho các PC, cấu hình trunk trên các cổng nối đến R1, R2.

2. VLAN 10: Cấu hình HSRP version 1 đảm bảo R1 là actice router, bật chế độ preempt để chiếm quyền active router nếu R1 online, R2 là standy router

3. VLAN 20: Cấu hình HSRP version 2 đảm bảo R2 là active router, bật chế độ preempt để chiếm quyền active router sau 2 phút nếu R2 online, R1 là standy router, cấu hình xác thực md5 password là cisco123, điều chỉnh timer: hello 1, deal 3 (mặt định hello time là 3s, deal/hold time 10s)

4. Cấu hình và đặt ip cho R12 như hình, cấu hình default route trên:
  • R1, R2 --> R12 với AD 5; Nat overload đảm bảo các PC trong LAN có thể ping đến được 8.8.8.8
  • R1 --> R2 với AD 10
  • R2 --> R1 với AD 10

5. Cấu hình Track cho HSRP
  • R1 track interface: kiểm tra nếu đường link e0/3 đến R12 bị down thì giảm priority của group 10 xuống 15, nếu đường link e0/3 đến R2 và e0/0 bị cùng down -> giảm thêm priority của group 10 là 15 ( lúc này R2 là active router cho group 10)
  • R2 track object: nếu R2 không ping đến được địa chỉ 2.2.2.2 của R12 thì giảm bớt priority của group 20 là 15, nếu không ping được địa chỉ 2.2.2.2 và 10.3.3.9 của R1 thì giảm tiếp priority của group 20 là 15. => R1 active router của group 20.
6. Cấu hình track cho Route đi internet:
  • R2 nếu không ping đến được ip 2.2.2.2 trỏ next hop của R2 trỏ về R1
  • Nếu R1 không ping đến được 10.3.3.1 của R2 thì next của R1 trỏ về R2

THỰC HIỆN:
1. Cấu hình Rapid-PVST+ và Port Fast trên Switch 12 để đảm bảo sự chuyển đổi dự phòng của HSRP được nhanh hơn (mặt định switch phải mất 30s-50s để chuyển thành port fordward dữ liệu), tạo và gán vlan tương ứng cho các PC, cấu hình trunk trên các cổng nối đến R1, R2.

Cisco, Configure IP SLA Tracking and Path Control


Mô hình ta có 2 đường internet, mặt định mọi kết nối ra internet của lớp mạng 192.168.1.0/24 phải thông qua R2 là đường chính, và sử dụng tính năng IP SLA để theo dõi/giám sát xem nếu không thể kết nối đến DNS của R2 thì chuyển hướng kết nối internet thông qua R3.

Các kiến thức dùng trong bài lab: Default route, Static, EIGRP, IP SLA, Track
Yêu cầu:
1. Đấu dây và đặt IP như hình, cấu hình:
  • R1: cấu hình default route (AD=5) trỏ về R2 đảm bảo có ping tới Web server và DNS của IPS1, ISP2
  • R2, R3: 
+ Cấu hình EIGRP 100 ( không quảng bá loopback 0: 209.165.200.254) 
+ Cấu hình Static route đến lớp mạng 192.168.1.0 về R1 

Cisco, Configure Site to Site IPSec VPN Tunnel



Các kiến thức dùng trong bài lab: Default route, Nat overload, Access List, VPN

Yêu cầu:
1. Đấu dây và đặt IP như hình (qui ước đặt IP theo số của Router), cấu hình Default route, Nat overload, Accesslist đảm bảo:
  • R1 có thể ping thấy R2
  • Site 1:  chỉ duy nhất lớp mạng 10.1.1.0 có thể ping thông 8.8.8.8
  • Site 2:  chỉ duy nhất lớp mạng 20.1.1.0 có thể ping thông 8.8.8.8


Gợi ý cấu hình:
!R3

!

interface Ethernet0/1
 ip address 1.1.1.3 255.255.255.0
end
!
interface Ethernet0/2
 ip address 2.2.2.3 255.255.255.0
end
!
interface Loopback0
 ip address 8.8.8.8 255.255.255.255
end

!R1
!
interface Ethernet0/1
 ip address 1.1.1.1 255.255.255.0
end
interface Ethernet0/0
 ip address 10.1.1.1 255.255.255.0
end

! default route
ip route 0.0.0.0 0.0.0.0 1.1.1.3

!Nat overload
interface Ethernet0/0
ip nat inside
interface Ethernet0/1
 ip nat outside
ip nat inside source list To_Internet interface Ethernet0/1 overload

!Accesslist Extended
ip access-list extended To_Internet
 permit ip 10.1.1.0 0.0.0.255 any
 deny   ip any any

!R2
!
interface Ethernet0/2
 ip address 2.2.2.2 255.255.255.0
end
!
interface Ethernet0/0
 ip address 20.1.1.1 255.255.255.0
 end

! default route
ip route 0.0.0.0 0.0.0.0 2.2.2.3

!Nat overload
interface Ethernet0/0
 ip address 20.1.1.1 255.255.255.0
interface Ethernet0/2
 ip nat outside
ip nat inside source list To_Internet interface Ethernet0/2 overload

!Accesslist Extended
ip access-list extended To_Internet
 permit ip 20.1.1.0 0.0.0.255 any
 deny   ip any any

!Kiểm tra bằng ping từ PC
PC1> ping 2.2.2.2
84 bytes from 2.2.2.2 icmp_seq=1 ttl=253 time=2.168 ms
84 bytes from 2.2.2.2 icmp_seq=2 ttl=253 time=1.979 ms
84 bytes from 2.2.2.2 icmp_seq=3 ttl=253 time=2.075 ms
84 bytes from 2.2.2.2 icmp_seq=4 ttl=253 time=1.640 ms
84 bytes from 2.2.2.2 icmp_seq=5 ttl=253 time=1.381 ms

PC1> ping 8.8.8.8
84 bytes from 8.8.8.8 icmp_seq=1 ttl=254 time=1.391 ms
84 bytes from 8.8.8.8 icmp_seq=2 ttl=254 time=1.734 ms
84 bytes from 8.8.8.8 icmp_seq=3 ttl=254 time=1.562 ms
84 bytes from 8.8.8.8 icmp_seq=4 ttl=254 time=1.683 ms
84 bytes from 8.8.8.8 icmp_seq=5 ttl=254 time=1.224 ms

PC2> ping 1.1.1.1  
84 bytes from 1.1.1.1 icmp_seq=1 ttl=253 time=1.709 ms
84 bytes from 1.1.1.1 icmp_seq=2 ttl=253 time=1.389 ms
84 bytes from 1.1.1.1 icmp_seq=3 ttl=253 time=1.912 ms
84 bytes from 1.1.1.1 icmp_seq=4 ttl=253 time=1.801 ms
84 bytes from 1.1.1.1 icmp_seq=5 ttl=253 time=1.428 ms

PC2> ping 8.8.8.8
84 bytes from 8.8.8.8 icmp_seq=1 ttl=254 time=1.548 ms
84 bytes from 8.8.8.8 icmp_seq=2 ttl=254 time=1.850 ms
84 bytes from 8.8.8.8 icmp_seq=3 ttl=254 time=2.033 ms
84 bytes from 8.8.8.8 icmp_seq=4 ttl=254 time=1.472 ms
84 bytes from 8.8.8.8 icmp_seq=5 ttl=254 time=1.262 ms

2. Cấu hình VPN IPSec đảm bảo PC1 ping thấy PC2 bằng VPN
a. Cấu hình IPSec Phase 1: ISAKMP (IKE) - ISAKMP policy)
!R1
crypto isakmp policy 1
 encryption 3des
 hash md5
 authentication pre-share
 group 2
lifetime 86400
exit

crypto isakmp key cisco address 2.2.2.2

!R2
crypto isakmp policy 1
 encryption 3des
 hash md5
 authentication pre-share
 group 2
lifetime 86400
exit

crypto isakmp key cisco address 1.1.1.1

b. Cấu hình IPSec Phase 2 

Transform Set
!R1
crypto ipsec transform-set TS esp-3des esp-md5-hmac

!R2
crypto ipsec transform-set TS esp-3des esp-md5-hmac

- Tạo Access-List Extended chỉ dùng cho traffic của VPN
!R1
ip access-list extended VPN-Traffic
 permit ip 10.1.1.0 0.0.0.255 20.1.1.0 0.0.0.255
 deny   ip any any

!R2
ip access-list extended VPN-Traffic
 permit ip 20.1.1.0 0.0.0.255 10.1.1.0 0.0.0.255
 deny   ip any any

- Cấu hình Crypto Map
!R1
crypto map CMAP 10 ipsec-isakmp
 set peer 2.2.2.2
 set transform-set TS
 match address VPN-Traffic
! gặp thông báo là
% NOTE: This new crypto map will remain disabled until a peer and a valid access list have been configured.

!R2
crypto map CMAP 20 ipsec-isakmp
 set peer 1.1.1.1
 set transform-set TS
 match address VPN-Traffic

- Gán Cryptp Map vào cổng e0/1 (outgoing interface)
!R1
interface Ethernet0/1
 crypto map CMAP

!R2
interface Ethernet0/2
 crypto map CMAP

Đến đây đã cấu hình xong  IPSec VPN tuy nhiên vẫn không thiết lập session được. Hiện tại tồn tại 2 Access List:
+ To_Internet của NAT overload
+ VPN-Traffic của VPN
Trong trường hợp này access-list của NAT overload chạy trước nên khi đứng từ PC1 ping đến PC2 sẽ qua đường NAT overload (đổi IP từ 10.1.1.10 sang IP 1.1.1.1) để đến router R3, router R3 không có bảng route đến PC2 20.1.1.20 nên R3 không thể đến được PC2, vậy ta cần phải sửa access-list của NAT overload (access-list có tên To_Internet ) là: nếu dữ liệu từ PC1 đến PC2 thì không cần NAT và phải qua tunnel bắt buộc phải map vào access-list VPN-Traffic 

!Kiểm chứng
PC1> ping 20.1.1.20
*1.1.1.3 icmp_seq=1 ttl=254 time=1.694 ms (ICMP type:3, code:1, Destination host unreachable)
*1.1.1.3 icmp_seq=2 ttl=254 time=1.537 ms (ICMP type:3, code:1, Destination host unreachable)
*1.1.1.3 icmp_seq=3 ttl=254 time=1.552 ms (ICMP type:3, code:1, Destination host unreachable)
*1.1.1.3 icmp_seq=4 ttl=254 time=1.478 ms (ICMP type:3, code:1, Destination host unreachable)
*1.1.1.3 icmp_seq=5 ttl=254 time=1.636 ms (ICMP type:3, code:1, Destination host unreachable)

R1#show access-lists 
Extended IP access list To_Internet
    10 permit ip 10.1.1.0 0.0.0.255 any (5 matches)
    20 deny ip any any
Extended IP access list VPN-Traffic
    10 permit ip 10.1.1.0 0.0.0.255 20.1.1.0 0.0.0.255
    20 deny ip any any

R1#show crypto session 
Crypto session current status

Interface: Ethernet0/1
Session status: UP-IDLE
Peer: 2.2.2.2 port 500 
  IKEv1 SA: local 1.1.1.1/500 remote 2.2.2.2/500 Active 
  IPSEC FLOW: deny ip 0.0.0.0/0.0.0.0 0.0.0.0/0.0.0.0 
        Active SAs: 0, origin: crypto map
  IPSEC FLOW: permit ip 10.1.1.0/255.255.255.0 20.1.1.0/255.255.255.0 

        Active SAs: 0, origin: crypto map

!Phân tích trên wireshark


- Sửa lại Access list NAT overload (Exclude traffic của VPN ra khỏi NAT overload) phải đưa dòng này lên trên.
!R1
ip access-list extended To_Internet
5 deny   ip 10.1.1.0 0.0.0.255 20.1.1.0 0.0.0.255

!R2
ip access-list extended To_Internet
5 deny   ip 20.1.1.0 0.0.0.255 10.1.1.0 0.0.0.255

!Kiểm tra
PC1> ping 20.1.1.20
84 bytes from 20.1.1.20 icmp_seq=1 ttl=62 time=2.179 ms
84 bytes from 20.1.1.20 icmp_seq=2 ttl=62 time=2.592 ms
84 bytes from 20.1.1.20 icmp_seq=3 ttl=62 time=2.406 ms
84 bytes from 20.1.1.20 icmp_seq=4 ttl=62 time=2.624 ms
84 bytes from 20.1.1.20 icmp_seq=5 ttl=62 time=2.589 ms

R1#show access-lists 
Extended IP access list To_Internet
    5 deny ip 10.1.1.0 0.0.0.255 20.1.1.0 0.0.0.255 (5 matches)
    10 permit ip 10.1.1.0 0.0.0.255 any
    20 deny ip any any
Extended IP access list VPN-Traffic
    10 permit ip 10.1.1.0 0.0.0.255 20.1.1.0 0.0.0.255 (5 matches)
    20 deny ip any any

!Kiểm tra kết nối IPSec phase 1
R1#show crypto isakmp sa 
IPv4 Crypto ISAKMP SA
dst                  src             state                  conn-id status
2.2.2.2         1.1.1.1         QM_IDLE           1001 ACTIVE

!Kiểm tra kết nối IPSec phase 2
R1#show crypto ipsec sa

interface: Ethernet0/1
    Crypto map tag: CMAP, local addr 1.1.1.1

   protected vrf: (none)
   local  ident (addr/mask/prot/port): (10.1.1.0/255.255.255.0/0/0)
   remote ident (addr/mask/prot/port): (20.1.1.0/255.255.255.0/0/0)
   current_peer 2.2.2.2 port 500
     PERMIT, flags={origin_is_acl,}
    #pkts encaps: 615, #pkts encrypt: 615, #pkts digest: 615
    #pkts decaps: 586, #pkts decrypt: 586, #pkts verify: 586
    #pkts compressed: 0, #pkts decompressed: 0
    #pkts not compressed: 0, #pkts compr. failed: 0
    #pkts not decompressed: 0, #pkts decompress failed: 0
    #send errors 0, #recv errors 0

     local crypto endpt.: 1.1.1.1, remote crypto endpt.: 2.2.2.2
     path mtu 1500, ip mtu 1500, ip mtu idb Ethernet0/1
     current outbound spi: 0x31832B(3244843)
     PFS (Y/N): N, DH group: none

     inbound esp sas:
      spi: 0xE3E0F005(3823169541)
        transform: esp-3des esp-md5-hmac ,
        in use settings ={Tunnel, }
        conn id: 5, flow_id: SW:5, sibling_flags 80004040, crypto map: CMAP
        sa timing: remaining key lifetime (k/sec): (4189305/607)
        IV size: 8 bytes
        replay detection support: Y
        Status: ACTIVE(ACTIVE)

     inbound ah sas:

     inbound pcp sas:

     outbound esp sas:
      spi: 0x31832B(3244843)
        transform: esp-3des esp-md5-hmac ,
        in use settings ={Tunnel, }
        conn id: 6, flow_id: SW:6, sibling_flags 80004040, crypto map: CMAP
        sa timing: remaining key lifetime (k/sec): (4189305/607)
        IV size: 8 bytes
        replay detection support: Y
        Status: ACTIVE(ACTIVE)

     outbound ah sas:
     outbound pcp sas:

!Kiểm tra session IPSec hiện tại
R1#sh crypto session 
Crypto session current status

Interface: Ethernet0/1
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: deny ip 0.0.0.0/0.0.0.0 0.0.0.0/0.0.0.0 
        Active SAs: 0, origin: crypto map
  IPSEC FLOW: permit ip 10.1.1.0/255.255.255.0 20.1.1.0/255.255.255.0 
        Active SAs: 2, origin: crypto map

!Phân tích trên wireshark
Ta chỉ thấy thiết lập peer 1.1.1.1 và 2.2.2.2 còn dữ liệu thì đã được mã hóa và sử dụng giao thức ESP như ta đã cấu hình ở phần Transform Set (crypto ipsec transform-set TS esp-3des esp-md5-hmac)

Xong

Cisco, Configure Site to Site IPSec VPN Tunnel



Các kiến thức dùng trong bài lab: Default route, Nat overload, Access List, VPN

Yêu cầu:
1. Đấu dây và đặt IP như hình (qui ước đặt IP theo số của Router), cấu hình Default route, Nat overload, Accesslist đảm bảo:
  • R1 có thể ping thấy R2
  • Site 1:  chỉ duy nhất lớp mạng 10.1.1.0 có thể ping thông 8.8.8.8
  • Site 2:  chỉ duy nhất lớp mạng 20.1.1.0 có thể ping thông 8.8.8.8

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*/