40
ISCW Chương trình đạo tạo mạng chuyên nghiệp ProNet TÀI LIỆU CẤU HÌNH IPSEC VPN I) Các bước cấu hình Site-to-Site VPN: 1) Cấu hình chính sách ISAKMP/IKE pha 1: a) Enable ISAKMP (mặc định là đã enable): Router(config)# [no] crypto isakmp enable b) Tạo chính sách cho pha 1: Mặc định có sẵn một chính sách mặc định nhưng ta có thể tạo thêm: Router(config)# crypto isakmp policy priority (priority càng nhỏ càng ưu tiên) Router(config-isakmp)# encryption {des | 3des | aes} Router(config-isakmp)# hash {sha | md5} Router(config-isakmp)# authentication {rsa-sig | rsa-encr | pre-share} Router(config-isakmp)# group {1 | 2 | 5} Router(config-isakmp)# lifetime seconds Router(config-isakmp)# exit Đối với các thiết bị cisco, lifetime có thể cấu hình khác nhau ở các peer, trong quá trình thiết lập pha 1, các peer sẽ chọn cho mình lifetime nhỏ hơn. Để xem các chính sách ISAKMP hiện có, dùng lệnh: show crypto isakmp policy Router# show crypto isakmp policy Global IKE policy Protection suite of priority 10 encryption algorithm: AES - Advanced Encryption Standard (128 bit keys). hash algorithm: Message Digest 5 authentication method: Pre-Shared Key Diffie-Hellman group: #2 (1024 bit) lifetime: 86400 seconds, no volume limit Default protection suite encryption algorithm: DES - Data Encryption Standard (56 bit keys). hash algorithm: Secure Hash Standard authentication method: Rivest-Shamir-Adleman Signature Diffie-Hellman group: #1 (768 bit) lifetime: 86400 seconds, no volume limit Mặc định thì có sẵn 1 chính sách mặc định như sau: Encryption algorithm: DES HMAC function: SHA-1 Authentication method: RSA signatures (certificates) DH group: 1 Lifetime: 86,400 seconds Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 1

22089395 Cau Hinh IPSec

Embed Size (px)

Citation preview

Page 1: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

TÀI LIỆU CẤU HÌNH IPSEC VPN

I) Các bước cấu hình Site-to-Site VPN:

1) Cấu hình chính sách ISAKMP/IKE pha 1:

a) Enable ISAKMP (mặc định là đã enable):

Router(config)# [no] crypto isakmp enable

b) Tạo chính sách cho pha 1:

Mặc định có sẵn một chính sách mặc định nhưng ta có thể tạo thêm:

Router(config)# crypto isakmp policy priority (priority càng nhỏ càng ưu tiên)Router(config-isakmp)# encryption {des | 3des | aes}Router(config-isakmp)# hash {sha | md5}Router(config-isakmp)# authentication {rsa-sig | rsa-encr | pre-share}Router(config-isakmp)# group {1 | 2 | 5}Router(config-isakmp)# lifetime secondsRouter(config-isakmp)# exit

Đối với các thiết bị cisco, lifetime có thể cấu hình khác nhau ở các peer, trong quá trình thiết lập pha 1, các peer sẽ chọn cho mình lifetime nhỏ hơn.

Để xem các chính sách ISAKMP hiện có, dùng lệnh:

show crypto isakmp policy

Router# show crypto isakmp policyGlobal IKE policyProtection suite of priority 10 encryption algorithm: AES - Advanced Encryption Standard (128 bit keys). hash algorithm: Message Digest 5 authentication method: Pre-Shared Key Diffie-Hellman group: #2 (1024 bit) lifetime: 86400 seconds, no volume limitDefault protection suite encryption algorithm: DES - Data Encryption Standard (56 bit keys). hash algorithm: Secure Hash Standard authentication method: Rivest-Shamir-Adleman Signature Diffie-Hellman group: #1 (768 bit) lifetime: 86400 seconds, no volume limit

Mặc định thì có sẵn 1 chính sách mặc định như sau:

• Encryption algorithm: DES• HMAC function: SHA-1• Authentication method: RSA signatures (certificates)• DH group: 1• Lifetime: 86,400 seconds

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 1

Page 2: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

Cấu hình để lấy sẵn các thuộc tính của chính sách mặc định:

Router(config-isakmp)# default {encryption | hash | authentication | group | lifetime}

Cấu hình cơ chế DPD:

Router(config)# crypto isakmp keepalive seconds [retries] [periodic | on-demand]

Lệnh debug ở pha 1:

Router(config)# debug crypto isakmp

c) Cấu hình chứng thực ở pha 1:

Có 2 kiểu chứng thực:

• Dùng địa chỉ IP cho các peer.

• Sử dụng hostname.

Cấu hình cho biết sử dụng kiểu chứng thực nào:

Router(config)# crypto isakmp identity {address | hostname}

Kiểu chứng thực phải đồng nhất trên các peer:

Nếu dùng “kiểu hostname” thì khi đó địa chỉ tương ứng với hostname được truy vấn tĩnh hoặc thông qua DNS Server.

Cấu hình tĩnh cho hostname:

Router(config)# ip host hostname address1 [address2...address8](tối đa 8 địa chỉ IP mỗi hostname)

Có 3 phương thức chứng thực:

• Pre-shared keys.

• RSA encrypted nonces.

• RSA signatures (digital certificates).

(i) Pre-shared keys:

Đây là phương thức đơn giản nhất, cấu hình dùng lệnh:

Router(config)# crypto isakmp {0 | 6} key <khóa> address <địa chỉ IP> [subnet_mask] [no-xauth]Router(config)# crypto isakmp {0 | 6} key <khóa> hostname peer_hostname [no-xauth]

Số ‘0’ cho biết chuỗi khóa chưa được mã hóa, ngược lại là số ‘6’.

Nếu muốn tất cả các peer đều dùng chung 1 khóa thì dùng câu lệnh bên dưới. Tuy nhiên, điều này không nên vì chỉ cần 1 peer bị đánh cắp khóa là tất cả các peer còn lại đều bị lộ khóa. Tốt nhất là mỗi peer một khóa khác nhau (nhiều quá thì hơi khó nhớ nhưng … an toàn là chính :D).

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 2

Page 3: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

Router(config)# crypto isakmp 0 key <khóa> address 0.0.0.0 0.0.0.0

Bảo vệ các Pre-Shared Key:

Router(config)# key config-key password-encryptNew key: <nhập khóa>Confirm key: <nhập khóa>Router(config)# password encryption aes

Khi đã bảo vệ theo cách trên thì khi dùng lệnh kiểm tra khóa sẽ không thấy được nội dung khóa:

Router# show crypto isakmp keyKeyring Hostname/Address Preshared Keydefault 192.1.1.1 (encrypted)

Muốn xóa chức năng bảo vệ khóa thì dùng lệnh:

no key config-key password-encrypt

Tuy nhiên, các khóa đã được mã hóa sẽ không tự giải mã ngược lại mà chúng ta phải gỏ lại lệnh.

(ii) RSA encrypted nonces:

Mã hóa khóa đồng bộ bằng khóa bất đồng bộ.

Các tiến trình con gồm:

• Tạo ra cặp khóa.

• Chia sẽ khóa công khai.

• Tạo ra cặp khóa:

Router(config)# hostname <hostname>Router(config)# ip domain-name <tên miền>

2 câu lệnh đầu là bắt buộc vì các tham số được nhập vào sau đó sẽ được sử dụng như tham số đầu vào cho thuật toán tạo khóa ở câu lệnh thứ 3. Lưu ý: hostname không được gỏ mặc định “Router”.

Router(config)# crypto key generate rsa [general-keys | usage-keys]

• general-keys (mặc định): tạo ra 1 cặp khóa chung cho chữ kí số và mã hóa.

• usage-keys: tạo 2 cặp khóa riêng biệt cho chữ kí số và mã hóa.

Cấu hình minh họa:

Router(config)# hostname pronetpronet (config)# ip domain-name cisco.compronet(config)# crypto key generate rsaThe name for the keys will be: r3640.cisco.comChoose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes.

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 3

Page 4: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

How many bits in the modulus [512]: 2048% Generating 2048 bit RSA keys ...[OK]pronet(config)#

Câu lệnh kiểm tra:

show crypto key mypubkey rsa

pronet# show crypto key mypubkey rsa% Key pair was generated at: 06:13:07 UTC Mar 1 2002Key name: pronet.cisco.com Usage: General Purpose Key Key is not exportable. Key Data: 30820122 300D0609 2A864886 F70D0101 01050003 82010F00 3082010A<bỏ qua 1 phần> 23CA4ACE 63F1D296 1B020301 0001% Key pair was generated at: 06:13:10 UTC Mar 1 2005Key name: pronet.cisco.com.server Usage: Encryption Key Key is not exportable. Key Data: 307C300D 06092A86 4886F70D 01010105 00036B00 30680261 00BFB7C0<bỏ qua 1 phần> BAE69169 713DCF99 B1020301 0001

Ta có thể tạo nhiều cặp khóa trên cùng 1 router cho các peer khác nhau. Khi đó chúng sẽ được phân biệt bởi một nhãn duy nhất khi cấu hình, nếu không cấu hình rõ ràng nhãn thì FQDN sẽ được sử dụng làm nhãn.

Router(config)# crypto key generate rsa [general-keys | usage-keys] key_pair_label

• Chia sẽ khóa công khai:

Router(config)# crypto key pubkey-chain rsa

Router(config-pubkey-c)# named-key peer_name [encryption | signature](dùng cho trường hợp chứng thực sử dụng hostname) HoặcRouter(config-pubkey-c)# addressed-key peer_IP_address [encryption | signature](dùng cho trường hợp chứng thực sử dụng địa chỉ IP của peer)

Router(config-pubkey-k)# key-string key_string !(key_string ở dạng Hecxa)Router(config-pubkey-k)# quit

Ghi chú: Đối với một số IOS thì cấu hình key-string có khác đôi chút:

Router(config-pubkey-k)# key-stringRouter(config-pubkey)# key_string !(nhập key_string ở dạng Hecxa)Router(config-pubkey)# quit

Kiểm tra:

Router# show crypto key pubkey-chain rsa {name peer_name | address peer_IP_address}

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 4

Page 5: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

Nếu không chỉ rỏ 1 trong 2 tham số tùy chọn phía sau câu lệnh thì khi show lên không thấy được khóa công khai của peer.

pronet# show crypto key pubkey-chain rsaCodes: M - Manually configured, C - Extracted from certificate

Code Usage IP-Address/VRF Keyring NameM General 192.1.1.1 default

pronet# show crypto key pubkey-chain rsa address 192.1.1.1Key address: 192.1.1.1 Usage: General Purpose Key Source: Manually entered Data: 30820122 300D0609 2A864886 F70D0101 01050003 82010F00 3082010A<bỏ qua 1 phần> 23CA4ACE 63F1D296 1B020301 0001

Xóa khóa công khai peer:

pronet(config)# crypto key pubkey-chain rsapronet(config-pubkey-chain)# no addressed-key 192.1.1.1

hoặc

pronet(config-pubkey-chain)# no named-key hocvienProNet

Xóa cặp khóa trên router cục bộ:

Router(config)# crypto key zeroize rsa [key_pair_label]Nếu không có tham số nhãn thì câu lệnh trên sẽ xóa tất cả các cặp khóa trên router.

(iii) RSA signatures (digital certificates):

Chữ kí số không được chia sẽ trước. Để đảm bảo bảo mật cho chữ kí số. CA được sử dụng để xác định tính hợp lệ của khóa công khai.Có 2 cách chính để lấy certificate (chứng chỉ) từ CA: lấy thủ công và sử dụng giao thức SCEP (Simple Certificate Enrollment Protocol).

Lấy certificate dùng SCEP:

• Cấu hình Router Cisco làm CA:

Có nhiều bước thực hiện, tuy vậy bài viết này chỉ ghi các bước tối thiểu cần thiết để cấu hình router cisco làm CA sử dụng SCEP.

Bước 1: Enable CA.

! Vì SCEP hoạt động dựa trên http nên ta phải enable http.

Router(config)# ip http server

! Cấu hình chức năng CA trên Router

Router(config)# crypto pki server CA_name

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 5

Page 6: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

! Cấu hình tên Common Name (CN) sẽ xuất hiện trong các chứng nhận (certificate) của CA. Nếu không! cấu hình lệnh này thì mặc định CA_name sẽ được dùng là CN luôn.

Router(cs-server)# issuer-name CA_string

! Cấu hình hạn sử dụng của CA.

Router(cs-server)# lifetime ca-certificate time_in_days

! Chỉ rỏ nơi lưu các thông tin certificate, mặc định là lưu trong NVRAM.

Router(cs-server)# database url root_URL

! Bắt buộc phải có lệnh “no shutdown” đển hoàn thành việc enable CA.

Router(cs-server)# no shutdownRouter(cs-server)# exit

Bước 2: Điều khiển việc chấp nhận các yêu cầu xin CA.

! Xem thông tin yêu cầu chứng nhận từ Clients

Router# crypto pki server CA_name info requestsVí dụ:

RouterCA# crypto pki server routerca info requestsEnrollment Request Database:Subordinate CA certificate requests:ReqID State Fingerprint SubjectName--------------------------------------------------------------

output omittedRouter certificates requests:ReqID State Fingerprint SubjectName--------------------------------------------------------------1 pending F089C0A84FC27545E01BE806978D898A hostname=r3620.cisco.com

! Xóa các yêu cầu chứng thực của client, nếu ghi thêm tham số reqID thì chỉ xóa những yêu cầu với reqID tương ứng.

Router# crypto pki server CA_name remove {all | reqID}

! Phê chuẩn các yêu cầu chứng thực của client, nếu ghi thêm tham số reqID thì chỉ phê chuẩn những yêu cầu với reqID tương ứng.

Router# crypto pki server CA_name grant {all | reqID}

! Từ chối không phê chuẩn các yêu cầu chứng thực của client, nếu ghi thêm tham số reqID thì chỉ từ chối phê chuẩn những yêu cầu với reqID tương ứng.

Router# crypto pki server CA_name reject {all | reqID}

• Cấu hình router cisco xin chứng nhận từ CA:

Bước 1: Cấu hình tên host và tên miền.

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 6

Page 7: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

Router(config)#hostname R1R1(config)#ip domain-name pronet.edu.vn

Bước 2: Cấu hình tạo cặp khóa RSA.

R1(config)#crypto key generate rsa The name for the keys will be: R1.pronet.edu.vnChoose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes.

How many bits in the modulus [512]: % Generating 512 bit RSA keys, keys will be non-exportable...[OK]

Bước 3: Định nghĩa CA cần yêu cầu chứng nhận.

Router(config)# crypto {ca | pki} trustpoint CA_nameRouter(ca-trustpoint)# enrollment url CA_URL

Ví dụ:

R1(config)# crypto pki trustpoint ProNetR1(ca-trustpoint)# enrollment url http://pronet.edu.vn/ca

Bước 4: chứng thực với CA.

Router(config)# crypto {ca | pki} authenticate CA_name

Ví dụ:

R1(config)# crypto pki authenticate ProNet

Bước 5: Gởi yêu cầu chứng nhận.

Router(config)# crypto {ca | pki} enroll CA_name

Ví dụ:

R1(config)# crypto ca enroll caserver% 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.Password: cisco123abcRe-enter password: cisco123abc% The fully-qualified domain name in the certificate will be:

R1.pronet.edu.vn% The subject name in the certificate will be: R1.pronet.edu.vn % Include the router serial number in the subject name? [yes/no]: no% Include an IP address in the subject name? [no]: noRequest certificate from CA? [yes/no]: yes% Certificate request sent to Certificate Authority% The certificate request fingerprint will be displayed.% The 'show crypto pki certificate' command will also show the fingerprint.05:32:29: CRYPTO_PKI: Certificate Request Fingerprint MD5:

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 7

Page 8: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

F9A3574C 09BAC68D 491D0FDA 1EBCE0BC05:32:29: CRYPTO_PKI: Certificate Request Fingerprint SHA1: 898BDC0B 69F74320 8EECF1FF FD86503F 3DC366BB05:32:34: %PKI-6-CERTRET: Certificate received from Certificate Authority

Bước 6: Lưu chứng nhận định danh của CA.

Dùng lệnh copy running-config startup-config.

II) Một số bài LAB mẫu Site-to-Site VPN:

1) Lab 1: Site-to-site VPN sử dụng chứng thực Preshared-key

Sơ đồ mạng:

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 8

Page 9: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

R2

ISP

R1

Lo0: 192 .168 .1.1/24 Lo0: 192.168.2.1/24

101 .0.0.0/24102.0.0.0/24

.2.2

.1.1

S0/1

S0/0

S0/0

S0/0

Cấu hình:

Trên R1:

R1#sho runBuilding configuration...!(bỏ qua)!crypto isakmp policy 1 hash md5 authentication pre-share group 2crypto isakmp key pronet address 102.0.0.1!!crypto ipsec transform-set setR1 esp-des esp-md5-hmac !crypto map mapR1 1 ipsec-isakmp set peer 102.0.0.1 set transform-set setR1 match address ACL_VPN!!! interface Loopback0 ip address 192.168.1.1 255.255.255.0!interface FastEthernet0/0 no ip address shutdown duplex auto speed auto!interface Serial0/0 ip address 101.0.0.1 255.255.255.0

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 9

Page 10: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

clock rate 2000000 crypto map mapR1!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!interface Serial0/1 no ip address shutdown clock rate 2000000!ip route 0.0.0.0 0.0.0.0 Serial0/0!!ip http serverno ip http secure-server!ip access-list extended ACL_VPN permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255!(bỏ qua)!end

Trên R2:

R2#sho run!(bỏ qua)!crypto isakmp policy 1 hash md5 authentication pre-share group 2crypto isakmp key pronet address 101.0.0.1!!crypto ipsec transform-set setR2 esp-des esp-md5-hmac !crypto map mapR2 1 ipsec-isakmp set peer 101.0.0.1 set transform-set setR2 match address ACL_VPN!!! interface Loopback0 ip address 192.168.2.1 255.255.255.0!interface FastEthernet0/0 no ip address shutdown duplex auto speed auto!

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 10

Page 11: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

interface Serial0/0 ip address 102.0.0.1 255.255.255.0 clock rate 2000000 crypto map mapR2!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!interface Serial0/1 no ip address shutdown clock rate 2000000!ip route 0.0.0.0 0.0.0.0 Serial0/0!!ip http serverno ip http secure-server!ip access-list extended ACL_VPN permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255!(bỏ qua)!end

Trên ISP:

ISP#sho run!(bỏ qua)!interface FastEthernet0/0 no ip address shutdown duplex auto speed auto!interface Serial0/0 ip address 101.0.0.2 255.255.255.0 clock rate 64000!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!interface Serial0/1 ip address 102.0.0.2 255.255.255.0 clock rate 64000!(bỏ qua)!end

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 11

Page 12: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

2) Lab 2: Site-to-site VPN sử dụng chứng thực RSA Encrypted Nonces.

Sơ đồ mạng:

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 12

Page 13: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

R2

ISP

R1

Lo0: 192 .168 .1.1/24 Lo0: 192.168.2.1/24

100.0.0.0/24 101 .0.0.0/24

.2

.2.1

.1F0/1

F0/0

F0/0

F0/0

Cấu hình tương tự như lab site-to-site VPN cơ bản, chỉ khác ở chổ không cấu hình preshared-key mà cấu hình RSA Encrypted Nonces.

Thực hiện cấu hình chứng thực RSA Encrypted Nonces:

Trên R1:

Router(config)#hostname R1R1(config)#ip domain-name pronet.edu.vnR1(config)#crypto key generate rsa The name for the keys will be: R1.pronet.edu.vnChoose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes.

How many bits in the modulus [512]: % Generating 512 bit RSA keys, keys will be non-exportable...[OK]

R1(config)#^ZR1#*Mar 1 00:42:54.591: %SSH-5-ENABLED: SSH 1.99 has been enabled*Mar 1 00:42:55.899: %SYS-5-CONFIG_I: Configured from console by consoleR1#sho crypto key mypubkey rsa% Key pair was generated at: 00:42:54 UTC Mar 1 2002Key name: R1.pronet.edu.vn Usage: General Purpose Key Key is not exportable. Key Data: 305C300D 06092A86 4886F70D 01010105 00034B00 30480241 00E1840A 3C7C56F0 E9A6FC05 C0E9C475 31D7BAB4 16BA2D0B 6225FE1A BABBEC1A 98D10326 22E92B47 4F2EE0E0 AEBB9575 C8ADCF3A 65DBD399 43883470 D641A3E8 35020301 0001% Key pair was generated at: 00:42:55 UTC Mar 1 2002Key name: R1.pronet.edu.vn.server Usage: Encryption Key Key is not exportable. Key Data: 307C300D 06092A86 4886F70D 01010105 00036B00 30680261 00D0D76D A9BC445F 45BCEA98 BB052210 AEE61F80 E1A1C337 D42728A2 67679767 4D6004F4 D74007A5 F9193312 3208FF64 E5971867 1FDA5390 F190902D 292219FB 4955A1FA 311F7ADF B4125D20 73E45386 21CEF920 BBB31299 BE6FB651 6036A13F D3020301 0001R1#

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 13

Page 14: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

R1#conf tEnter configuration commands, one per line. End with CNTL/Z.R1(config)#crypto key pubkey-chain rsa R1(config-pubkey-chain)#addressed-key 101.0.0.2R1(config-pubkey-key)#key-string Enter a public key as a hexidecimal number ....

R1(config-pubkey)#305C300D 06092A86 4886F70D 01010105R1(config-pubkey)#00034B00 30480241 00C3F4FF 640DEC64R1(config-pubkey)#EBA0427D 2794180D 5FD67884 6B13ACE7R1(config-pubkey)#5A370FD4 75151F1B 10E400F5 04380909R1(config-pubkey)#066FBC57 9D2BB9A2 0EE04D95 8FB2BE15R1(config-pubkey)#4C1FE507 EDADDF60 89020301 0001R1(config-pubkey)#quitR1(config-pubkey-key)#^ZR1#

Trên R2:

R2(config)#hostname R2R2(config)#ip domain-name pronet.edu.vnR2(config)#crypto key generate rsa The name for the keys will be: R2.pronet.edu.vnChoose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes.

How many bits in the modulus [512]: % Generating 512 bit RSA keys, keys will be non-exportable...[OK]

R2(config)#R2#sho crypto key mypubkey r % Key pair was generated at: 00:42:00 UTC Mar 1 2002Key name: R2.pronet.edu.vn Usage: General Purpose Key Key is not exportable. Key Data: 305C300D 06092A86 4886F70D 01010105 00034B00 30480241 00C3F4FF 640DEC64 EBA0427D 2794180D 5FD67884 6B13ACE7 5A370FD4 75151F1B 10E400F5 04380909 066FBC57 9D2BB9A2 0EE04D95 8FB2BE15 4C1FE507 EDADDF60 89020301 0001% Key pair was generated at: 00:42:01 UTC Mar 1 2002Key name: R2.pronet.edu.vn.server Usage: Encryption Key Key is not exportable. Key Data: 307C300D 06092A86 4886F70D 01010105 00036B00 30680261 00A2308F 5F8846AF FC423170 951BC10C DD882934 C3F06E54 58A579D8 F89DAF03 0BA94069 891EA161 B7CF35BC 006A0BD2 F18FCBC1 8696A180 B74B46AA 6D5E855E 5B5F7535 B913530B F73E0625 7DAE97F8 4B4BBE24 ABBCDCDB B512BF65 91C4D642 9F020301 0001R2#R2(config)#cry key pubkey-chain rsaR2(config-pubkey-chain)#addressed-key 100.0.0.1R2(config-pubkey-key)#key-string Enter a public key as a hexidecimal number ....

R2(config-pubkey)#305C300D 06092A86 4886F70D 01010105R2(config-pubkey)#00034B00 30480241 00E1840A 3C7C56F0R2(config-pubkey)#E9A6FC05 C0E9C475 31D7BAB4 16BA2D0B

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 14

Page 15: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

R2(config-pubkey)#6225FE1A BABBEC1A 98D10326 22E92B47R2(config-pubkey)#4F2EE0E0 AEBB9575 C8ADCF3A 65DBD399R2(config-pubkey)#43883470 D641A3E8 35020301 0001R2(config-pubkey)#quitR2(config-pubkey-key)#^ZR2#

File cấu hình tham khảo:

ISP:

ISP#sho runBuilding configuration...Current configuration : 649 bytes!version 12.4service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname ISP!(bỏ qua)!interface FastEthernet0/0 ip address 100.0.0.2 255.255.255.0 duplex auto speed auto!interface FastEthernet0/1 ip address 101.0.0.1 255.255.255.0 duplex auto speed auto!(bỏ qua)!End

R1:

R1#sho runBuilding configuration...

Current configuration : 1431 bytes!version 12.4service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname R1!boot-start-markerboot-end-marker!no aaa new-model!resource policy

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 15

Page 16: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

!memory-size iomem 5ip subnet-zero!ip cefip domain name pronet.edu.vn!crypto key pubkey-chain rsa addressed-key 101.0.0.2 address 101.0.0.2 key-string 305C300D 06092A86 4886F70D 01010105 00034B00 30480241 00C3F4FF 640DEC64 EBA0427D 2794180D 5FD67884 6B13ACE7 5A370FD4 75151F1B 10E400F5 04380909 066FBC57 9D2BB9A2 0EE04D95 8FB2BE15 4C1FE507 EDADDF60 89020301 0001 quit ! crypto isakmp policy 1 hash md5 authentication rsa-encr group 2!crypto ipsec transform-set myset esp-des esp-md5-hmac !crypto map mymap 1 ipsec-isakmp set peer 101.0.0.2 set transform-set myset match address VPNACL!interface Loopback0 ip address 192.168.1.1 255.255.255.0!interface FastEthernet0/0 ip address 100.0.0.1 255.255.255.0 duplex auto speed auto crypto map mymap!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!ip http serverno ip http secure-serverip classlessip route 0.0.0.0 0.0.0.0 100.0.0.2!ip access-list extended VPNACL permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255!control-plane!line con 0 logging synchronousline aux 0line vty 0 4!

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 16

Page 17: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

!End

R2:

R2#sho runBuilding configuration...

Current configuration : 1431 bytes!version 12.4service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname R2!boot-start-markerboot-end-marker!no aaa new-model!resource policy!memory-size iomem 5ip subnet-zero!!ip cefip domain name pronet.edu.vn!crypto key pubkey-chain rsa addressed-key 100.0.0.1 address 100.0.0.1 key-string 305C300D 06092A86 4886F70D 01010105 00034B00 30480241 00E1840A 3C7C56F0 E9A6FC05 C0E9C475 31D7BAB4 16BA2D0B 6225FE1A BABBEC1A 98D10326 22E92B47 4F2EE0E0 AEBB9575 C8ADCF3A 65DBD399 43883470 D641A3E8 35020301 0001 quit! crypto isakmp policy 1 hash md5 authentication rsa-encr group 2!!crypto ipsec transform-set myset esp-des esp-md5-hmac !crypto map mymap 1 ipsec-isakmp set peer 100.0.0.1 set transform-set myset match address VPNACL!interface Loopback0 ip address 192.168.2.1 255.255.255.0! interface FastEthernet0/0 ip address 101.0.0.2 255.255.255.0

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 17

Page 18: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

duplex auto speed auto crypto map mymap!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!ip http serverno ip http secure-serverip classlessip route 0.0.0.0 0.0.0.0 101.0.0.1!ip access-list extended VPNACL permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255!control-plane!line con 0 logging synchronousline aux 0line vty 0 4!end

3) Lab 3: Site-to-site VPN sử dụng chứng thực qua CA.

Sơ đồ mạng:

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 18

Page 19: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

R2

ISP

R1

Lo0: 192 .168 .1.1/24 Lo0: 192.168.2.1/24

101 .0.0.0/24102.0.0.0/24

.2.2

.1.1

S0/1

S0/0

S0/0

S0/0

103.0.0.0/24

S1/0.2

CA

.1 S0/0

Yêu cầu: LAN R1 có thể đến được LAN R2.

Thực hiện:

Cấu hình tương tự như lab site-to-site VPN cơ bản, chỉ khác ở chổ không cấu hình preshared-key mà cấu hình chứng thực qua CA.

Giả sử đã cấu hình đúng địa chỉ IP như sơ đồ, đã cấu hình định tuyến để các router liên lạc được với nhau (LAN R1 chưa thể đến được LAN R2).

Thực hiện cấu hình chứng thực qua CA:

Trên CA:

! Vì SCEP hoạt động dựa trên HTTP nên ta phải enable giao thức HTTP trên Router

CA(config)#ip http server

! Khai báo và enable CA, tên là ProNet

CA(config)#crypto pki server ProNetCA(cs-server)#no sh%Some server settings cannot be changed after CA certificate generation.% Please enter a passphrase to protect the private key% or type Return to exitPassword: (nhập cisco123, tối thiểu 7 kí tự)

Re-enter password: (nhập lại cisco123)% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 19

Page 20: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

% Time has not been set. Cannot start the Certificate serverCA(cs-server)#*Mar 1 00:14:57.551: %SSH-5-ENABLED: SSH 1.99 has been enabledCA(config)#^Z% Ambiguous command: "e"*Mar 1 00:15:11.931: %SYS-5-CONFIG_I: Configured from console by console

! Cấu hình thời gian hiện hành trên router thì mới có thể enable CA, khuyến cáo nên sử dụng NTP.

CA#clock set 15:30:00 6 FEB 2009CA#% Exporting Certificate Server signing certificate and keys...

*Feb 6 15:30:00.000: %SYS-6-CLOCKUPDATE: System clock has been updated from 00:15:51 UTC Fri Mar 1 2002 to 15:30:00 UTC Fri Feb 6 2009, configured from console by console.CA#Feb 6 15:30:01.603: %PKI-6-CS_ENABLED: Certificate server now enabled.CA#

! Kiểm tra các khóa đã được tạo ra.

CA#sho crypto key mypubkey rsa% Key pair was generated at: 00:14:57 UTC Mar 1 2002Key name: ProNet Storage Device: not specified Usage: General Purpose Key Key is not exportable. Key Data: 30819F30 0D06092A 864886F7 0D010101 05000381 8D003081 89028181 00D9DEA5 32A5C052 88CB20E5 2495FF7C D263097E 12610305 F681CBD9 C099D342 C2FD42FA 36A3FE93 DB04759B 1F4AE764 85DAE063 15EB0C16 025E3E0F B7203AE8 B948AD1A C6C540A3 C0E791C6 E3609FAC 02059D70 17745EAB E7CF26E5 01A15001 77D76C05 595513E6 09D33D19 87E9287D 301DC9A6 C6390542 EBD26F2D F3AFD0A8 7F020301 0001% Key pair was generated at: 00:14:58 UTC Mar 1 2002Key name: ProNet.serverTemporary key Usage: Encryption Key Key is not exportable. Key Data: 307C300D 06092A86 4886F70D 01010105 00036B00 30680261 00BC1340 A83FEE9F A3F9717D 3CF85A67 6B3882D1 01A536D6 325F0101 71EE05E9 F2F748E3 636EBA78 6CF1A6EC 93648E5E C0DD8D47 1CB23C1F B1294E30 C2527967 7CE6A145 6B33AF73 703E2431 79AB8E43 2259B793 3A6CC06D 7C914A16 AC5D9143 35020301 0001CA#

Trên R1:

! Bắt buộc phải cấu hình hostname và domain-name vì đó sẽ làm các tham số đầu

! vào cho việc tạo khóa.

Router(config)#hostname R1R1(config)#ip domain-name pronet.edu.vn

! Tạo khóa.

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 20

Page 21: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

R1(config)#crypto key generate rsa The name for the keys will be: R1.pronet.edu.vnChoose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes.

How many bits in the modulus [512]: % Generating 512 bit RSA keys, keys will be non-exportable...[OK]

R1(config)#Feb 6 15:36:10.103: %SSH-5-ENABLED: SSH 1.99 has been enabled

! Định nghĩa một CA.

R1(config)#crypto ca trustpoint ProNet

! Lệnh enrollment mode ra cho biết là CA có cung cấp RA (Registerd Authority) dự! phòng. Điều này là mặc định ở hầu hết các Cisco IOS nên nếu không cần thiết thì! cũng không cần cấu hình lệnh này.

R1(ca-trustpoint)#enrollment mode ra

! Chỉ rỏ URL đến CA.

R1(ca-trustpoint)#enrollment url http://103.0.0.1R1(ca-trustpoint)#^ZFeb 6 15:36:42.395: %SYS-5-CONFIG_I: Configured from console by consoleR1#copy run startDestination filename [startup-config]? Building configuration...[OK]R1#conf t Enter configuration commands, one per line. End with CNTL/Z.

! Tải về và chứng thực các chứng nhận của CA.

R1(config)#crypto pki authenticate ProNetCertificate has the following attributes: Fingerprint MD5: 9B0A62AB E4F377FE 9711677F 448A72EB Fingerprint SHA1: C77F7D3C 9AA07C4C E97937DF 030D5AE6 58120162

% Do you accept this certificate? [yes/no]: yesTrustpoint CA certificate accepted.

! Yêu cầu chứng nhận định danh router.

R1(config)#crypto ca enroll ProNet%% 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.

Password: (nhập cisco123, tối thiểu 7 kí tự)Re-enter password: (nhập lại cisco123)

% The subject name in the certificate will include: R1.pronet.edu.vn

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 21

Page 22: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

% Include the router serial number in the subject name? [yes/no]: no% Include an IP address in the subject name? [no]: noRequest certificate from CA? [yes/no]: yes% Certificate request sent to Certificate Authority% The 'show crypto ca certificate ProNet verbose' commandwill show the fingerprint.

R1(config)#Feb 6 15:38:22.291: CRYPTO_PKI: Certificate Request Fingerprint MD5: 03CF9F14 8F04E3A4 F68D8215 7C8772AD Feb 6 15:38:22.295: CRYPTO_PKI: Certificate Request Fingerprint SHA1: A030DCDE B7C721EE 656C4339 2AE4C328 E21AC235 R1(config)#^ZFeb 6 15:38:30.319: %SYS-5-CONFIG_I: Configured from console by console

! Xem lại các chứng nhận trên Router.R1#sho crypto ca certificates verbose CA Certificate Status: Available Version: 3 Certificate Serial Number: 01 Certificate Usage: Signature Issuer: cn=ProNet Subject: cn=ProNet Validity Date: start date: 15:30:00 UTC Feb 6 2009 end date: 15:30:00 UTC Feb 6 2012 Subject Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (1024 bit) Signature Algorithm: MD5 with RSA Encryption Fingerprint MD5: 9B0A62AB E4F377FE 9711677F 448A72EB Fingerprint SHA1: C77F7D3C 9AA07C4C E97937DF 030D5AE6 58120162 X509v3 extensions: X509v3 Key Usage: 86000000 Digital Signature Key Cert Sign CRL Signature X509v3 Subject Key ID: 7E767F28 DCBA573C C95A5CE3 0C111117 13782CDD X509v3 Basic Constraints: CA: TRUE X509v3 Authority Key ID: 7E767F28 DCBA573C C95A5CE3 0C111117 13782CDD Authority Info Access: Associated Trustpoints: ProNet

Certificate Subject: Name: R1.pronet.edu.vn Status: Pending Key Usage: General Purpose Certificate Request Fingerprint MD5: 03CF9F14 8F04E3A4 F68D8215 7C8772AD Certificate Request Fingerprint SHA1: A030DCDE B7C721EE 656C4339 2AE4C328 E21AC235 Associated Trustpoint: ProNet

R1#

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 22

Page 23: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

Cấu hình tương tự trên R2:

Trên R2:

Router(config)#hostname R2R2(config)#ip domain-name pronet.edu.vnR2(config)#crypto key generate rsa The name for the keys will be: R2.pronet.edu.vnChoose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes.

How many bits in the modulus [512]: % Generating 512 bit RSA keys, keys will be non-exportable...[OK]

R2(config)#Feb 6 15:46:38.179: %SSH-5-ENABLED: SSH 1.99 has been enabledR2(config)#crypto ca trustpoint ProNetR2(ca-trustpoint)#enrollment mode raR2(ca-trustpoint)#enrollment url http://103.0.0.1R2(ca-trustpoint)#exitR2(config)#^ZR2#wrBuilding configuration...

Feb 6 15:47:26.951: %SYS-5-CONFIG_I: Configured from console by console[OK]R2#conf t Enter configuration commands, one per line. End with CNTL/Z.

R2(config)#crypto ca authenticate ProNetCertificate has the following attributes: Fingerprint MD5: 9B0A62AB E4F377FE 9711677F 448A72EB Fingerprint SHA1: C77F7D3C 9AA07C4C E97937DF 030D5AE6 58120162

% Do you accept this certificate? [yes/no]: yesTrustpoint CA certificate accepted.

R2(config)#crypto ca enroll ProNet%% 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.

Password: Re-enter password:

% The subject name in the certificate will include: R2.pronet.edu.vn% Include the router serial number in the subject name? [yes/no]: no% Include an IP address in the subject name? [no]: noRequest certificate from CA? [yes/no]: yes% Certificate request sent to Certificate Authority% The 'show crypto ca certificate ProNet verbose' commandwill show the fingerprint.

R2(config)#Feb 6 15:48:18.019: CRYPTO_PKI: Certificate Request Fingerprint MD5: 41163E6A 6951FDBD 2FFDBD64 62473E0A

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 23

Page 24: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

Feb 6 15:48:18.031: CRYPTO_PKI: Certificate Request Fingerprint SHA1: 4FA69EE7 C5CCDE21 FF7FCB91 90AC7C89 57D03755 R2(config)#^Z

R2#sho crypto ca certificates verbose CA Certificate Status: Available Version: 3 Certificate Serial Number: 01 Certificate Usage: Signature Issuer: cn=ProNet Subject: cn=ProNet Validity Date: start date: 15:30:00 UTC Feb 6 2009 end date: 15:30:00 UTC Feb 6 2012 Subject Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (1024 bit) Signature Algorithm: MD5 with RSA Encryption Fingerprint MD5: 9B0A62AB E4F377FE 9711677F 448A72EB Fingerprint SHA1: C77F7D3C 9AA07C4C E97937DF 030D5AE6 58120162 X509v3 extensions: X509v3 Key Usage: 86000000 Digital Signature Key Cert Sign CRL Signature X509v3 Subject Key ID: 7E767F28 DCBA573C C95A5CE3 0C111117 13782CDD X509v3 Basic Constraints: CA: TRUE X509v3 Authority Key ID: 7E767F28 DCBA573C C95A5CE3 0C111117 13782CDD Authority Info Access: Associated Trustpoints: ProNet

Certificate Subject: Name: R2.pronet.edu.vn Status: Pending Key Usage: General Purpose Certificate Request Fingerprint MD5: 41163E6A 6951FDBD 2FFDBD64 62473E0A Certificate Request Fingerprint SHA1: 4FA69EE7 C5CCDE21 FF7FCB91 90AC7C89 57D03755 Associated Trustpoint: ProNet

R2#

Bây giờ quay lại cấu hình trên CA, dùng lệnh crypto pki server ProNet info requests để xem các yêu cầu chứng nhận:

CA#crypto pki server ProNet info requests Enrollment Request Database:

Subordinate CA certificate requests:ReqID State Fingerprint SubjectName--------------------------------------------------------------

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 24

Page 25: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

RA certificate requests:ReqID State Fingerprint SubjectName--------------------------------------------------------------

Router certificates requests:ReqID State Fingerprint SubjectName--------------------------------------------------------------2 pending 41163E6A6951FDBD2FFDBD6462473E0A hostname=R2.pronet.edu.vn1 pending 03CF9F148F04E3A4F68D82157C8772AD hostname=R1.pronet.edu.vn

CA#

! Phê chuẩn tất cả các yêu cầu chứng nhận.

CA#crypto pki server ProNet grant all CA#

CA#crypto pki server ProNet info requests Enrollment Request Database:

Subordinate CA certificate requests:ReqID State Fingerprint SubjectName--------------------------------------------------------------

RA certificate requests:ReqID State Fingerprint SubjectName--------------------------------------------------------------

Router certificates requests:ReqID State Fingerprint SubjectName--------------------------------------------------------------2 granted 41163E6A6951FDBD2FFDBD6462473E0A hostname=R2.pronet.edu.vn1 granted 03CF9F148F04E3A4F68D82157C8772AD hostname=R1.pronet.edu.vn

CA#Cấu hình chính sách ISAKMP, tranform-set trên R1 và R2:

Trên R1:

R1(config)#crypto isakmp enable R1(config)#crypto isakmp policy 1R1(config-isakmp)#encryption des R1(config-isakmp)#hash md5 R1(config-isakmp)#authentication rsa-sig R1(config-isakmp)#group 2R1(config-isakmp)#exit

R1(config)#crypto ipsec transform-set setR1 esp-des esp-md5-hmac R1(cfg-crypto-trans)#exit

R1(config)#ip access-list extended VPN_ACLR1(config-ext-nacl)#permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255R1(config-ext-nacl)#exit

R1(config)#crypto map mymap 1 ipsec-isakmp % NOTE: This new crypto map will remain disabled until a peer and a valid access list have been configured.

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 25

Page 26: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

R1(config-crypto-map)#set peer 102.0.0.1R1(config-crypto-map)#set transform-set setR1R1(config-crypto-map)#match address VPN_ACLR1(config-crypto-map)#exit

R1(config)#int s0/0R1(config-if)#cryR1(config-if)#crypto map mymapR1(config-if)#^ZR1#*Mar 1 00:10:01.227: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ONR1#

Trên R2:

R2#conf tEnter configuration commands, one per line. End with CNTL/Z.R2(config)#crypto isakmp policy 1R2(config-isakmp)#en des R2(config-isakmp)#hash mR2(config-isakmp)#g 2R2(config-isakmp)#authentication rsa-sig R2(config-isakmp)#exit

R2(config)#crypto ipsec transform-set setR2 esp-des esp-md5-hmac R2(cfg-crypto-trans)#exit

R2(config)#ip access-list extended VPN_ACLR2(config-ext-nacl)#permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255R2(config-ext-nacl)#exit

R2(config)#crypto map mymap 1 ipsec-isakmp % NOTE: This new crypto map will remain disabled until a peer and a valid access list have been configured.R2(config-crypto-map)#set peer 101.0.0.1R2(config-crypto-map)#set transform-set setR2R2(config-crypto-map)#match address VPN_ACLR2(config-crypto-map)#^ZR2#R2#conf tEnter configuration commands, one per line. End with CNTL/Z.R2(config)#int s0/0R2(config-if)#crypto map mymapR2(config-if)#^ZR2#Feb 6 16:15:33.439: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ONFeb 6 16:15:33.763: %SYS-5-CONFIG_I: Configured from console by consoleR2#

Kiểm tra liên lạc giữa LAN R1 và LAN R2:

R2#ping 192.168.1.1 source 192.168.2.1

Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:Packet sent with a source address of 192.168.2.1 !!!!!

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 26

Page 27: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

Success rate is 100 percent (5/5), round-trip min/avg/max = 16/52/100 msR2#

File cấu hình tham khảo:

R1:

R1#sho runBuilding configuration...

Current configuration : 3669 bytes!! Last configuration change at 15:38:30 UTC Fri Feb 6 2009! NVRAM config last updated at 16:05:40 UTC Fri Feb 6 2009!version 12.4service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname R1!boot-start-markerboot-end-marker!no aaa new-model!resource policy!memory-size iomem 5ip cef! ip domain name pronet.edu.vn!crypto pki trustpoint ProNet enrollment url http://103.0.0.1:80 revocation-check crl!crypto pki certificate chain ProNet certificate 03 308201B3 3082011C A0030201 02020103 300D0609 2A864886 F70D0101 04050030 11310F30 0D060355 04031306 50726F4E 6574301E 170D3039 30323036 31363034 32355A17 0D313030 32303631 36303432 355A3021 311F301D 06092A86 4886F70D 01090216 1052312E 70726F6E 65742E65 64752E76 6E305C30 0D06092A 864886F7 0D010101 0500034B 00304802 4100BF6D B4AFD3D7 6153950E 96402667 07D14968 48B628B9 9200F276 35832BF1 A37BAABF C586429F 90285CC0 28C24849 1EDFD483 CC75D9AA 8AE3B39C A7A19F63 FA5B0203 010001A3 4F304D30 0B060355 1D0F0404 030205A0 301F0603 551D2304 18301680 147E767F 28DCBA57 3CC95A5C E30C1111 1713782C DD301D06 03551D0E 04160414 ED68805E C0267C42 5E097218 D8EA1634 F5938873 300D0609 2A864886 F70D0101 04050003 81810063 A043617F 13286A2C DA19D0A7 2B60E575 7258C3E7 4FDD9E4F BB99E80D 14443D78 90070950 8DE95918 95A29A73 842C36B8 BFA94EE8 3B572C83 C497EB0D A1F2D4D6 866FE562 1BD68C66 68A5E28B A85CF64A 0FE60967 53EF870C FC80803F 390B9906 D4393B26 405EC8C7 283BE24B 5BE31937 668BD8C0 E4D6E31A 236C36B9 7C550E quit certificate ca 01 308201FB 30820164 A0030201 02020101 300D0609 2A864886 F70D0101 04050030

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 27

Page 28: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

11310F30 0D060355 04031306 50726F4E 6574301E 170D3039 30323036 31353330 30305A17 0D313230 32303631 35333030 305A3011 310F300D 06035504 03130650 726F4E65 7430819F 300D0609 2A864886 F70D0101 01050003 818D0030 81890281 8100D9DE A532A5C0 5288CB20 E52495FF 7CD26309 7E126103 05F681CB D9C099D3 42C2FD42 FA36A3FE 93DB0475 9B1F4AE7 6485DAE0 6315EB0C 16025E3E 0FB7203A E8B948AD 1AC6C540 A3C0E791 C6E3609F AC02059D 7017745E ABE7CF26 E501A150 0177D76C 05595513 E609D33D 1987E928 7D301DC9 A6C63905 42EBD26F 2DF3AFD0 A87F0203 010001A3 63306130 0F060355 1D130101 FF040530 030101FF 300E0603 551D0F01 01FF0404 03020186 301F0603 551D2304 18301680 147E767F 28DCBA57 3CC95A5C E30C1111 1713782C DD301D06 03551D0E 04160414 7E767F28 DCBA573C C95A5CE3 0C111117 13782CDD 300D0609 2A864886 F70D0101 04050003 8181004E B71E7E71 85099310 B354BE77 FBDD2030 5C0633D5 34037F85 1A9820F1 A7F8FFD8 378CD0B1 B2CE89B8 B3D021A7 8B81B88B 22595CC7 9DD5925A F6DB1A07 A38FE82C 8D4463D7 8F29C15F 29A307A6 39F12B08 E8A3822D 0E97B8F8 26529D48 FB86E5EF 124B5C6D 0F86BC1D 70C66121 87C7B619 5DA6898C 3EBACB67 F134125D 6B077E quit!

crypto isakmp policy 1 hash md5 group 2!crypto ipsec transform-set setR1 esp-des esp-md5-hmac !crypto map mymap 1 ipsec-isakmp set peer 102.0.0.1 set transform-set setR1 match address VPN_ACL!interface Loopback0 ip address 192.168.1.1 255.255.255.0!interface FastEthernet0/0 no ip address shutdown duplex auto speed auto!interface Serial0/0 ip address 101.0.0.1 255.255.255.0 clock rate 2000000 crypto map mymap!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!interface Serial0/1 no ip address shutdown clock rate 2000000!ip route 0.0.0.0 0.0.0.0 Serial0/0!ip http serverno ip http secure-server

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 28

Page 29: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

!ip access-list extended VPN_ACL permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255!control-plane!line con 0 logging synchronousline aux 0line vty 0 4!end

R2:

R2#sho runBuilding configuration...

Current configuration : 3669 bytes!! Last configuration change at 16:15:33 UTC Fri Feb 6 2009! NVRAM config last updated at 16:05:38 UTC Fri Feb 6 2009!version 12.4service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname R2!boot-start-markerboot-end-marker!no aaa new-model!resource policy!memory-size iomem 5ip cef!ip domain name pronet.edu.vn!crypto pki trustpoint ProNet enrollment url http://103.0.0.1:80 revocation-check crl!crypto pki certificate chain ProNet certificate 02 308201B3 3082011C A0030201 02020102 300D0609 2A864886 F70D0101 04050030 11310F30 0D060355 04031306 50726F4E 6574301E 170D3039 30323036 31363034 32355A17 0D313030 32303631 36303432 355A3021 311F301D 06092A86 4886F70D 01090216 1052322E 70726F6E 65742E65 64752E76 6E305C30 0D06092A 864886F7 0D010101 0500034B 00304802 4100D4BE CA499CB1 1D4BFB83 E699FAC0 B6C4E960 4B9150A8 6F5B884A 9FAE80C7 23A72499 FC069FB1 F5977D62 03F53E70 0FB80F3F FA6F7CB4 A2EC7E15 0E89F6DA 6F090203 010001A3 4F304D30 0B060355 1D0F0404 030205A0 301F0603 551D2304 18301680 147E767F 28DCBA57 3CC95A5C E30C1111 1713782C DD301D06 03551D0E 04160414 24DA3405 6AC7B468 EC1423E0 98C98A2A

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 29

Page 30: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

C612E7D2 300D0609 2A864886 F70D0101 04050003 81810011 663A5822 81297281 BB10DD0E 3AE4E5F4 9987506B 3F24D063 8475B86E EB4F8DF4 5FAD289C 5F93963F 76A8F5D3 94450726 79A0AE58 434A1D24 C63F4EF7 AFC5F799 5AAE7A3E 114395CC B876611D A49FBF7A E7FE87E7 E0ED5EFC 500BBE57 364970C9 2DC8CB4A 380ECA38 84AD2374 ACF16313 6C7FB3F8 B957CC18 88FDCB41 2CCB9C quit certificate ca 01 308201FB 30820164 A0030201 02020101 300D0609 2A864886 F70D0101 04050030 11310F30 0D060355 04031306 50726F4E 6574301E 170D3039 30323036 31353330 30305A17 0D313230 32303631 35333030 305A3011 310F300D 06035504 03130650 726F4E65 7430819F 300D0609 2A864886 F70D0101 01050003 818D0030 81890281 8100D9DE A532A5C0 5288CB20 E52495FF 7CD26309 7E126103 05F681CB D9C099D3 42C2FD42 FA36A3FE 93DB0475 9B1F4AE7 6485DAE0 6315EB0C 16025E3E 0FB7203A E8B948AD 1AC6C540 A3C0E791 C6E3609F AC02059D 7017745E ABE7CF26 E501A150 0177D76C 05595513 E609D33D 1987E928 7D301DC9 A6C63905 42EBD26F 2DF3AFD0 A87F0203 010001A3 63306130 0F060355 1D130101 FF040530 030101FF 300E0603 551D0F01 01FF0404 03020186 301F0603 551D2304 18301680 147E767F 28DCBA57 3CC95A5C E30C1111 1713782C DD301D06 03551D0E 04160414 7E767F28 DCBA573C C95A5CE3 0C111117 13782CDD 300D0609 2A864886 F70D0101 04050003 8181004E B71E7E71 85099310 B354BE77 FBDD2030 5C0633D5 34037F85 1A9820F1 A7F8FFD8 378CD0B1 B2CE89B8 B3D021A7 8B81B88B 22595CC7 9DD5925A F6DB1A07 A38FE82C 8D4463D7 8F29C15F 29A307A6 39F12B08 E8A3822D 0E97B8F8 26529D48 FB86E5EF 124B5C6D 0F86BC1D 70C66121 87C7B619 5DA6898C 3EBACB67 F134125D 6B077E quit!crypto isakmp policy 1 hash md5 group 2!crypto ipsec transform-set setR2 esp-des esp-md5-hmac !crypto map mymap 1 ipsec-isakmp set peer 101.0.0.1 set transform-set setR2 match address VPN_ACL!interface Loopback0 ip address 192.168.2.1 255.255.255.0!interface FastEthernet0/0 no ip address shutdown duplex auto speed auto!interface Serial0/0 ip address 102.0.0.1 255.255.255.0 clock rate 2000000 crypto map mymap!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!interface Serial0/1 no ip address

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 30

Page 31: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

shutdown clock rate 2000000!ip route 0.0.0.0 0.0.0.0 Serial0/0! ip http serverno ip http secure-server!ip access-list extended VPN_ACL permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255!control-plane!line con 0 logging synchronousline aux 0line vty 0 4!end

CA:

CA#sho runBuilding configuration...

Current configuration : 2165 bytes!! NVRAM config last updated at 16:05:52 UTC Fri Feb 6 2009!version 12.4service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname CA!boot-start-markerboot-end-marker!no aaa new-model!resource policy!memory-size iomem 5ip cef!crypto pki server ProNet!crypto pki trustpoint ProNet revocation-check crl rsakeypair ProNet!crypto pki certificate chain ProNet certificate ca 01 308201FB 30820164 A0030201 02020101 300D0609 2A864886 F70D0101 04050030 11310F30 0D060355 04031306 50726F4E 6574301E 170D3039 30323036 31353330 30305A17 0D313230 32303631 35333030 305A3011 310F300D 06035504 03130650

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 31

Page 32: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

726F4E65 7430819F 300D0609 2A864886 F70D0101 01050003 818D0030 81890281 8100D9DE A532A5C0 5288CB20 E52495FF 7CD26309 7E126103 05F681CB D9C099D3 42C2FD42 FA36A3FE 93DB0475 9B1F4AE7 6485DAE0 6315EB0C 16025E3E 0FB7203A E8B948AD 1AC6C540 A3C0E791 C6E3609F AC02059D 7017745E ABE7CF26 E501A150 0177D76C 05595513 E609D33D 1987E928 7D301DC9 A6C63905 42EBD26F 2DF3AFD0 A87F0203 010001A3 63306130 0F060355 1D130101 FF040530 030101FF 300E0603 551D0F01 01FF0404 03020186 301F0603 551D2304 18301680 147E767F 28DCBA57 3CC95A5C E30C1111 1713782C DD301D06 03551D0E 04160414 7E767F28 DCBA573C C95A5CE3 0C111117 13782CDD 300D0609 2A864886 F70D0101 04050003 8181004E B71E7E71 85099310 B354BE77 FBDD2030 5C0633D5 34037F85 1A9820F1 A7F8FFD8 378CD0B1 B2CE89B8 B3D021A7 8B81B88B 22595CC7 9DD5925A F6DB1A07 A38FE82C 8D4463D7 8F29C15F 29A307A6 39F12B08 E8A3822D 0E97B8F8 26529D48 FB86E5EF 124B5C6D 0F86BC1D 70C66121 87C7B619 5DA6898C 3EBACB67 F134125D 6B077E quit!interface FastEthernet0/0 no ip address shutdown duplex auto speed auto!interface Serial0/0 ip address 103.0.0.1 255.255.255.0 clock rate 2000000! interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!interface Serial0/1 no ip address shutdown clock rate 2000000!ip route 0.0.0.0 0.0.0.0 Serial0/0!ip http serverno ip http secure-server!control-plane!line con 0 logging synchronousline aux 0line vty 0 4!end

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 32

Page 33: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

4) Lab 4: Cấu hình GRE cơ bản:

Sơ đồ mạng:

R2

ISP

R1

Lo0: 192 .168 .1.1/24 Lo0: 192.168.2.1/24

101 .0.0.0/24102.0.0.0/24

.2.2

.1.1

S0/1

S0/0

S0/0

S0/0

Router R1:

R1#sho runBuilding configuration...!(bỏ qua)

!interface Tunnel0 ip address 10.0.0.1 255.255.255.0 tunnel source Serial0/0 tunnel destination 102.0.0.1!interface Loopback0 ip address 192.168.1.1 255.255.255.0!interface FastEthernet0/0 no ip address shutdown duplex auto speed auto

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 33

Page 34: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

! interface Serial0/0 ip address 101.0.0.1 255.255.255.0 clock rate 2000000!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!interface Serial0/1 no ip address shutdown clock rate 2000000!router eigrp 1 network 10.0.0.0 network 192.168.1.0 auto-summary!ip route 0.0.0.0 0.0.0.0 Serial0/0!(bỏ qua)!end

Router R2:

R2#sho run!(bỏ qua)!interface Tunnel0 ip address 10.0.0.2 255.255.255.0 tunnel source Serial0/0 tunnel destination 101.0.0.1!interface Loopback0 ip address 192.168.2.1 255.255.255.0!interface FastEthernet0/0 no ip address shutdown duplex auto speed auto! interface Serial0/0 ip address 102.0.0.1 255.255.255.0 clock rate 2000000!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!interface Serial0/1

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 34

Page 35: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

no ip address shutdown clock rate 2000000!router eigrp 1 network 10.0.0.0 network 192.168.2.0 auto-summary!ip route 0.0.0.0 0.0.0.0 Serial0/0!(bỏ qua)!end

Router ISP:

ISP#sho runBuilding configuration...!(bỏ qua)!interface FastEthernet0/0 no ip address shutdown duplex auto speed auto!interface Serial0/0 ip address 101.0.0.2 255.255.255.0 clock rate 64000!interface FastEthernet0/1 no ip address shutdown duplex auto speed auto!interface Serial0/1 ip address 102.0.0.2 255.255.255.0 clock rate 64000!(bỏ qua)!end

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 35

Page 36: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

5) Lab 5: GRE over IPSec

Các GRE tunnel như sau:R1 (192.168.1.1/24) ----- (192.168.1.2/24) R2R1 (192.168.2.1/24) ----- (192.168.2.2/24) R3

Cấu hình cụ thể các router như sau:

Router ISP:

!interface FastEthernet0/0no ip addressshutdownduplex autospeed auto!interface Serial0/0ip address 172.16.1.1 255.255.255.0clock rate 64000!interface FastEthernet0/1no ip addressshutdownduplex autospeed auto!interface Serial0/1ip address 172.16.2.1 255.255.255.0clock rate 64000!interface Serial0/2ip address 172.16.3.1 255.255.255.0

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 36

Page 37: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

clock rate 64000!

Router R1:

!

crypto isakmp policy 1hash md5authentication pre-sharegroup 2crypto isakmp key cisco address 172.16.2.2crypto isakmp key cisco address 172.16.3.2!!crypto ipsec transform-set myset esp-des esp-md5-hmac crypto ipsec transform-set myset13 esp-des esp-md5-hmac !crypto map mymap 1 ipsec-isakmp set peer 172.16.2.2set transform-set myset match address 100crypto map mymap 2 ipsec-isakmp set peer 172.16.3.2set transform-set myset13 match address 101!!interface Loopback0ip address 1.0.0.1 255.255.255.0!interface Tunnel0ip address 192.168.1.1 255.255.255.0tunnel source Serial0/0tunnel destination 172.16.2.2!interface Tunnel1ip address 192.168.2.1 255.255.255.0tunnel source Serial0/0tunnel destination 172.16.3.2!interface FastEthernet0/0no ip addressshutdownduplex autospeed auto!interface Serial0/0description Noi IPSec-GRE toi R2ip address 172.16.1.2 255.255.255.0clock rate 2000000crypto map mymap!interface FastEthernet0/1no ip addressshutdownduplex autospeed auto

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 37

Page 38: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

!interface Serial0/1no ip addressshutdownclock rate 2000000!router ospf 1log-adjacency-changesnetwork 1.0.0.0 0.0.0.255 area 0network 192.168.1.0 0.0.0.255 area 0network 192.168.2.0 0.0.0.255 area 0!ip http serverno ip http secure-serverip classlessip route 0.0.0.0 0.0.0.0 Serial0/0! !access-list 100 permit gre host 172.16.1.2 host 172.16.2.2access-list 101 permit gre host 172.16.1.2 host 172.16.3.2!!

Router R2:

!crypto isakmp policy 1hash md5authentication pre-sharegroup 2crypto isakmp key cisco address 172.16.1.2!crypto ipsec transform-set myset esp-des esp-md5-hmac !crypto map mymap 1 ipsec-isakmp set peer 172.16.1.2set transform-set myset match address 100!!interface Loopback0ip address 2.0.0.1 255.255.255.0!interface Tunnel0ip address 192.168.1.2 255.255.255.0tunnel source Serial0/0tunnel destination 172.16.1.2!interface FastEthernet0/0no ip addressshutdownduplex autospeed auto!interface Serial0/0ip address 172.16.2.2 255.255.255.0clock rate 2000000crypto map mymap

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 38

Page 39: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

!interface FastEthernet0/1no ip addressshutdownduplex autospeed auto!interface Serial0/1no ip addressshutdownclock rate 2000000!router ospf 1log-adjacency-changesnetwork 2.0.0.0 0.0.0.255 area 0network 192.168.1.0 0.0.0.255 area 0!ip http serverno ip http secure-serverip classlessip route 0.0.0.0 0.0.0.0 Serial0/0!access-list 100 permit gre host 172.16.2.2 host 172.16.1.2!

Router R3:

! !crypto isakmp policy 1hash md5authentication pre-sharegroup 2crypto isakmp key cisco address 172.16.1.2!crypto ipsec transform-set myset esp-des esp-md5-hmac !crypto map mymap 1 ipsec-isakmp set peer 172.16.1.2set transform-set myset match address 100

!interface Loopback0ip address 3.0.0.1 255.255.255.0!interface Tunnel0ip address 192.168.2.2 255.255.255.0tunnel source Serial0/0tunnel destination 172.16.1.2!interface FastEthernet0/0no ip addressshutdownduplex autospeed auto!interface Serial0/0

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 39

Page 40: 22089395 Cau Hinh IPSec

ISCW

Chương trình đạo tạo mạng chuyên nghiệp ProNet

ip address 172.16.3.2 255.255.255.0clock rate 2000000crypto map mymap!interface FastEthernet0/1no ip addressshutdownduplex autospeed auto!interface Serial0/1no ip addressshutdownclock rate 2000000!router ospf 1log-adjacency-changesnetwork 3.0.0.0 0.0.0.255 area 0network 192.168.2.0 0.0.0.255 area 0!ip http serverno ip http secure-serverip classlessip route 0.0.0.0 0.0.0.0 Serial0/0!! access-list 100 permit gre host 172.16.3.2 host 172.16.1.2!end

Tài liệu cấu hình IPSec VPN – Trịnh Thanh Sử 40