Lab 16.5 client-to-site IPSEC-VPN with AD Windows Server 2012

root

Leader IT/Architect
Dec 31, 2012
1,153
72
48
I. Mô hình và yêu cầu
1.Mô hình

1.jpg

2. Yêu cầu

- Thực hiện IPSEC-VPN client-to-site cho phép PC ngoài internet có thể VPN vào trong hệ thống mạng của ASA
- Cấu hình NAT để PC đi internet và VPN đều bình thường
- Cấu hình IPSEC-VPN sử dụng Ldap trên AD windows server 2012 để thực hiện chứng thực user/pass của VPN-Client
- Sơ đồ IP:
ASAg0
g1
nameif: outside, IP: 151.1.1.1/24
nameif: inside, IP: 192.168.10.1/24
Router ISPf0/0
f0/1
f1/0
IP: 151.1.1.254/24
IP: 152.2.2.254/24
IP: DHCP
AD2k12IP: 192.168.10.100/24
PC1IP: 192.168.10.10/24
Gateway: 192.168.10.1
PC2IP: 10.2.2.20/24
Gateway: 10.2.2.2

II. Triển khai

- Các yêu cầu 1 và 2 các bạn thực hiện tương tự trong bài lab trước Lab 16.5 nhé.
1. Trên Router ISP
- Cấu hình IP và NAT cho phép Client đi internet
ISP(config-if)#int f0/0
ISP(config-if)#ip address 151.1.1.254 255.255.255.0
ISP(config-if)#no shutdown
ISP(config-if)#int f0/1
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 dhcp

ISP(config)#ip access-list extended NAT
ISP(config-ext-nacl)#deny ip 152.2.2.0 255.255.255.0 151.1.1.1 255.255.255.0
ISP(config-ext-nacl)#permit ip any any

ISP(config)#ip nat inside source list NAT interface FastEthernet1/0 overload

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

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

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

ASA2config)# route outside 0 0 151.1.1.254

- Định nghĩa các subnet bằng object-network
ASA(config)# object network INSIDE-ASA
ASA(config-network-object)# subnet 192.168.10.0 255.255.255.0

ASA(config-network-object)# object network VPN-Client
ASA(config-network-object)# subnet 10.0.0.0 255.255.255.0

ASA(config-network-object)# object network OUTSIDE
ASA(config-network-object)# subnet 0.0.0.0 0.0.0.0


Cấu hình IPSEC-VPN
- Pharse 1:
ASA(config)# crypto ikev1 policy 10
ASA(config-ikev1-policy)# authentication pre-share
ASA(config-ikev1-policy)# encryption 3des
ASA(config-ikev1-policy)# hash md5
ASA(config-ikev1-policy)# group 2
ASA(config-ikev1-policy)# lifetime 86400

ASA(config)# crypto ikev1 enable outside

- Pharse 2:
ASA(config)# crypto ipsec ikev1 transform-set MYSET esp-3des esp-md5-hmac

ASA(config)# crypto dynamic-map DYNAMIC-MAP 10 set ikev1 transform-set MYSET
ASA(config)# crypto map MYMAP 10 ipsec-isakmp dynamic DYNAMIC-MAP
ASA(config)# crypto map MYMAP interface outside
ASA(config)# ip local pool MYPOOL 10.0.0.2-10.0.0.20 mask 255.255.255.0

ASA(config)# group-policy REMOTE-VPN internal
ASA(config)# group-policy REMOTE-VPN attributes
ASA(config-group-policy)# default-domain value svuit.com
ASA(config-group-policy)# address-pools value MYPOOL

ASA(config)# tunnel-group REMOTE-VPN type remote-access
ASA(config)# tunnel-group REMOTE-VPN general-attributes
ASA(config-tunnel-general)# default-group-policy REMOTE-VPN

ASA(config)# tunnel-group REMOTE-VPN ipsec-attributes
ASA(config-tunnel-ipsec)# ikev1 pre-shared-key svuit

ASA(config)# username svuit password svuit.com

- Cấu hình NAT
ASA(config)# object-group network VPN-Client
ASA(config-network-object-group)# network-object 10.0.0.0 255.255.255.0

ASA(config)# object-group network INSIDE
ASA(config-network-object-group)# network-object 192.168.10.0 255.255.255.0

ASA(config)# object-group network OUTSIDE
ASA(config-network-object-group)# network-object 0.0.0.0 0.0.0.0

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

ASA(config-if)# nat (inside,outside) source static INSIDE-ASA INSIDE-ASA destination static VPN-Client VPN-Client

- Đảm bảo Client có thể VPN được

 
3. Cấu hình Authentication giữa ASA và LDAP
- Bây giờ chúng ta sẽ vào tiết mục chính của bài lab này.
  • Khi client quay VPN đến ASA
  • ASA sẽ yêu cầu client chứng thực
  • Client sẽ gửi user/pass đến cho ASA
  • ASA nhận được user/pass của client và tìm trong LDAP server xem có thông tin không, nêu ok thì cho phép client VPN
- Cấu hình

- Bước 1: Ánh xạ Ldap với IETF-Radius-Class
ASA(config)# ldap attribute-map SVUIT
ASA(config-ldap-attribute-map)# map-name AD2K12 IETF-Radius-Class
ASA(config-ldap-attribute-map)# map-value AD2K12 CN=ADMIN,OU=SVUIT,DC=svuit,DC=com ADMIN
ASA(config-ldap-attribute-map)# map-value AD2K12 CN=STAFF,OU=SVUIT,DC=svuit,DC=com STAFF

- Cấu hình AAA để client VPN xác thực bằng LDAP server
ASA(config-ldap-attribute-map)# aaa-server LDAP protocol ldap
ASA(config-aaa-server-group)# aaa-server LDAP host 10.1.1.10
ASA(config-aaa-server-host)# ldap-base-dn OU=SVUIT,dc=svuit,dc=com

- Cấu hình thuộc tính LDAP và thực hiện xác thực giữa ASA và Ldap
ASA(config-aaa-server-host)# ldap-naming-attribute sAMAccountName

//123456abc! là password của administrator dùng để login trên AD windows server 2012
ASA(config-aaa-server-host)# ldap-login-password 123456abc!

ASA(config-aaa-server-host)# ldap-login-dn cn=administrator,cn=Users,dc=svuit,dc=com
ASA(config-aaa-server-host)# server-type microsoft
ASA(config-aaa-server-host)# ldap-attribute-map SVUIT

- Tạo các pool cấp cho client-VPN
ASA(config)# ip local pool ADMIN 10.10.10.0-10.10.10.100 mask 255.255.255.0
ASA(config)# ip local pool STAFF 20.20.20.0-20.20.20.100 mask 255.255.255.0

- Tao ACL cho phép group ADMIN truy cập vào subnet 192.168.10.0/24 trong inside của ASA
access-list VPN-ACL extended permit ip 192.168.10.0 255.255.255.0 10.10.10.0 255.255.255.0

- Cấu hình group-policy cho các nhóm user VPN
// dùng cho Group user STAFF
ASA(config)# group-policy STAFF internal
ASA(config)# group-policy STAFF attributes
ASA(config-group-policy)# address-pools value STAFF

//dùng cho group user ADMIN
ASA(config)# group-policy ADMIN internal
ASA(config)# group-policy ADMIN attributes
ASA(config-group-policy)# address-pools value ADMIN
// Cho phép group ADMIN truy cập vào vùng insdie
ASA(config-group-policy)#split-tunnel-policy tunnelspecified
ASA(config-group-policy)#split-tunnel-network-list value VPN-ACL

- Tạo và cấu hình Tunnel-group cho từng group-policy ở trên, add Ldap vào từng tunnel-group
// Đối với group ADMIN
ASA(config)# tunnel-group ADMIN general-attributes
ASA(config-tunnel-general)# default-group-policy ADMIN
ASA(config-tunnel-general)# authentication-server-group LDAP

ASA(config)# tunnel-group ADMIN ipsec-attributes
ASA(config-tunnel-ipsec)# ikev1 pre-shared-key svuit

// Đối với group STAFF
ASA(config)# tunnel-group STAFF general-attributes
ASA(config-tunnel-general)# default-group-policy STAFF
ASA(config-tunnel-general)# authentication-server-group LDAP

ASA(config)# tunnel-group STAFF ipsec-attributes
ASA(config-tunnel-ipsec)# ikev1 pre-shared-key svuit

4. Tạo user và group trên AD2k12
- Qua máy windows server AD 2012 các bạn tạo 2 group ADMIN và STAFF


- Group ADMIN có 2 user là admin


- Group STAFF có 1 user là staff1



5. Kiểm tra
5.1 VPN với group ADMIN
- PC thực hiện VPN với Group là ADMIN



- User là admin10


- Sau khi truy cập thành công các bạn mở cmd và sẽ thấy client group ADMIN sẽ được cấp IP có subnet 10.10.10.0/24 và nó có thể truy cập tới vùng inside của ASA


- Trên ASA thực hiện kiểm tra thấy có 1 session VPN của user admin10
ASA(config)# sh vpn-sessiondb ra-ikev1-ipsec

Session Type: IKEv1 IPsec

Username : admin10 Index : 21
Assigned IP : 10.10.10.1 Public IP : 152.2.2.20
Protocol : IKEv1 IPsec
License : Other VPN
Encryption : 3DES Hashing : MD5
Bytes Tx : 180 Bytes Rx : 180
Group Policy : ADMIN Tunnel Group : ADMIN
Login Time : 17:34:53 UTC+7 Sun Jun 29 2014
Duration : 0h:12m:09s
Inactivity : 0h:00m:00s
NAC Result : Unknown
VLAN Mapping : N/A VLAN : none

5.2 VPN với group STAFF
- Cấu hình VPN client với group STAFF


- Sử dụng user là staff1


- Sau khi VPN thành công các bạn sẽ thấy staff1 được cấp IP thuộc subnet 20.20.20.0/24 và nó không được phép truy cập vùng inside ASA


- Kiểm tra session VPN trên ASA
ASA(config)# sh vpn-sessiondb ra-ikev1-ipsec

Session Type: IKEv1 IPsec

Username : staff1 Index : 22
Assigned IP : 20.20.20.20 Public IP : 152.2.2.20
Protocol : IKEv1 IPsec
License : Other VPN
Encryption : 3DES Hashing : MD5
Bytes Tx : 0 Bytes Rx : 5528
Group Policy : STAFF Tunnel Group : STAFF
Login Time : 17:50:45 UTC+7 Sun Jun 29 2014
Duration : 0h:01m:19s
Inactivity : 0h:00m:00s
NAC Result : Unknown
VLAN Mapping : N/A VLAN : none
 
III. TIP và FIX
- NTP: Với ASA khi bạn sử dụng Authentication giữa ASA với 1 RADIUS server như : ACS, Windows server... Mặc dù các bạn đã cấu hình đúng hết mà nó không chạy. Các bạn hãy bình tĩnh xem NTP giữa ASA và RADIUS server có đồng bộ chưa, thằng NTP nhỏ mà cực kì nguy hiểm, hay gây ra các vấn đề làm cho a/e IT nhức đầu :)

- Khi gặp lỗi các bạn hãy dùng các câu lệnh debug để kiểm tra để biết bug nằm ở đâu và trị nó :)

- 1 vài lỗi hay gặp với LDAP và ASA. Để biết lỗi hãy debug ldap để biết lỗi :)
ASA(config)#debug ldap 255
[5] Session Start
[5] New request Session, context 0xbc1d99a8, reqType = Authentication
[5] Fiber started
[5] Creating LDAP context with uri=ldap://192.168.10.100:389
[5] Connect to LDAP server: ldap://192.168.10.100:389, status = Successful
[5] supportedLDAPVersion: value = 3
[5] supportedLDAPVersion: value = 2
[5] Binding as administrator
[5] Performing Simple authentication for administrator to 192.168.10.100
[5] LDAP Search:
Base DN = [OU=SVUIT,dc=svuit,dc=com]
Filter = [SVUIT-ACCOUNT=admin10]
Scope = [ONE LEVEL]
[5] User admin10 not found
[5] Fiber exit Tx=286 bytes Rx=560 bytes, status=-1
[5] Session End

FIX
ASA(config)# aaa-server LDAP (inside) host 192.168.10.100
ASA(config-aaa-server-host)# ldap-naming-attribute sAMAccountName

- và kết quả debug lại
ASA(config-aaa-server-host)#debug ldap 255
[6] Session Start
[6] New request Session, context 0xbc1d99a8, reqType = Authentication
[6] Fiber started
[6] Creating LDAP context with uri=ldap://192.168.10.100:389
[6] Connect to LDAP server: ldap://192.168.10.100:389, status = Successful
[6] supportedLDAPVersion: value = 3
[6] supportedLDAPVersion: value = 2
[6] Binding as administrator
[6] Performing Simple authentication for administrator to 192.168.10.100
[6] LDAP Search:
Base DN = [OU=SVUIT,dc=svuit,dc=com]
Filter = [sAMAccountName=admin10]
Scope = [ONE LEVEL]
[6] User DN = [CN=admin10,OU=SVUIT,DC=svuit,DC=com]
[6] Talking to Active Directory server 192.168.10.100
[6] Reading password policy for admin10, dn:CN=admin10,OU=SVUIT,DC=svuit,DC=com
[6] Read bad password count 0
[6] Binding as admin10
[6] Performing Simple authentication for admin10 to 192.168.10.100
[6] Processing LDAP response for user admin10
[6] Message (admin10):
[6] Authentication successful for admin10 to 192.168.10.100
[6] Retrieved User Attributes:
[6] objectClass: value = top
[6] objectClass: value = person
[6] objectClass: value = organizationalPerson
[6] objectClass: value = user
[6] cn: value = admin10
[6] givenName: value = admin10
[6] distinguishedName: value = CN=admin10,OU=SVUIT,DC=svuit,DC=com
[6] instanceType: value = 4
[6] whenCreated: value = 20140629060244.0Z
[6] whenChanged: value = 20140629060244.0Z
[6] displayName: value = admin10
[6] uSNCreated: value = 32798
[6] memberOf: value = CN=ADMIN,OU=SVUIT,DC=svuit,DC=com
[6] uSNChanged: value = 32805
[6] name: value = admin10
[6] objectGUID: value = .1F~...E...l$...
[6] userAccountControl: value = 66048
[6] badPwdCount: value = 0
[6] codePage: value = 0
[6] countryCode: value = 0
[6] badPasswordTime: value = 0
[6] lastLogoff: value = 0
[6] lastLogon: value = 0
[6] pwdLastSet: value = 130484953642867695
[6] primaryGroupID: value = 513
[6] objectSid: value = ............{...g..=.).bZ...
[6] accountExpires: value = 9223372036854775807
[6] logonCount: value = 0
[6] sAMAccountName: value = admin10
[6] sAMAccountType: value = 805306368
[6] userPrincipalName: value = admin10@svuit.com
[6] objectCategory: value = CN=Person,CN=Schema,CN=Configuration,DC=svuit,DC=com
[6] dSCorePropagationData: value = 20140629060244.0Z
[6] dSCorePropagationData: value = 16010101000000.0Z
[6] Fiber exit Tx=535 bytes Rx=2191 bytes, status=1
[6] Session End
 

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