思科IPSec基本命令彙總

“Internet 協議安全性 (IPSec)”是一種開放標準的框架結構,通過使用加密的安全服務以確保在 Internet 協議 (IP) 網絡上進行保密而安全的通訊。那麼思科怎麼配置IPSec呢?配置命令如何?下面跟yjbys小編一起來看看吧!

思科IPSec基本命令彙總

  一、IPSec一些基本命令。

R1(config)#crypto ?

dynamic-map Specify a dynamic crypto map template

//創建或修改一個動態加密映射表

ipsec Configure IPSEC policy

//創建IPSec安全策略

isakmp Configure ISAKMP policy

//創建IKE策略

key Long term key operations

//爲路由器的SSH加密會話產生加密密鑰。後面接數值,是key modulus size,單位爲bit

map Enter a crypto map

//創建或修改一個普通加密映射表

Router(config)#crypto dynamic-map ?

WORD Dynamic crypto map template tag

//WORD爲動態加密映射表名

Router(config)#crypto ipsec ?

security-association Security association parameters

// ipsec安全關聯存活期,也可不配置,在map裏指定即可

transform-set Define transform and settings

//定義一個ipsec變換集合(安全協議和算法的一個可行組合)

Router(config)#crypto isakmp ?

client Set client configuration policy

//建立地址池

enable Enable ISAKMP

//啓動IKE策略,默認是啓動的

key Set pre-shared key for remote peer

//設置密鑰

policy Set policy for an ISAKMP protection suite

//設置IKE策略的優先級

Router(config)#crypto key ?

generate Generate new keys

//生成新的密鑰

zeroize Remove keys

//移除密鑰

Router(config)#crypto map ?

WORD Crypto map tag

//WORD爲map表名

  二、一些重要命令。

Router(config)#crypto isakmp policy ?

<1-10000> Priority of protection suite

//設置IKE策略,policy後面跟1-10000的數字,這些數字代表策略的優先級。

Router(config)#crypto isakmp policy 100//進入IKE策略配置模式,以便做下面的配置

Router(config-isakmp)#encryption ?//設置採用的加密方式,有以下三種

3des Three key triple DES

aes AES - Advanced Encryption Standard

des DES - Data Encryption Standard (56 bit keys).

Router(config-isakmp)#hash ? //採用的散列算法,MD5爲160位,sha爲128位。

md5 Message Digest 5

sha Secure Hash Standard

Router(config-isakmp)#authentication pre-share//採用預共享密鑰的認證方式

Router(config-isakmp)#group ?//指定密鑰的位數,越往下安全性越高,但加密速度越慢

1 Diffie-Hellman group 1

2 Diffie-Hellman group 2

5 Diffie-Hellman group 5

Router(config-isakmp)#lifetime ? //指定安全關聯生存期,爲60-86400秒

<60-86400> lifetime in seconds

Router(config)#crypto isakmp key *** address

//設置IKE交換的密鑰,***表示密鑰組成,表示對方的IP地址

Router(config)#crypto ipsec transform-set zx ?

//設置IPsec交換集,設置加密方式和認證方式,zx是交換集名稱,可以自己設置,兩端的名字也可不一樣,但其他參數要一致。

ah-md5-hmac AH-HMAC-MD5 transform

ah-sha-hmac AH-HMAC-SHA transform

esp-3des ESP transform using 3DES(EDE) cipher (168 bits)

esp-aes ESP transform using AES cipher

esp-des ESP transform using DES cipher (56 bits)

esp-md5-hmac ESP transform using HMAC-MD5 auth

esp-sha-hmac ESP transform using HMAC-SHA auth

例:Router(config)#crypto ipsec transform-set zx esp-des esp-md5-hmac

Router(config)#crypto map map_zx 100 ipsec-isakmp

//建立加密映射表,zx爲表名,可以自己定義,100爲優先級(可選範圍1-65535),如果有多個表,數字越小的越優先工作。

Router(config-crypto-map)#match address ?//用ACL來定義加密的通信

<100-199> IP access-list number

WORD Access-list name

Router(config-crypto-map)#set ?

peer Allowed Encryption/Decryption peer.//標識對方路由器IP地址

pfs Specify pfs settings//指定上面定義的密鑰長度,即group

security-association Security association parameters//指定安全關聯的生存期

transform-set Specify list of transform sets in priority order

//指定加密圖使用的IPSEC交換集

router(config-if)# crypto map zx

//進入路由器的指定接口,應用加密圖到接口,zx爲加密圖名。

  三、一個配置實驗。

實驗拓撲圖:

1.R1上的配置。

Router>enable

Router#config terminal

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#hostname R1

//配置IKE策略

R1(config)#crypto isakmp enable

R1(config)#crypto isakmp policy 100

R1(config-isakmp)#encryption des

R1(config-isakmp)#hash md5

R1(config-isakmp)#authentication pre-share

R1(config-isakmp)#group 1

R1(config-isakmp)#lifetime 86400

R1(config-isakmp)#exit

//配置IKE密鑰

R1(config)#crypto isakmp key 123456 address

//創建IPSec交換集

R1(config)#crypto ipsec transform-set zx esp-des esp-md5-hmac

//創建映射加密圖

R1(config)#crypto map zx_map 100 ipsec-isakmp

R1(config-crypto-map)#match address 111

R1(config-crypto-map)#set peer

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

R1(config-crypto-map)#set security-association lifetime seconds 86400

R1(config-crypto-map)#set pfs group1

R1(config-crypto-map)#exit

//配置ACL

R1(config)#access-list 111 permit ip

//應用加密圖到接口

R1(config)#interface s1/0

R1(config-if)#crypto map zx_map

2.R2上的配置。

與R1的配置基本相同,只需要更改下面幾條命令:

R1(config)#crypto isakmp key 123456 address

R1(config-crypto-map)#set peer

R1(config)#access-list 111 permit ip

3.實驗調試。

在R1和R2上分別使用下面的命令,查看配置信息。

R1#show crypto ipsec ?

sa IPSEC SA table

transform-set Crypto transform sets

R1#show crypto isakmp ?

policy Show ISAKMP protection suite policy

sa Show ISAKMP Security Associations

  四、相關知識點

對稱加密或私有密鑰加密:加密解密使用相同的'私鑰

DES--數據加密標準 data encryption standard

3DES--3倍數據加密標準 triple data encryption standard

AES--高級加密標準 advanced encryption standard

一些技術提供驗證:

MAC--消息驗證碼 message authentication code

HMAC--散列消息驗證碼 hash-based message authentication code

MD5和SHA是提供驗證的散列函數

對稱加密被用於大容量數據,因爲非對稱加密站用大量cpu資源

非對稱或公共密鑰加密:

RSA rivest-shamir-adelman

用公鑰加密,私鑰解密。公鑰是公開的,但只有私鑰的擁有者才能解密

兩個散列常用算法:

HMAC-MD5 使用128位的共享私有密鑰

HMAC-SHA-I 使用160位的私有密鑰

ESP協議:用來提供機密性,數據源驗證,無連接完整性和反重放服務,並且通過防止流量分析來限制流量的機密性,這些服務以來於SA建立和實現時的選擇。

加密是有DES或3DES算法完成。可選的驗證和數據完整性由HMAC,keyed SHA-I或MD5提供

IKE--internet密鑰交換:他提供IPSEC對等體驗證,協商IPSEC密鑰和協商IPSEC安全關聯

實現IKE的組件

1:des,3des 用來加密的方式

2:Diffie-Hellman 基於公共密鑰的加密協議允許對方在不安全的信道上建立公共密鑰,在IKE中被用來建立會話密鑰。group 1表示768位,group 2表示1024位

3:MD5,SHA--驗證數據包的散列算法。RAS簽名--基於公鑰加密系統