IPSec - Internet Protocol Security

Sau đây là một số tips để dễ nhớ về IPSec:

- ISAKMP cung cấp phương thức để nhận biết và trao đổi khóa và các thuộc tính security để đảm bảo an toàn khi truyền thông giữa các thiết bị, các thông tin này được quản lý bởi SA (Security Asociation).
- SA chứa các chính sách quản lý các giải thuật và khóa, cung cấp tất cả các thông tin cần thiết để đảm bảo an toàn trong quá trình chuyển tải dữ liệu.

-Đầu tiên, các thiết bị cần thỏa thuận 3 điểm sau:
1) Encryption: xác định loại giải thuật mã hóa (DES, triple DES)
2) Integrity: xác định loại giải thuật để đảm bảo an toàn cho dữ liệu (MD5 or SHA-1)
3) Authentication: xác định loại khóa sử dụng để mã hóa đường truyền (public-key certificate, shared secret key or Kerberos).

Sau khi đã thống nhất được các điều trên thì sẽ tiến hành thương lượng với nhau về loại cơ chế điều khiển để đảm bảo an toàn khi gửi dữ liệu qua public network như sau:
1) AH (Authentication Header): xác định có dùng AH protocol hay ko
2) ESP (Encapsulation Security Payload): xác định có dùng ESP protocol hay ko
3) Xác định loại authentication sẽ dùng trong AH
4) Xác định loại encryption sẽ dùng trong ESP

- IPSec có 2 cơ chế điều khiển để đảm bảo an toàn khi gửi dữ liệu qua public network đó là AH mechanism và ESP mechanism.

Notes: Lưu ý rằng có thể sử dụng đồng thời cả 2 cơ chế cùng lúc.

1. AH mechanism:
Gói tin trước khi gửi đi sẽ chèn thêm vào Header Authentication ở giữa layer3 và layer4 để đảm bảo tính authentication để tránh khỏi sự giả mạo khi hacker ngồi ở giữa và sửa đổi nội dung gói tin để giả mạo bên gửi và bên nhận để lấy cắp thông tin.
Để làm được điều này, IPSec dùng Authentication Header như là chữ ký điện tử (digital signature) để đánh dấu các gói tin. Chữ ký này mang lại lợi ích là có thể phòng ngừa các cuộc tấn công kiểu replay attack, tampering và spoofing.

2. ESP mechanism:
AH chỉ tránh được vấn đề mạo danh người dùng nhưng dữ liệu vẫn có thể xem được. Khi đó ESP được dùng để mã hoá toàn bộ payload và dữ liệu được đảm bảo an toàn.
ESP hay và phức tạp hơn AH vì nó có tính năng authentication, chống replay-proofing và đảm bảo toàn vẹn dữ liệu (integrity). Khi đó, gói tin sẽ được thêm vào 3 thành phần:
1) ESP header
2) ESP trailer
3) ESP authentication block.

more and more...

Ví dụ:

(LAN1)
|192.168.80.9/24
|
|192.168.80.222/24
(R1)
|192.168.10.1/30
|
|192.168.10.2/30
(R2)
|10.10.10.1/24
|
(LAN2)


- Lab này thực hiện ping và telnet từ LAN1 đến LAN2 (192.168.0.9 to 10.10.10.1), routing sử dụng static route.
- Khi ko cấu hình IPSec, thì kết quả bình thường.
- Khi cấu hình IPSec, packet sẽ đi qua tunnel 192.168.10.1-192.168.10.2 mà không quan tâm đến source and destination addresses.


! @(#)IPsec Cisco router configuration 10 MAY 2000 Rob Thomas robt@cymru.com
!
crypto isakmp policy 1
! Set the crypto policy to ISAKMP, priority 1.
hash md5
! Use MD5 as the authentication algorithm (instead
! of SHA, which is slower yet more secure).
authentication pre-share
! Utilize the hard-coded key "123FOO123".
!
crypto isakmp key 123FOO123 address 192.168.10.2
! Set the key and the peer with whom to share the
! key. Be careful not to share this with anyone!
!
crypto ipsec transform-set OURIPS esp-des esp-md5-hmac
! Create a transform set called OURIPS that utilizes
! ESP (Encapsulating Security Payload) encrypted with
! DES and authenticated with MD5. In this case, we
! will encrypt only the payload of the packet, not the
! header.
!
crypto map IPSEC-TO-RMT local-address Ethernet0
! Specify that the crypto map called IPSEC-TO-RMT
! will use the local-address on E0 for identification
! purposes. This is not always necessary, but makes
! for nice documentation.
!
crypto map IPSEC-TO-RMT 1 ipsec-isakmp
! Map IPSEC-TO-RMT, sequence number 1, that uses
! ISAKMP for key exchange.
set peer 192.168.10.2
! Our remote peer
set transform-set OURIPS
! Apply the proper transform set (q.v.)
match address IPSEC-TUN
! Only IPSEC the packets that match the extended
! ACL named IPSEC-TUN

ip access-list extended IPSEC-TUN
! Build an ACL to use for IPSEC.
remark IPSEC ACL
! Comments are good. :-)
permit ip any any
! This is a bit misleading. While it will attempt
! to ESP encrypt all packets, multicast packets can
! not be encrypted with IPSEC. For multicast pack-
! ets, a GRE tunnel must be used. Recall that most
! routing protocols use multicast (OSPF, RIP v2) for
! the routing updates.

interface Ethernet0
ip address 192.168.10.1 255.255.255.252
no ip redirects
no ip proxy-arp
no ip mroute-cache
crypto map IPSEC-TO-RMT
! Apply the crypto map IPSEC-TO-RMT to the e0
! interface.

Snoop before IPSEC configuration:

192.168.80.9 -> 10.10.10.1 ICMP Echo request
10.10.10.1 -> 192.168.80.9 ICMP Echo reply
192.168.80.9 -> 10.10.10.1 ICMP Echo request
10.10.10.1 -> 192.168.80.9 ICMP Echo reply
192.168.80.9 -> 10.10.10.1 ICMP Echo request
10.10.10.1 -> 192.168.80.9 ICMP Echo reply

Snoop after IPSEC configuration:

192.168.10.1 -> 192.168.10.2 IP D=192.168.10.2 S=192.168.10.1 LEN=136, ID=243
192.168.10.2 -> 192.168.10.1 IP D=192.168.10.1 S=192.168.10.2 LEN=136, ID=625
192.168.10.1 -> 192.168.10.2 IP D=192.168.10.2 S=192.168.10.1 LEN=136, ID=244
192.168.10.2 -> 192.168.10.1 IP D=192.168.10.1 S=192.168.10.2 LEN=136, ID=628
192.168.10.1 -> 192.168.10.2 IP D=192.168.10.2 S=192.168.10.1 LEN=136, ID=245

Rob Thomas, robt@cymru.com
http://www.enteract.com/~robt