You are on page 1of 6

IPSec VPN Site-to-Site

I. Mô tả:
Thực hiện IPSec VPN giữa hai site, đảm bảo mạng Lan thuộc hai site có thể giao tiếp được với
nhau.
II. Cấu hình
B1: Cấu hình chính sách IKE (chính sách pha 1)

SAIGON(config)#crypto isakmp policy 10


SAIGON(config-isakmp)#hash md5
SAIGON(config-isakmp)#encryption des
SAIGON(config-isakmp)#group 2
SAIGON(config-isakmp)#authentication pre-share

B2: Xác định thông tin key và peer


SAIGON(config)#crypto isakmp key 0 vnpro123 address 151.1.1.1

B3:Cấu hình chính sách IPSec (chính sách pha 2)


SAIGON(config)#crypto ipsec transform-set MYSET esp-md5-hmac esp-des

B4: Xác định “traffic” sẽ được mã hóa hay được bảo vệ


SAIGON(config)#access-list 100 permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255

B5: Cấu hình Crypto map


SAIGON(config)#crypto map MYMAP 10 ipsec-isakmp
% NOTE: This new crypto map will remain disabled until a peer
and a valid access list have been configured.
SAIGON(config-crypto-map)#set peer 151.1.1.1
SAIGON(config-crypto-map)#set transform-set MYSET
SAIGON(config-crypto-map)#match address 100

B6: Cấu hình crypto map lên cổng


SAIGON(config)#interface s1/0
SAIGON(config-if)#crypto map MYMAP

Các bước làm tương tự trên VUNGTAU


III. Cấu hình đầy đủ:

SAIGON#sh run
Building configuration...

Current configuration : 1644 bytes


!
hostname SAIGON
!
no aaa new-model
ip cef
!
crypto isakmp policy 10
hash md5
authentication pre-share
group 2
crypto isakmp key vnpro123 address 151.1.1.1
!
!
crypto ipsec transform-set MYSET esp-des esp-md5-hmac
!
crypto map MYMAP 10 ipsec-isakmp
set peer 151.1.1.1
set transform-set MYSET
match address 100
!
interface Loopback0
ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex half
!
interface Serial1/0
ip address 150.1.1.1 255.255.255.0
no fair-queue
serial restart-delay 0
clock rate 64000
crypto map MYMAP
!

!
ip route 0.0.0.0 0.0.0.0 150.1.1.2
access-list 100 permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
!
!
end

SAIGON#

VUNGTAU#sh run
Building configuration...

Current configuration : 1632 bytes


hostname VUNGTAU
!
!
no aaa new-model
ip cef
!

crypto isakmp policy 10


hash md5
authentication pre-share
group 2
crypto isakmp key vnpro123 address 150.1.1.1
!
!
crypto ipsec transform-set MYSET esp-des esp-md5-hmac
!
crypto map MYMAP 10 ipsec-isakmp
set peer 150.1.1.1
set transform-set MYSET
match address 100
!

interface Loopback0
ip address 192.168.2.1 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex half
!
interface Serial1/0
ip address 151.1.1.1 255.255.255.0
serial restart-delay 0
clock rate 64000
crypto map MYMAP
!
ip route 0.0.0.0 0.0.0.0 151.1.1.2
no ip http server
no ip http secure-server
!
!
access-list 100 permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255
!
end

VUNGTAU#

ISP#sh run
Building configuration...
Current configuration : 1020 bytes
!
hostname ISP
!
!
no aaa new-model
ip subnet-zero
!
!interface Serial0/0
ip address 150.1.1.2 255.255.255.0
clockrate 2000000
!
interface Serial0/1
ip address 151.1.1.2 255.255.255.0
clockrate 2000000
!
!
ip classless
ISP#
IV. Kiểm tra:
Kích hoạt tunnel dựa vào traffic được xác định trên acl 100.
SAIGON#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 = 80/118/176 ms

Sau khi tunnel được thiết lập có thể kiểm tra thông tin vế pha 1 và pha 2

Trạng thái ISAKMP SA


SAIGON#sh crypto isakmp sa
IPv4 Crypto ISAKMP SA
dst src state conn-id slot status
151.1.1.1 150.1.1.1 QM_IDLE 1001 0 ACTIVE

IPv6 Crypto ISAKMP SA

Trạng thái IPSEC SA


SAIGON#sh crypto ipsec sa

interface: Serial1/0
Crypto map tag: MYMAP, local addr 150.1.1.1

protected vrf: (none)


local ident (addr/mask/prot/port): (192.168.1.0/255.255.255.0/0/0)
remote ident (addr/mask/prot/port): (192.168.2.0/255.255.255.0/0/0)
current_peer 151.1.1.1 port 500
PERMIT, flags={origin_is_acl,}
#pkts encaps: 9, #pkts encrypt: 9, #pkts digest: 9 => Gói được mã hóa
#pkts decaps: 9, #pkts decrypt: 9, #pkts verify: 9 => Gói được giải mã
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 1, #recv errors 0

local crypto endpt.: 150.1.1.1, remote crypto endpt.: 151.1.1.1


path mtu 1500, ip mtu 1500, ip mtu idb Serial1/0
current outbound spi: 0x1A166DE8(437677544)

inbound esp sas: => SA sử dụng cho gói đi vào


spi: 0x7507C194(1963442580) =>Tương ứng với outbound của peer
transform: esp-des esp-md5-hmac ,
in use settings ={Tunnel, }
conn id: 1, flow_id: SW:1, crypto map: MYMAP
sa timing: remaining key lifetime (k/sec): (4569737/3545)
IV size: 8 bytes
replay detection support: Y
Status: ACTIVE

inbound ah sas:

inbound pcp sas:

outbound esp sas: =>SA sử dụng cho gói đi ra


spi: 0x1A166DE8(437677544) =>Tươmg ứng với inbound của peer
transform: esp-des esp-md5-hmac ,
in use settings ={Tunnel, }
conn id: 2, flow_id: SW:2, crypto map: MYMAP
sa timing: remaining key lifetime (k/sec): (4569737/3544)
IV size: 8 bytes
replay detection support: Y
Status: ACTIVE

outbound ah sas:

outbound pcp sas:

SAIGON#sh crypto session detail


Crypto session current status

Code: C - IKE Configuration mode, D - Dead Peer Detection


K - Keepalives, N - NAT-traversal, X - IKE Extended Authentication

Interface: Serial1/0
Uptime: 00:01:46
Session status: UP-ACTIVE =>Trạng thái của session
Peer: 151.1.1.1 port 500 fvrf: (none) ivrf: (none)
Phase1_id: 151.1.1.1
Desc: (none)
IKE SA: local 150.1.1.1/500 remote 151.1.1.1/500 Active
Capabilities:(none) connid:1001 lifetime:23:58:13
IPSEC FLOW: permit ip 192.168.1.0/255.255.255.0 192.168.2.0/255.255.255.0 =>Dữ liệu
được bảo vệ
Active SAs: 2, origin: crypto map
Inbound: #pkts dec'ed 9 drop 0 life (KB/Sec) 4569737/3493
Outbound: #pkts enc'ed 9 drop 1 life (KB/Sec) 4569737/3493

Số lượng kết nối được mở ( 1 cho IKE và 2 cho IPSec)


SAIGON#sh crypto engine connections active
Crypto Engine Connections

ID Interface Type Algorithm Encrypt Decrypt IP-Address


1 Se1/0 IPsec DES+MD5 0 9 150.1.1.1
2 Se1/0 IPsec DES+MD5 9 0 150.1.1.1
1001 Se1/0 IKE MD5+DES 0 0 150.1.1.1

Có thể xóa kết nối với dòng lệnh:

Debug cryto ipsec


Debug crypt sa

Clear ???
SAIGON#clear crypto session

SAIGON#sh crypto isakmp sa


IPv4 Crypto ISAKMP SA
dst src state conn-id slot status
151.1.1.1 150.1.1.1 MM_NO_STATE 1001 0 ACTIVE (deleted)

Trong quá trình cấu hình, có thể dùng câu lệnh debug crypto isakmp để kiểm tra tiến trình thiết
lập.

You might also like