Lab 17.2 IPSEC VPN site-to-site chứng thực qua CA 2k8

root

Leader IT/Architect
Dec 31, 2012
1,153
72
48
I. Sơ đồ
1. Sơ đồ mô hình

1.jpg

2. Sơ đồ IP

ASA1g0: outside: 151.1.1.1/24
g1: inside: 192.168.10.1/24
PC1IP: 192.168.10.10/24
Gateway: 192.168.10.1
ISPf0/0: 151.1.1.254/24
f0/1: 152.2.2.254/24
f1/0: 10.1.1.254/24
f2/0: DHCP
ASA2g0: outside, 152.2.2.2/24
g1: inside, 192.168.20.2/24
PC2IP: 192.168.20.20/24
Gateway: 192.168.20.2/24

3. Yêu cầu
- Cấu hình VPN site-to-site xác thực bằng RSA (sử dụng CA trên windows server 2008R2 )
- Đảm bảo 2 mạng ra inside của 2 ASA: 192.168.10.0/24 và 192.168.20.0/24 thấy nhau và đi ra internet thành công

II. Triển khai

1. Cấu hình ISP
- Ở đây mình sẽ dùng 1 Router giả lập làm ISP cho phép ra internet

ISP(config)#int f0/0
ISP(config-if)#ip address 150.1.1.254 255.255.255.0
ISP(config-if)#no shutdown
ISP(config-if)#int f0/1
ISP(config-if)#ip address
ISP(config-if)#ip address 152.2.2.254 255.255.255.0
ISP(config-if)#no shutdown
ISP(config-if)#int f1/0
ISP(config-if)#ip address 10.1.1.254 255.255.255.0
ISP(config-if)#no shutdown

// Lấy IP được cấp từ model xuống
ISP(config-if)#int f2/0
ISP(config-if)#ip address dhcp
ISP(config-if)#no shutdown
ISP(config-if)#exit

//NAT ra internet
ISP(config)#access-list 1 permit any
ISP(config)#ip nat inside source list 1 interface f2/0 overload

ISP(config)#int f2/0
ISP(config-if)#ip nat outside
ISP(config-if)#int f1/0
ISP(config-if)#ip nat inside
ISP(config-if)#int f0/0
ISP(config-if)#ip nat inside
ISP(config-if)#int f0/1
ISP(config-if)#ip nat inside

2. Cấu hình ASA1
- Cấu hình IP và default-route
ASA1(config)# int g0
ASA1(config-if)# nameif outside
ASA1(config-if)# ip address 151.1.1.1 255.255.255.0
ASA1(config-if)# no shutdown

ASA1(config)# int g1
ASA1(config-if)# nameif inside
ASA1(config-if)# ip address 192.168.10.1 255.255.255.0
ASA1(config-if)# no shutdown

ASA1(config)# route outside 0 0 151.1.1.254
ASA1(config-if)# fixup protocol icmp

- Đảm bảo ASA ra internet thành công

ASA1(config)# ping 8.8.8.8
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 100/126/140 ms
- Cấu hình xin CA từ CA server
- Cấu hình hostname và map IP của CA 2k8 thành tên CASERVER

ASA1(config)# domain-name svuit.com
ASA1(config)# name 10.1.1.10 CASERVER

- Tạo RSA key thành công
Code:
ASA1(config)#[COLOR=#ff0000] crypto ca authenticate CA[/COLOR]


INFO: Certificate has the following attributes:
Fingerprint:     6c68062d 92188438 fc44cd32 918bda27
Do you accept this certificate? [yes/no]: [COLOR=#ff0000]yes[/COLOR]

[COLOR=#ff0000]Trustpoint CA certificate accepted.[/COLOR]

- Dùng 1 PC truy cập CA server để lây password enrollment challenge. Ở đây bạn có thể dùng chính AD2k8 truy cập = localhost thay vì dùng IP như dưới đây. Để nhìn thực tế xíu thì mình sẽ dùng IP để truy cập vào CA. Và bạn phải cấu hình DNS cho CA để nó phân giải tên

- Bạn copy Password enrollment challenge trong khung màu đỏ dưới đây


- Cấu hình thông tin CA.
Code:
ASA1(config)# [COLOR=#ff0000]crypto ca enroll CA[/COLOR]
%
% Start certificate enrollment ..
% Create a challenge password. You will need to verbally provide this
   password to the CA Administrator in order to revoke your certificate.
   For security reasons your password will not be saved in the configuration.
   Please make a note of it.
[COLOR=#ff0000]Password: ****************  [/COLOR][I][COLOR=#00ff00]// điền password enrollment challenge mà bạn đã lấy được ở trên[/COLOR][/I]
[COLOR=#ff0000]Re-enter password: ****************[/COLOR]


% The subject name in the certificate will be: cn=svuit O=svuit ou=svuit e=svuit.com


% The fully-qualified domain name in the certificate will be: ASA1.svuit.com


% Include the device serial number in the subject name? [yes/no]: [COLOR=#ff0000]no[/COLOR]


Request certificate from CA? [yes/no]: [COLOR=#ff0000]yes[/COLOR]
[COLOR=#ff0000]% Certificate request sent to Certificate Authority[/COLOR]
- Bây giờ trên máy CA 2k8 bạn kiểm tra trạng thái Pending bạn sẽ thấy 1 certificate mới. Và chúng ta cần issued để chấp nhận chứng chỉ này


- Qua trình cấp phép thành công

- Sau khi CA 2k8 issue chứng chỉ thì bạn quay lại ASA sẽ xuất hiện dòng dưới đây cho biết certificate đã được cấp và quá trình enroll thành công

ASA1(config)# The certificate has been granted by CA!

- Công việc cấu hình IPSEC-VPN trên ASA 8.4 các bạn thực hiện tương tự các bài lab trước. Tuy nhiên có vài điểm thay đổi. Trước kia chúng ta xác thực với nhau bằng pre-share key nhưng bây giờ chúng ta xác thực bằng CA :)
ASA1(config)# crypto ikev1 policy 10
ASA1(config-ikev1-policy)# authentication rsa-sig
ASA1(config-ikev1-policy)# encryption 3des
ASA1(config-ikev1-policy)# hash md5
ASA1(config-ikev1-policy)# group 2
ASA1(config-ikev1-policy)# lifetime 86400

ASA1(config)# crypto ipsec ikev1 transform-set SVUIT esp-3des esp-md5-hmac

ASA1(config-if)# object network INSIDE-ASA1
ASA1(config-network-object)# subnet 192.168.10.0 255.255.255.0
ASA1(config)# object network INSIDE-ASA2
ASA1(config-network-object)# subnet 192.168.20.0 255.255.255.0
ASA1(config)# access-list VPN-TRAFFIC permit ip object INSIDE-ASA1 object INSIDE-ASA2
ASA1(config)# crypto map ASA-VPN 10 match address VPN-TRAFFIC
ASA1(config)# crypto map ASA-VPN 10 set peer 152.2.2.2
ASA1(config)# crypto map ASA-VPN 10 set ikev1 transform-set SVUIT
ASA1(config)# crypto map ASA-VPN 10 set trustpoint CA
ASA1(config)# crypto map ASA-VPN interface outside
ASA1(config)# crypto ikev1 enable outside

ASA1(config)# tunnel-group 152.2.2.2 type ipsec-l2l
ASA1(config)# tunnel-group 152.2.2.2 ipsec-attributes
ASA1(config-tunnel-ipsec)# ikev1 trust-point CA

3. Trên ASA2
- Các bạn cấu hình tương tự trên ASA2 nhé
- Cấu hình IP và default-route

ASA2(config-if)# int g0
ASA2(config-if)# nameif outside
ASA2(config-if)# ip address 152.2.2.2 255.255.255.0
ASA2(config-if)# no shutdown

ASA2(config)# interface g1
ASA2(config-if)# nameif inside
ASA2(config-if)# ip address 192.168.20.2 255.255.255.0
ASA2(config-if)# no shutdown

ASA2(config)# route outside 0 0 152.2.2.254
ASA2(config-if)# fixup protocol icmp

- Cấu hình map IP CA sang tên, tạo RSA key và cấu hình thông tin xác thực CA

ASA2(config)# domain-name svuit.com
ASA2(config)# name 10.1.1.10 CASERVER

ASA2(config)# crypto key generate rsa general-keys
ASA2(config)# crypto ca trustpoint CA
ASA2(config-ca-trustpoint)# enrollment url http://CASERVER:80/certsrv/mscep/mscep.dll
ASA2(config-ca-trustpoint)# subject-name cn=svuit O=svuit ou=svuit e=svuit.com

- Cấu hình xác thực với CA

Code:
ASA2(config)# [COLOR=#ff0000]crypto ca authenticate CA[/COLOR]


INFO: Certificate has the following attributes:
Fingerprint:     6c68062d 92188438 fc44cd32 918bda27
Do you accept this certificate? [yes/no]: [COLOR=#ff0000]yes[/COLOR]


Trustpoint CA certificate accepted.
- Thực hiện Enroll CA.

Code:
ASA2(config)# [COLOR=#ff0000]crypto ca enroll CA[/COLOR]
%
% Start certificate enrollment ..
% Create a challenge password. You will need to verbally provide this
   password to the CA Administrator in order to revoke your certificate.
   For security reasons your password will not be saved in the configuration.
   Please make a note of it.
[COLOR=#ff0000]Password: ****************[/COLOR] [I][COLOR=#00ff00]//password này khác với password ở trên, bạn thực hiện lấy pass giống như ở trên[/COLOR][/I]
Re-enter password: ****************


% The subject name in the certificate will be: cn=svuit O=svuit ou=svuit e=svuit.com


% The fully-qualified domain name in the certificate will be: ASA2.svuit.com


% Include the device serial number in the subject name? [yes/no]: [COLOR=#ff0000]no[/COLOR]


Request certificate from CA? [yes/no]: [COLOR=#ff0000]yes[/COLOR]
% Certificate request sent to Certificate Authority
ASA1(config)# [COLOR=#ff0000]The certificate has been granted by CA![/COLOR]
- Chấp nhận Certificate mới của ASA2


- Trên CA 2k8 lúc này sẽ có cả 2 Certificate của ASA1 và ASA2




- Cấu hình IPSEC-VPN trên ASA2 chứng thực bằng RSA

ASA2(config)# crypto ikev1 policy 10
ASA2(config-ikev1-policy)# authentication rsa-sig
ASA2(config-ikev1-policy)# encryption 3des
ASA2(config-ikev1-policy)# hash md5
ASA2(config-ikev1-policy)# group 2
ASA2(config-ikev1-policy)# lifetime 86400


ASA2(config)# crypto ipsec ikev1 transform-set SVUIT esp-3des esp-md5-hmac

ASA2(config-if)# object network INSIDE-ASA1
ASA2(config-network-object)# subnet 192.168.10.0 255.255.255.0
ASA2(config)# object network INSIDE-ASA2
ASA2(config-network-object)# subnet 192.168.20.0 255.255.255.0
ASA2(config)# access-list VPN-TRAFFIC permit ip object INSIDE-ASA2 object INSIDE-ASA1
ASA2(config)# crypto map ASA-VPN 10 match address VPN-TRAFFIC
ASA2(config)# crypto map ASA-VPN 10 set peer 151.1.1.1
ASA2(config)# crypto map ASA-VPN 10 set ikev1 transform-set SVUIT
ASA2(config)# crypto map ASA-VPN 10 set trustpoint CA
ASA2(config)# crypto map ASA-VPN interface outside
ASA2(config)# crypto ikev1 enable outside

ASA2(config)# tunnel-group 151.1.1.1 type ipsec-l2l
ASA2(config)# tunnel-group 151.1.1.1 ipsec-attributes
ASA2(config-tunnel-ipsec)# ikev1 trust-point CA

 
4. Cấu hình NAT overload và NAT exemption
- Cấu hình PAT để PC trong inside ASA ra internet và cấu hình NAT exemption để client có thể VPN

ASA1(config)# object network INSIDE-ASA1
ASA1(config-network-object)# nat (inside,outside) dynamic interface


ASA1(config)#nat (inside,outside) source static INSIDE-ASA1 INSIDE-ASA1 destination static INSIDE-ASA2 INSIDE-ASA2

- Cấu hình tương tự trên ASA2

ASA1(config)# object network INSIDE-ASA1
ASA1(config-network-object)# nat (inside,outside) dynamic interface

ASA1(config)#nat (inside,outside) source static INSIDE-ASA1 INSIDE-ASA1 destination static INSIDE-ASA2 INSIDE-ASA2

III. Kiểm tra
- Bây giờ là tới công đoạn thu thành quả sau 1 thời gian cấu hình phê tay :)
- Kiểm tra certificate trên CA

Code:
ASA1# sh crypto ca certificates CA
Certificate
  Status: Available
  Certificate Serial Number: 6126fc29000000000004
  Certificate Usage: General Purpose
  Public Key Type: RSA (1024 bits)
  Signature Algorithm: SHA1 with RSA Encryption
  Issuer Name:
    cn=WIN-A1BNMMHMO2S-CA
  Subject Name:
    cn=svuit O\=svuit ou\=svuit e\=svuit.com
    hostname=ASA1.svuit.com
  CRL Distribution Points:
    [1]  file://WIN-A1BNMMHMO2S/CertEnroll/WIN-A1BNMMHMO2S-CA.crl
  Validity Date:
    start date: 09:26:23 UTC Jul 25 2014
    end   date: 09:36:23 UTC Jul 25 2015
  Associated Trustpoints: CA


CA Certificate
  Status: Available
  Certificate Serial Number: 0ade7cdd23724fa742db353bc233fb52
  Certificate Usage: Signature
  Public Key Type: RSA (2048 bits)
  Signature Algorithm: SHA1 with RSA Encryption
  Issuer Name:
    cn=WIN-A1BNMMHMO2S-CA
  Subject Name:
    cn=WIN-A1BNMMHMO2S-CA
  Validity Date:
    start date: 06:17:25 UTC Jul 5 2014
    end   date: 06:27:24 UTC Jul 5 2019
  Associated Trustpoints: CA
- Kiểm tra trạng thái ikev1

Code:
ASA1# sh crypto ikev1 sa


IKEv1 SAs:


   Active SA: 1
    Rekey SA: 0 (A tunnel will report 1 Active and 1 Rekey SA during rekey)
Total IKE SA: 1


1   IKE Peer: 152.2.2.2
    Type    : L2L             Role    : initiator
    Rekey   : no              State   : MM_ACTIVE
- Kiểm tra trạng thái IPSEC

Code:
ASA1# sh crypto ipsec sa
interface: outside
    Crypto map tag: ASA-VPN, seq num: 10, local addr: 151.1.1.1


      access-list VPN-TRAFFIC extended permit ip 192.168.10.0 255.255.255.0 192.168.20.0 255.255.255.0
      local ident (addr/mask/prot/port): (192.168.10.0/255.255.255.0/0/0)
      remote ident (addr/mask/prot/port): (192.168.20.0/255.255.255.0/0/0)
      current_peer: 152.2.2.2


      #pkts encaps: 14, #pkts encrypt: 14, #pkts digest: 14
      #pkts decaps: 14, #pkts decrypt: 14, #pkts verify: 14
      #pkts compressed: 0, #pkts decompressed: 0
      #pkts not compressed: 14, #pkts comp failed: 0, #pkts decomp failed: 0
      #pre-frag successes: 0, #pre-frag failures: 0, #fragments created: 0
      #PMTUs sent: 0, #PMTUs rcvd: 0, #decapsulated frgs needing reassembly: 0
      #send errors: 0, #recv errors: 0


      local crypto endpt.: 151.1.1.1/0, remote crypto endpt.: 152.2.2.2/0
      path mtu 1500, ipsec overhead 58, media mtu 1500
      current outbound spi: C2505B2E
      current inbound spi : 0C8FFEE8


    inbound esp sas:
      spi: 0x0C8FFEE8 (210763496)
         transform: esp-3des esp-md5-hmac no compression
         in use settings ={L2L, Tunnel, }
         slot: 0, conn_id: 8192, crypto-map: ASA-VPN
         sa timing: remaining key lifetime (kB/sec): (3914999/28713)
         IV size: 8 bytes
         replay detection support: Y
         Anti replay bitmap:
          0x00000000 0x00007FFF
    outbound esp sas:
      spi: 0xC2505B2E (3260046126)
         transform: esp-3des esp-md5-hmac no compression
         in use settings ={L2L, Tunnel, }
         slot: 0, conn_id: 8192, crypto-map: ASA-VPN
         sa timing: remaining key lifetime (kB/sec): (3914999/28713)
         IV size: 8 bytes
         replay detection support: Y
         Anti replay bitmap:
          0x00000000 0x00000001

- PC trong vùng inside của 2 ASA đi được internet và thấy nhau
- PC1 trong inside của ASA1 ra internet và ping thấy PC2 trong inside của ASA2


- Tương tự PC2 trong inside của ASA2 truy cập web ngoài internet và web trong inside của ASA1 thành công

 
1 vài lỗi hay gặp khi cấu hình CA, khá là bực mềnh :)

- Ưu tiên hàng đâu khi cấu hình ok hết mà vẫn ko chạy là đồng bộ NTP giữa ASA và CA ...lỗi củ chuối nhất :)
- và 1 vài lệnh để debug khi cấu hình

asa(config)# debug crypto ca 255
asa(config)# debug crypto ca messages
asa(config)# debug crypto ca transactions

1. ERROR: receiving Certificate Authority certificate: status = FAIL, cert length = 0
- debug trên ASA các bạn thấy
ASA(config)#
CRYPTO_PKI: HTTP response header:
HTTP/1.1 401 Unauthorized
Content-Type: text/html
Server: Microsoft-IIS/7.5
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
Date: Sat, 05 Jul 2014 07:49:48 GMT
Connection: close
Content-Length: 1293

Content-Type indicates we did not receive a certificate.
FIX: có lẽ do bạn cài thiếu chức năng của CA. Bạn vào Role của CA 2k8 cài thêm Features như hình cho mình nhé

334.jpg


2. Sau khi fix lỗi số 1 nếu các bạn gặp lỗi này
ASA(config)#
CRYPTO_PKI: HTTP response header:
HTTP/1.1 404 Not Found
Content-Type: text/html
Server: Microsoft-IIS/7.5
Date: Sat, 05 Jul 2014 08:51:34 GMT
Connection: close
Content-Length: 1245

Content-Type indicates we did not receive a certificate.

- Các bạn lên máy CA và truy cập: http://152.2.2.20/certsrv/mscep/mscep.dll.
- Nếu bào lỗi thì bạn cần cài thêm service
 

About us

  • Securityzone.vn là một trang web chuyên về an ninh mạng và công nghệ thông tin. Trang web này cung cấp các bài viết, tin tức, video, diễn đàn và các dịch vụ liên quan đến lĩnh vực này. Securityzone.vn là một trong những cộng đồng IT lớn và uy tín tại Việt Nam, thu hút nhiều người quan tâm và tham gia. Securityzone.vn cũng là nơi để các chuyên gia, nhà nghiên cứu, sinh viên và người yêu thích an ninh mạng có thể trao đổi, học hỏi và chia sẻ kiến thức, kinh nghiệm và giải pháp về các vấn đề bảo mật trong thời đại số.

Quick Navigation

User Menu