root

Leader IT/Architect
Dec 31, 2012
1,153
72
48

Lab vpn site to site between Router and ASA


I. Mô hình và yêu cầu Lab vpn site to site between Router and ASA


1. Mô hình Lab vpn site to site between Router and ASA

Lab vpn site to site between Router and ASA(1)

2. Yêu cầu Lab vpn site to site between Router and ASA


- Cấu hình IPSEC-VPN giữa ASA và Router để PC trong inside của ASA có thể connect đến Pc trong LAN của Router
- Cấu hình NAT để PC vừa ra được internet vừa đi được VPN.
- Sơ đồ IP

Lab vpn site to site between Router and ASA(2)


II. Triển khai Lab vpn site to site between Router and ASA


1. Trên Router ISP
- Cấu hình IP, NAT để cho cty thuê dịch vụ ra internet

Code:
ISP(config)#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

SP(config)#access-list 1 permit any
ISP(config)#ip nat inside source list 1 interface f1/0

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 Router R2
- Cấu hình IP và trỏ default-route về ISP

Code:
R2(config)#int f0/0
R2(config-if)#ip address 152.2.2.2 255.255.255.0
R2(config-if)#no shutdown

R2(config-if)#int f0/1
R2(config-if)#ip address 10.2.2.2 255.255.255.0
R2(config-if)#no shutdown

R2(config)#ip route 0.0.0.0 0.0.0.0 152.2.2.254


3. Trên Cisco ASA

- Cấu hình IP và default route về ISP

Code:
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


III. Cấu hình Lab vpn site to site between Router and ASA


1. Cấu hình VPN trên ASA
- Các bạn cứ cấu hình tương tự các bài lab trước, quá đơn giản chỉ việc copy & paste :)
- Config VPN on Cisco ASA Phase 1:

Code:
ASA1(config)# crypto ikev1 policy 10
ASA1(config-ikev1-policy)# authentication pre-share
ASA1(config-ikev1-policy)# encryption 3des
ASA1(config-ikev1-policy)# hash md5
ASA1(config-ikev1-policy)# group 2
ASA1(config-ikev1-policy)# lifetime 86400


- Config VPN on Cisco ASA Pharse 2:
//Bước 1: Tạo Policy SVUIT

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

//Bước 2: ACL cho phép traffic nào được vào hầm

Code:
ASA2(config-if)# object network INSIDE-ASA
ASA2(config-network-object)# subnet 192.168.10.0 255.255.255.0
ASA2(config-network-object)# object network INSIDE-R2
ASA2(config-network-object)# subnet 10.2.2.0 255.255.255.0
ASA2(config-network-object)# exit

ASA1(config)# access-list VPN-TRAFFIC permit ip object INSIDE-ASA object INSIDE-R2

//Bước 3: cấu hình crypto map

Code:
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

//Bước 4: apply crypto map và IKEV1 vào interface

Code:
ASA1(config)# crypto map ASA-VPN interface outside
ASA1(config)# crypto ikev1 enable outside

// Bước 5: cấu hình tunnel-group

Code:
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 pre-shared-key svuit.com
ASA1(config-tunnel-ipsec)# exit

2. Cấu hình VPN trên Router R2
- Tương tự Router cũng chia làm 2 pharse
- Cấu hình VPN trên Router R2 pharse 1:

Code:
R2(config)#crypto isakmp policy 10
R2(config-isakmp)#authentication pre-share
R2(config-isakmp)#encryption 3des
R2(config-isakmp)#hash md5
R2(config-isakmp)#group 2
R2(config-isakmp)#lifetime 86400

- Pharse 2: Cấu hình IPSEC trên Router Cisco
  • Bước 1: Tạo policy SVUIT
Code:
R2(config)#crypto ipsec transform-set SVUIT esp-3des esp-md5-hmac

  • Bước 2: Tạo ACL quy định traffic được đi vào hầm :)
Code:
R2(config)#access-list 101 permit ip 10.2.2.0 0.0.0.255 any

  • Bước 3: Cấu hình crypto map
Code:
R2(config)#crypto map ASA-VPN 10 ipsec-isakmp
R2(config-crypto-map)#match address 101
R2(config-crypto-map)#set peer 151.1.1.1
R2(config-crypto-map)#set transform-set SVUIT

  • Bước 4: Apply crypto map vào interface
Code:
R2(config)#int f0/0
R2(config-if)#crypto map ASA-VPN

  • Bước 5: Đặt Pre-Sharekey
Code:
R2(config)#crypto isakmp key 0 svuit.com address 151.1.1.1

3. Kiểm tra
- PC trong inside ASA có thể truy cập đến PC trong LAN của Router thành công.

Lab vpn site to site between Router and ASA(3)

- Show crypto IKEV1 trên ASA
ASA(config)# 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


- Show crypto ISAKMP trên Router R2
R2#sh crypto isakmp sa
IPv4 Crypto ISAKMP SA
dst src state conn-id slot status
152.2.2.2 151.1.1.1 QM_IDLE 1001 0 ACTIVE

IPv6 Crypto ISAKMP SA
 
Last edited:
Lab vpn site to site between Router and ASA

IV. Cấu hình NAT trên Cisco ASA và Router R2


- Mặc dù các PC trong inside ASA và LAN của Router R2 đã ping được nhau vì có đường VPN. Nhưng chúng không ra được internet vì ASA vả Router chưa thực hiện NAT.
- Tuy nhiên, nếu bạn NAT theo cách thông thường thì sẽ gặp vấn đề là PC ra được internet và không đi VPN được nữa, đơn giản vì khi NAT nó sẽ cho toàn bộ inside ra internet. Nên đối với
  • Cisco ASA: Bạn phải thực hiện NAT exemption (có nghĩa là bypass NAT)
  • Router: ACL của bạn phải deny traffic VPN không được NAT
- Chém gió nãy giờ bây giờ sẽ vào công việc.

1. Trên Router
- Làm Router trước cho dễ
- Tạo 1 ACL cho phép NAT và không cho phép traffic VPN sử dụng NAT

Code:
R2(config)#ip access-list extended NAT

// Câu này sẽ deny các traffic từ trong LAN đi đến vùng inside của ASA (chính là traffic VPN).

Code:
R2(config)# deny ip any 192.168.10.0 0.0.0.255

// còn lại thì cho phép tất cả đều được NAT.

Code:
R2(config-ext-nacl)#permit ip any any


- Thực hiện NAT Overload cho Router

Code:
R2(config)#ip nat inside source list NAT interface f0/0 overload

R2(config)#int f0/0
R2(config-if)#ip nat outside
R2(config-if)#int f0/1
R2(config-if)#ip nat inside
R2(config-if)#end

- Test thử trên PC trong LAN của Router bạn sẽ nó vừa đi được internet vừa VPN được

Lab vpn site to site between Router and ASA(10)

2. Trên Cisco ASA

- ASA thì dùng NAT exemption để by pass nat cho phép PC trong inside đi VPN không cần NAT
- Cấu hình NAT Exemption trên ASA 8.4. Câu lệnh rất dễ nhớ, để by pass nat trên ASA bạn phải thực hiện NAT 2 lần (như kiểu 1+1=0 c/thức cộng của hệ nhị phân :)

Code:
ASA(config)#nat (inside,outside) source static INSIDE-ASA INSIDE-ASA destination static INSIDE-R2 INSIDE-R2


- Bước tiếp theo chúng ta thực hiện NAT như thông thường cho ASA. Mình sẽ thực hiện NÂT kiểu PAT cho ASA

Code:
ASA(config)# object network OUTSIDE
ASA(config-network-object)#subnet 0.0.0.0 0.0.0.0
ASA(config-network-object)#nat (inside,outside) dynamic interface

- Xong bây giờ bạn dùng PC truy cập internet và đi VPN thành công.

Lab vpn site to site between Router and ASA(11)
 
Last edited:
Anh cho em hỏi là hình như bài của anh thiếu câu lệnh "crypto isakmp enable outside" ở pharse 1 của ASA phải ko anh ? với "152.2.2.2" trong 2 câu lệnh
Code:
ASA1(config)# tunnel-group 152.2.2.2 type ipsec-l2l
ASA1(config)# tunnel-group 152.2.2.2 ipsec-attributes
là sao vậy anh ?
 
Last edited by a moderator:
Anh cho em hỏi là hình như bài của anh thiếu câu lệnh "crypto isakmp enable outside" ở pharse 1 của ASA phải ko anh ?

bạn đọc kỹ lại nhé mình có viết ở đây.

Code:
//Bước 4: apply crypto map và IKEV1 vào interface
ASA1(config)# crypto map ASA-VPN interface outside
ASA1(config)# crypto ikev1 enable outside

Code:
với "152.2.2.2" trong 2 câu lệnh "ASA1(config)# tunnel-group 152.2.2.2 type ipsec-l2l" và "ASA1(config)# tunnel-group 152.2.2.2 ipsec-attributes" là sao vậy anh ?

Ở đây bạn khai bạn cái đầu VPN của ASA bên kia ( peer to peer ấy bạn)

Code:
ASA1(config)# tunnel-group 152.2.2.2 type ipsec-l2l
.
Là khai báo VPN này dùng site-to-site và ASA này sẽ tạo 1 đường VPN với ASA có IP 152.2.2.2

Code:
ASA1(config)# tunnel-group 152.2.2.2 ipsec-attributes
Bạn sẽ khai báo thuộc tính của đường hầm VPN mà bạn đã cấu hình ở trên.
 
Last edited:
em có cấu hình con ASA và router giống với bài của anh nhưng tới khúc 3. em show crypto ikev1 sa trên ASA thì nó báo "There are no IKEv1 SAs" :(. Anh kiểm tra giúp em cấu hình với. Từ ASA em ping được tới cổng router và ngược lại nên em nghĩ ISP bình thường. Đây là cấu hình của em.

ASA:
ASA Version 8.4(2)
!
hostname ciscoasa
enable password 8Ry2YjIyt7RRXU24 encrypted
passwd 2KFQnbNIdI.2KYOU encrypted
names
!
interface GigabitEthernet0
nameif outside
security-level 0
ip address 151.1.1.1 255.255.255.0
!
interface GigabitEthernet1
nameif inside
security-level 100
ip address 192.168.10.1 255.255.255.0
!
interface GigabitEthernet2
shutdown
no nameif
no security-level
no ip address
!
interface GigabitEthernet3
shutdown
no nameif
no security-level
no ip address
!
interface GigabitEthernet4
shutdown
no nameif
no security-level
no ip address
!
interface GigabitEthernet5
shutdown
no nameif
no security-level
no ip address
!
ftp mode passive
object network INSIDE-ASA
subnet 192.168.10.0 255.255.255.0
object network INSIDE-R2
subnet 10.2.2.0 255.255.255.0
access-list VPN-TRAFFIC extended permit ip object INSIDE-ASA object INSIDE-R2
pager lines 24
mtu outside 1500
mtu inside 1500
no failover
icmp unreachable rate-limit 1 burst-size 1
no asdm history enable
arp timeout 14400
route outside 0.0.0.0 0.0.0.0 151.1.1.254 1
timeout xlate 3:00:00
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
timeout tcp-proxy-reassembly 0:01:00
timeout floating-conn 0:00:00
dynamic-access-policy-record DfltAccessPolicy
user-identity default-domain LOCAL
no snmp-server location
no snmp-server contact
snmp-server enable traps snmp authentication linkup linkdown coldstart warmstart
crypto ipsec ikev1 transform-set SVUIT esp-3des esp-md5-hmac
crypto map ASA-VPN 10 match address VPN-TRAFFIC
crypto map ASA-VPN 10 set peer 152.2.2.2
crypto map ASA-VPN 10 set ikev1 transform-set SVUIT
crypto ikev1 policy 10
authentication pre-share
encryption 3des
hash md5
group 2
lifetime 86400
telnet timeout 5
ssh timeout 5
console timeout 0
threat-detection basic-threat
threat-detection statistics access-list
no threat-detection statistics tcp-intercept
tunnel-group 152.2.2.2 type ipsec-l2l
tunnel-group 152.2.2.2 ipsec-attributes
ikev1 pre-shared-key *****
!
!
prompt hostname context
no call-home reporting anonymous
call-home
profile CiscoTAC-1
no active
destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService
destination address email callhome@cisco.com
destination transport-method http
subscribe-to-alert-group diagnostic
subscribe-to-alert-group environment
subscribe-to-alert-group inventory periodic monthly
subscribe-to-alert-group configuration periodic monthly
subscribe-to-alert-group telemetry periodic daily
crashinfo save disable
Cryptochecksum:47cbb99593e09d1159d76b2e50b658bd
: end


router:
Building configuration...

Current configuration : 1358 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
no ip icmp rate-limit unreachable
ip cef
!
!
!
!
no ip domain lookup
ip auth-proxy max-nodata-conns 3
ip admission max-nodata-conns 3
!
multilink bundle-name authenticated
!
!
!
archive
log config
hidekeys
!
!
crypto isakmp policy 10
encr 3des
hash md5
authentication pre-share
group 2
crypto isakmp key svuit.com address 151.1.1.1
!
!
crypto ipsec transform-set SVUIT esp-3des esp-md5-hmac
!
crypto map ASA-VPN 10 ipsec-isakmp
set peer 151.1.1.1
set transform-set SVUIT
match address 101
!
!
!
ip tcp synwait-time 5
!
!
interface FastEthernet0/0
ip address 152.2.2.2 255.255.255.0
duplex auto
speed auto
crypto map ASA-VPN
!
interface FastEthernet0/1
ip address 10.2.2.2 255.255.255.0
duplex auto
speed auto
!
ip forward-protocol nd
ip route 0.0.0.0 0.0.0.0 152.2.2.254
!
!
no ip http server
no ip http secure-server
!
access-list 101 permit ip 10.2.2.0 0.0.0.255 any
!
!
control-plane
!
!
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous
line aux 0
exec-timeout 0 0
privilege level 15
logging synchronous
line vty 0 4
login
!
!
end
 
Last edited by a moderator:
hi huy8114644 ,

Lần sau bạn nên dùng thẻ
HTML:
[CODE] hoặc [QUOTE]
để người khác sửa nhìn vào nó dễ dàng hơn nhé. Chút góp ý của mình


Cấu hình ASA
Code:
interface GigabitEthernet0
nameif outside
security-level 0
ip address 151.1.1.1 255.255.255.0
!
interface GigabitEthernet1
nameif inside
security-level 100
ip address 192.168.10.1 255.255.255.0
!

object network INSIDE-ASA
subnet 192.168.10.0 255.255.255.0
object network INSIDE-R2
subnet 10.2.2.0 255.255.255.0
access-list VPN-TRAFFIC extended permit ip object INSIDE-ASA object INSIDE-R2

route outside 0.0.0.0 0.0.0.0 151.1.1.254 1

crypto ipsec ikev1 transform-set SVUIT esp-3des esp-md5-hmac
crypto map ASA-VPN 10 match address VPN-TRAFFIC
crypto map ASA-VPN 10 set peer 152.2.2.2
crypto map ASA-VPN 10 set ikev1 transform-set SVUIT
crypto ikev1 policy 10
authentication pre-share
encryption 3des
hash md5
group 2
lifetime 86400

tunnel-group 152.2.2.2 type ipsec-l2l
tunnel-group 152.2.2.2 ipsec-attributes
ikev1 pre-shared-key *****


Router

Code:
crypto isakmp policy 10
encr 3des
hash md5
authentication pre-share
group 2
crypto isakmp key svuit.com address 151.1.1.1
!
!
crypto ipsec transform-set SVUIT esp-3des esp-md5-hmac
!
crypto map ASA-VPN 10 ipsec-isakmp
set peer 151.1.1.1
set transform-set SVUIT
match address 101

interface FastEthernet0/0
ip address 152.2.2.2 255.255.255.0
duplex auto
speed auto
crypto map ASA-VPN
!
interface FastEthernet0/1
ip address 10.2.2.2 255.255.255.0
duplex auto
speed auto
!
ip forward-protocol nd
ip route 0.0.0.0 0.0.0.0 152.2.2.254

access-list 101 permit ip 10.2.2.0 0.0.0.255 any
 
Last edited:
Bạn thử dùng PC trong LAN ping tới ISP thử, sau đó ping tới PC trong LAN bên kia xem ok không. Trong lúc ping thì bật debug crypto lên
 
thanks anh root... em làm được rồi... 2 con ASA phải cho gói tin icmp đi qua, 2 PC phải trỏ default gateway về ASA, còn 1 điều lạ là, từ PC bên này phải ping qua PC bên kia thì VPN nó mới bắt đầu được kích hoạt ( đèn VPN trên ASA bắt đầu sáng).
 
hi huy8114644,

thanks anh root... em làm được rồi... 2 con ASA phải cho gói tin icmp đi qua, 2 PC phải trỏ default gateway về ASA, còn 1 điều lạ là, từ PC bên này phải ping qua PC bên kia thì VPN nó mới bắt đầu được kích hoạt ( đèn VPN trên ASA bắt đầu sáng).

Nếu không có gói tin nào chạy thì làm gì có đường hầm hả bạn, khi có traffic chạy qua nó sẽ thiết lập 1 đường hầm. KHi quá trình trao đổi kết thúc sẽ đóng đường hầm. Đó là lý thuyết
 
Last edited:

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