Menu

1/26/19

VPN site to site (IPsec)

Từ mô hình thực tế, ta xây dựng đồ hình lab sau trên GNS3.



Cấu hình VPN rất đơn giản qua 2 pha,

Pha 1:  Configure ISAKMP (ISAKMP Phase 1)
Pha 2: Configure IPSec  (ISAKMP Phase 2, ACLs, Crypto MAP)

Trải qua 5 bước thiết lập,




Bước 1: Host A ping 1 traffic sang host B
Bước 2: Hai router đàm phán thiết lâp IKE pha 1
Bước 3:Tiếp tục đàm phán thiết lâp IKE pha 2
Bước 4: Trao đổi thông tin thông qua đường hầm IPSEC.
Bước 5: Kết thúc quá trình trao đổi và chấm dứt tunnel IPSEC

Các thiết lệnh thiết lập căn bản ban đầu,

-Trên PC1,

PC-1> ip 10.10.10.2/24 10.10.10.1

-Trên PC2,

PC-2> ip 20.20.20.2/24 20.20.20.1


-Trên Router R1,

 --------------------Default gate của LAN.

R1(config)#int f0/1
R1(config-if)#ip add 10.10.10.2 255.255.255.0
R1(config-if)#no shut


-------------------IP public ta thuê từ ISP (1.1.1.1)

R1(config-if)#int f0/0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#no shut


-Trên Router R2,

--------------------Default gate của LAN.

R2(config)#int f0/1
R2(config-if)#ip add 20.20.20.2 255.255.255.0
R2(config-if)#no shut


 -------------------IP public ta thuê từ ISP (1.1.1.2)

R2(config-if)#int f0/0
R2(config-if)#ip add 1.1.1.2 255.255.255.0
R2(config-if)#no shut


Cấu hình các thông số đàm phán Phase 1 cho 2 router,
  • Kiểu mã hóa
  • Thuật toán băm MD5 để xác thực
  • Kiểu xác thực
  • Group DH sử dụng để trao đổi khóa
  • Lifetime: Quy đinh thời gian sống của đường hầm
Trên Router R1,

R1(config)#  crypto isakmp policy 1
R1(config-isakmp)# encr 3des

R1(config-isakmp)# hash md5

R1(config-isakmp)# authentication pre-share

R1(config-isakmp)# group 2

R1(config-isakmp)# lifetime 86400 
Trên Router R2,

R2(config)# crypto isakmp policy 1

R2(config-isakmp)# encr 3des

R2(config-isakmp)# hash md5

R2(config-isakmp)# authentication pre-share

R2(config-isakmp)# group 2
R2(config-isakmp)# lifetime 86400
 Xác định thông tin key và peer.
Trên R1,

R1(config)# crypto isakmp key firewallcx address 1.1.1.2
Trên R2,
R2(config)# crypto isakmp key firewallcx address 1.1.1.1
Tạo ACL cho 2 chi nhánh tham gia VPN.
Trên R1,
R1(config)# ip access-list extended VPN-TRAFFIC
R1(config-ext-nacl)# permit ip 10.10.10.0 0.0.0.255 20.20.20.0 0.0.0.255

 Trên R2,


R2(config)# ip access-list extended VPN-TRAFFIC

R2(config-ext-nacl)# permit ip 20.20.20.0 0.0.0.255 10.10.10.0 0.0.0.255
-Cấu hình thông số cho Phase 2  cho 2 router,
 -Tạo IP set transform
 R1(config)# crypto ipsec transform-set TS esp-3des esp-md5-hmac
 R2(config)# crypto ipsec transform-set TS esp-3des esp-md5-hmac

-Tạo cryto map 
Trên  R1,

R1(config)# crypto map CMAP 10 ipsec-isakmp

R1(config-crypto-map)# set peer 1.1.1.2

R1(config-crypto-map)# set transform-set TS

R1(config-crypto-map)# match address VPN-TRAFFIC
 Trên R2,


R2(config)# crypto map CMAP 10 ipsec-isakmp

R2(config-crypto-map)# set peer 1.1.1.1

R2(config-crypto-map)# set transform-set TS
R2(config-crypto-map)# match address VPN-TRAFFIC
Gán cryto map lên interface của ip public
Trên R1,
R1(config)# interface FastEthernet0/0

R1(config- if)# crypto map CMAP
Trên R2,
 R2(config)# interface FastEthernet0/0

R2(config- if)# crypto map CMAP
Để PC từ các chi nhánh có thể ping thấy nhau ta cầu static router,
R1(config)# ip route 0.0.0.0 0.0.0.0 FastEthernet0/0
R2(config)# ip route 0.0.0.0 0.0.0.0 FastEthernet0/0

 Tiến hành thiết lập kết nối, từ PC1 ta thực hiện ping sang PC2.

PC-1> ping 20.20.20.2
20.20.20.2 icmp_seq=1 timeout
20.20.20.2 icmp_seq=2 timeout
84 bytes from 20.20.20.2 icmp_seq=3 ttl=62 time=28.005 ms
84 bytes from 20.20.20.2 icmp_seq=4 ttl=62 time=28.030 ms
84 bytes from 20.20.20.2 icmp_seq=5 ttl=62 time=28.076 ms
Kết quả show các lệnh VPN trên các Router


Xem thiết lập kết nối.
 
R1#sh crypto session

Crypto session current status

Interface: FastEthernet0/0
Session status: UP-ACTIVE
Peer: 1.1.1.2 port 500
  IKE SA: local 1.1.1.1/500 remote 1.1.1.2/500 Active
  IPSEC FLOW: permit ip 10.10.10.0/255.255.255.0 20.20.20.0/255.255.255.0
        Active SAs: 2, origin: crypto map
R1#sh crypto isakmp sa
 
IPv4 Crypto ISAKMP SA
dst             src             state          conn-id slot status
1.1.1.2         1.1.1.1         QM_IDLE           1001    0 ACTIVE

IPv6 Crypto ISAKMP SA
 R2#sh crypto session

Crypto session current status

Interface: FastEthernet0/0
Session status: UP-ACTIVE
Peer: 1.1.1.1 port 500
  IKE SA: local 1.1.1.2/500 remote 1.1.1.1/500 Active
  IPSEC FLOW: permit ip 20.20.20.0/255.255.255.0 10.10.10.0/255.255.255.0
        Active SAs: 2, origin: crypto map

R2#sh crypto isakmp sa
 
IPv4 Crypto ISAKMP SA
dst             src             state          conn-id slot status
1.1.1.2         1.1.1.1         QM_IDLE           1001    0 ACTIVE

IPv6 Crypto ISAKMP SA
 


Xem các gói tin đóng gói mã hóa và giải mã,
R1#sh crypto ipsec sa

interface: FastEthernet0/0
    Crypto map tag: CMAP, local addr 1.1.1.1

   protected vrf: (none)
   local  ident (addr/mask/prot/port): (10.10.10.0/255.255.255.0/0/0)
   remote ident (addr/mask/prot/port): (20.20.20.0/255.255.255.0/0/0)
   current_peer 1.1.1.2 port 500
     PERMIT, flags={origin_is_acl,}
    #pkts encaps: 20, #pkts encrypt: 20, #pkts digest: 20
    #pkts decaps: 22, #pkts decrypt: 22, #pkts verify: 22
 Kết thúc bài lab

--------- ĐÂU CHỈ CÓ THẾ?

Trên thực tế ta thường triển khai công nghệ VPN cùng với PPPOE tức là người dùng trong LAN vừa muốn truy cập internet vừa truy cập VPN phía chi nhánh khác. Vậy phải làm sau đây?

Thông thường ta thường cấu hình ACL để NAT overload phục vụ việc quay số PPPOE như sau:

R1(config)# ip nat inside source list 100 interface fastethernet0/0 overload
R1(config)# access-list 100 permit ip 10.10.10.0 0.0.0.255 any
R1(config)# access-list 100 remark
Nếu như vậy, từ host A khi ping đén host 20.20.20.2 (PC2 đầu xa) thì phương thức NAT overload vẫn được thực thi 1 cách vô nghĩa, ta hãy phân luồn traffic ACL như sau
--Dùng cho VPN
--Dùng cho quay số PPPOE 

===> Chỉ NAT overload cho packets nào ra internet, deny (không NAT overload) packets nào đến VPN đầu xa.


 

R1(config)# access-list 100 remark -=[Define NAT Service]=-
R1(config)# access-list 100 deny ip 10.10.10.0 0.0.0.255 20.20.20.0 0.0.0.255 //không thực thi NAT overload
R1(config)# access-list 100 permit ip 10.10.10.0 0.0.0.255 any //ra internet luôn thực thi NAT overload
R1(config)# access-list 100 remark_--[END]
R1(config)# ip nat inside source list 100 interface fastethernet0/1 overload

No comments:

Post a Comment