IPSec ×××实验
一,IKE协商.
IKE协商跟TCP三次握手相似.不过比TCP 三次握手复杂点.IKE协商过程需要经过9个报文的来回,才能建立通讯双方需要的IKE SA,然后利用该IKE SA进行数据的加密和解密.
IKE协商报文采用UDP格式,默认端口是500
一,IKE协商的第一阶段:也称为IKE的主模式:
1,A和B通讯,A作为发起方,第一个报文是A本地配置的policy(策略),该policy包含:
⑴,加密算法
⑵,hash算法
⑶,D-H组
⑷,认证方式
⑸,SA生存时间
PS: ①,Policy可以配置多个,只要对端只要有任何一个与它匹配就行.
②,五元素里最主要的是认证方式.目前主要分: 预共享 和 数字证书.一般采用预共享秘匙
2,第二个报文是B采用相同的policy发回.表明采用该policy作为后续通讯的保护.
3,第三和第四个报文是A和B进行D-H交换的D-H公开值,这与具体配置关系不大.
在完成上面四个报文的交换后,利用D-H算法.A和B就协商出一个共同的秘密.后续的密匙都是依靠这个秘密来衍生的.
4,第五和第六个报文是身份验证过程.A将自己的身份信息和其他信息发送给B.B对A进行验证,然后发送自己的身份信息回去给A进行验证.
预共享方式主要有两种验证方法: A,IP地址 B,主机名. 一般采用IP地址作为验证方法.
一,IKE协商.
IKE协商跟TCP三次握手相似.不过比TCP 三次握手复杂点.IKE协商过程需要经过9个报文的来回,才能建立通讯双方需要的IKE SA,然后利用该IKE SA进行数据的加密和解密.
IKE协商报文采用UDP格式,默认端口是500
一,IKE协商的第一阶段:也称为IKE的主模式:
1,A和B通讯,A作为发起方,第一个报文是A本地配置的policy(策略),该policy包含:
⑴,加密算法
⑵,hash算法
⑶,D-H组
⑷,认证方式
⑸,SA生存时间
PS: ①,Policy可以配置多个,只要对端只要有任何一个与它匹配就行.
②,五元素里最主要的是认证方式.目前主要分: 预共享 和 数字证书.一般采用预共享秘匙
2,第二个报文是B采用相同的policy发回.表明采用该policy作为后续通讯的保护.
3,第三和第四个报文是A和B进行D-H交换的D-H公开值,这与具体配置关系不大.
在完成上面四个报文的交换后,利用D-H算法.A和B就协商出一个共同的秘密.后续的密匙都是依靠这个秘密来衍生的.
4,第五和第六个报文是身份验证过程.A将自己的身份信息和其他信息发送给B.B对A进行验证,然后发送自己的身份信息回去给A进行验证.
预共享方式主要有两种验证方法: A,IP地址 B,主机名. 一般采用IP地址作为验证方法.
完成上面六个报文的交换,IKE的第一阶段就已经完成.(IKE主模式协商完成),打开debug会看到IKE SA Establish (IKE SA已经建立)
二,IKE第二阶段-----IKE快速模式协商.
上面6个报文之后,进入的就是第二阶段---快速模式.是依靠最后的三个报文来进行IPSec SA协商.利用第一阶段协商出来的共同的秘密来为这三个报文来进行加密.配置方面是以下三个
1, 数据流(access-list定义保护加密的数据流)
2, 交换集合transform-set (加密算法和安全协议)
3, 完美前向保护(PFS)
很多情况下,发现IKE SA已经建立,但IPSec SA无法建立.很有可能就是因为这三点不一致造成.
上面6个报文之后,进入的就是第二阶段---快速模式.是依靠最后的三个报文来进行IPSec SA协商.利用第一阶段协商出来的共同的秘密来为这三个报文来进行加密.配置方面是以下三个
1, 数据流(access-list定义保护加密的数据流)
2, 交换集合transform-set (加密算法和安全协议)
3, 完美前向保护(PFS)
很多情况下,发现IKE SA已经建立,但IPSec SA无法建立.很有可能就是因为这三点不一致造成.
IKE配置:
1, Policy
包括hash算法,加密算法,D-H组,生存时间,.认证方式是最重要的.
2, 预共享 (preshare)
验证方式一般采用预共享方式,又分为IP地址和主机名(hostname).一般采用IP地址验证.
3, 本端标识 (localID)
IP地址或主机名。一般采用IP地址. 如果发起方
以上三个步骤就完成IKE SA的配置.接下来的是IPSec的配置
1, 配置要保护(加密)的数据流(access-list)
部署任何×××都需要对数据流进行限制.不可能对所有的数据流进行加密(any to any ),该Access-list在加密映射(map)里会被引用. 首先是在实际使用过程中,不会有这样的需求,其次,这样会让很多本来不需要加密的通信无法通信。比如广播被加密后大量丢弃,路由器无法工作.
2, 配置变换集合(transform-set)
变换集合是某个对等方能接受的密码学算法和安全协议(IPSec协议),双方需要一致.
3, 配置加密映射(map)
为IPSec创建的加密映射条目,使IPSec联盟的各部件协调工作.包括以下部分:
⑴, 欲保护(加密)的数据流 (引用access-list所定义)
⑵, 对端的IP地址 (这个是必须的,除非是动态映射加密)
⑶, 欲保护(加密)的数据流采用的加密算法和安全协议(引用transform-set定义)
⑷, 是否需要PFS支持 (两端要一致)
⑸, SA的生存时间 (不配置的话有默认值)
1, Policy
包括hash算法,加密算法,D-H组,生存时间,.认证方式是最重要的.
2, 预共享 (preshare)
验证方式一般采用预共享方式,又分为IP地址和主机名(hostname).一般采用IP地址验证.
3, 本端标识 (localID)
IP地址或主机名。一般采用IP地址. 如果发起方
以上三个步骤就完成IKE SA的配置.接下来的是IPSec的配置
1, 配置要保护(加密)的数据流(access-list)
部署任何×××都需要对数据流进行限制.不可能对所有的数据流进行加密(any to any ),该Access-list在加密映射(map)里会被引用. 首先是在实际使用过程中,不会有这样的需求,其次,这样会让很多本来不需要加密的通信无法通信。比如广播被加密后大量丢弃,路由器无法工作.
2, 配置变换集合(transform-set)
变换集合是某个对等方能接受的密码学算法和安全协议(IPSec协议),双方需要一致.
3, 配置加密映射(map)
为IPSec创建的加密映射条目,使IPSec联盟的各部件协调工作.包括以下部分:
⑴, 欲保护(加密)的数据流 (引用access-list所定义)
⑵, 对端的IP地址 (这个是必须的,除非是动态映射加密)
⑶, 欲保护(加密)的数据流采用的加密算法和安全协议(引用transform-set定义)
⑷, 是否需要PFS支持 (两端要一致)
⑸, SA的生存时间 (不配置的话有默认值)
特别鸣谢:灵溪金典网吧以及香香公主网吧提供×××100路由器以及线路,我才得以完成以下实现。(当然,他们不知道。让我们再次对他们的默默的无私奉献致敬)
Configuration:
Configuration:
access-list 111 permit ip 192.168.1.0 0.0.0.255 192.168.16.0 0.0.0.255 ----定义保护的数据流
crypto isakmp policy 1 ----创建isakmp 策略
authentication pre-share ----认证方式
hash md5 ----hash算法
group 2 ---组号
!
!
crypto isakmp key 7 151b5f72467e7a address 60.190.90.66 -----pre-share密码
crypto ipsec transform-set myset esp-des esp-md5-hmac -----定义交换集合加密和算法
crypto map mymap 1 ipsec-isakmp ----定义加密映射
set peer 60.190.90.66 ----对端的ip地址
set transform-set myset -----引用myset这个交换集合
match address 111 -----引用access-list 111定义的保护数据流
!
interface FastEthernet 0/0
ip nat inside
ip access-group 120 in
no ip redirects
ip address 192.168.1.2 255.255.255.0
!
interface FastEthernet 1/0
ip nat outside
ip access-group 110 in
ip address 60.190.94.84 255.255.255.248
crypto map mymap ----应用crypto map-
duplex auto
speed auto
crypto isakmp policy 1 ----创建isakmp 策略
authentication pre-share ----认证方式
hash md5 ----hash算法
group 2 ---组号
!
!
crypto isakmp key 7 151b5f72467e7a address 60.190.90.66 -----pre-share密码
crypto ipsec transform-set myset esp-des esp-md5-hmac -----定义交换集合加密和算法
crypto map mymap 1 ipsec-isakmp ----定义加密映射
set peer 60.190.90.66 ----对端的ip地址
set transform-set myset -----引用myset这个交换集合
match address 111 -----引用access-list 111定义的保护数据流
!
interface FastEthernet 0/0
ip nat inside
ip access-group 120 in
no ip redirects
ip address 192.168.1.2 255.255.255.0
!
interface FastEthernet 1/0
ip nat outside
ip access-group 110 in
ip address 60.190.94.84 255.255.255.248
crypto map mymap ----应用crypto map-
duplex auto
speed auto
对方配置同上。
#########################调试信息##############################
×××100#clear crypto isakmp 清除isakmp sa
×××100#clear crypto sa 清除所有sa包括isakmp sa和ipsec sa
×××100#debug crypto isakmp debug isakmp 协商过程
×××100#ping
Protocol [ip]:
Target IP address: 192.168.1.2
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y ---用扩展ping
Source address:192.168.16.254 ---定义源地址是为了能触发isakmp协商。因为我不能在任何一个路由器的内网。
Sending 5, 100-byte ICMP Echoes to 192.168.1.2, timeout is 2 seconds:
< press Ctrl+C to break >
.....
Success rate is 0 percent (0/5)
×××100#sh log
Syslog logging: enabled
Console logging: disabled
Monitor logging: disabled
Buffer logging: level debugging, 281 messages logged
logging trace : disable
Timestamp debug messages: uptime
Timestamp log messages: disabled
Sequence log messages: disable
Trap logging: level informational, 0 message lines logged,0 reserved,0 fail
Log Buffer (Total 4096 Bytes) : have written 3499
#########################调试信息##############################
×××100#clear crypto isakmp 清除isakmp sa
×××100#clear crypto sa 清除所有sa包括isakmp sa和ipsec sa
×××100#debug crypto isakmp debug isakmp 协商过程
×××100#ping
Protocol [ip]:
Target IP address: 192.168.1.2
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y ---用扩展ping
Source address:192.168.16.254 ---定义源地址是为了能触发isakmp协商。因为我不能在任何一个路由器的内网。
Sending 5, 100-byte ICMP Echoes to 192.168.1.2, timeout is 2 seconds:
< press Ctrl+C to break >
.....
Success rate is 0 percent (0/5)
×××100#sh log
Syslog logging: enabled
Console logging: disabled
Monitor logging: disabled
Buffer logging: level debugging, 281 messages logged
logging trace : disable
Timestamp debug messages: uptime
Timestamp log messages: disabled
Sequence log messages: disable
Trap logging: level informational, 0 message lines logged,0 reserved,0 fail
Log Buffer (Total 4096 Bytes) : have written 3499
Configured from console by vty0 (60.181.132.226)
14:1:54:29 ×××100: %7:Acqurire negociate with 60.190.94.84
14:1:54:29 ×××100: %7:(33) sending packet to 60.190.94.84 (I) MM_SI1_WR1, MM_SA_
SETUP
14:1:54:29 ×××100: %7:(33) sending packet to 60.190.94.84 (I) MM_SI1_WR1, MM_SA_
SETUP
14:1:54:29 ×××100: %7:sendout main I1, and wait R1
14:1:54:29 ×××100: %7:Receive IKE message packet.
14:1:54:29 ×××100: %7:(33) received packet from 60.190.94.84, (I) MM_SI1_WR1, MM
_SA_SETUP
14:1:54:29 ×××100: %7: Exchange type : 0x2
14:1:54:29 ×××100: %7:main mode r1 process
14:1:54:29 ×××100: %7:(33) Checking ISAKMP transform 1 against priority 1 policy
14:1:54:29 ×××100: %7: encryption DES-CBC
14:1:54:29 ×××100: %7: hash MD5
14:1:54:29 ×××100: %7: auth pre-share -------policy内容
14:1:54:29 ×××100: %7: group 2
14:1:54:29 ×××100: %7: life type in seconds
14:1:54:29 ×××100: %7:life duration 86400 orginal:86400
14:1:54:29 ×××100: %7:(33) atts are acceptable
14:1:54:29 ×××100: %7:vendor_id=0xaf 0xca 0xd7 0x13 0x68 0xa1 0xf1 0xc9 0x6b 0x8
6 0x96 0xfc 0x77 0x57 0x1 0x0
14:1:54:29 ×××100: %7: dpd's vendor id is detected.
14:1:54:29 ×××100: %7:(33) sending packet to 60.190.94.84 (I) MM_SI2_WR2, MM_KEY
_EXCH
14:1:54:29 ×××100: %7:IKE message packet process over.
14:1:54:29 ×××100: %7:Receive IKE message packet.
14:1:54:29 ×××100: %7:(33) received packet from 60.190.94.84, (I) MM_SI2_WR2, MM
_KEY_EXCH
14:1:54:29 ×××100: %7: Exchange type : 0x2
14:1:54:29 ×××100: %7:main mode process R2:(33) processing NONCE payload.
14:1:54:29 ×××100: %7:(33)main mode process R2:SKEYID state generated
14:1:54:29 ×××100: %7:(33) sending packet to 60.190.94.84 (I) MM_SI3_WR3, MM_VER
IFY
14:1:54:29 ×××100: %7:IKE message packet process over.
14:1:54:29 ×××100: %7:Receive IKE message packet.
14:1:54:29 ×××100: %7:(33) received packet from 60.190.94.84, (I) MM_SI3_WR3, MM
_VERIFY
14:1:54:29 ×××100: %7: Exchange type : 0x2
14:1:54:29 ×××100: %7:(33) (auth pre-share) processing ID payload. message ID =
0
14:1:54:29 ×××100: %7:(33) (auth pre-share) processing HASH payload. message ID
= 0
14:1:54:29 ×××100: %7:(33) (auth pre-share) SA has been authenticated with 60.19
0.94.84
14:1:54:29 ×××100: %7:(main mode)(33) (I)Phase_1 negotiate complete! ---主模式成功建立
14:1:54:29 ×××100: %7:++++++++++++++Fill quick sa's dpd_mode(0).
上面为6个报文来IKE的主模式协商过程
下面开始IKE的快速模式(也就是ipsec sa)的协商过程
14:1:54:29 ×××100: %7:(33) Beginning Quick Mode exchange, M-ID of 2060103392
14:1:54:29 ×××100: %7:(33)(quick mode) sending packet to 60.190.94.84 (I) QM_SI1
_WR1
14:1:54:29 ×××100: %7:IKE message packet process over.
14:1:54:29 ×××100: %7:Receive IKE message packet.
14:1:54:29 ×××100: %7:find phase 2 quick sa!
14:1:54:29 ×××100: %7:(33) (2060103392)received packet from 60.190.94.84, (I) QM
_SI1_WR1
14:1:54:29 ×××100: %7: Exchange type : 0x20
14:1:54:29 ×××100: %7:(quick mode)(isakmp_id---33) process r1:processing SA payl
oad. message ID = 2060103392
14:1:54:29 ×××100: %7: set->lifebak_sec=3600
14:1:54:29 ×××100: %7:(quick_mode)(I)phase 2 sa established,begining to update s
ab!
14:1:54:29 ×××100: %7:+++++++++++++Fill sab' dpd_mode(0)
14:1:54:29 ×××100: %7:add first sab into salink.
14:1:54:29 ×××100: %7: life_seconds=3600
14:1:54:29 ×××100: %7: life_back_seconds=3600
14:1:54:29 ×××100: %7:(quick mode)(isakmp_id---33) sending packet to 60.190.94.8
4 (I) QM_IDLE
14:1:54:29 ×××100: %7:(quick mode)(isakmp_id---33)process r1:Phase_2 negotiate c
omplete!
14:1:54:29 ×××100: %7:ike's tunnel (number=1)established.
14:1:54:29 ×××100: %7:IKE message packet process over.
×××100#debug crypto ipsec ipsec sa的调试信息
14:2:13:16 ×××100: %7:Get acquire: 192.168.16.0/0.0.0.255 -> 192.168.1.0/0.0.0.2
55 , prot 0, port 0/0
14:2:13:16 ×××100: %7:Get acquire: negotiate source 60.190.90.66 -> dest 60.190.
94.84
14:2:13:17 ×××100: %7:(33) Creating IPSec SAs-esp.
14:2:13:17 ×××100: %7: inbound SA has spi 276460337
14:2:13:17 ×××100: %7: protocol esp, DES_CBC
14:2:13:17 ×××100: %7: auth MD5
14:2:13:17 ×××100: %7: fill esp in success!
14:2:13:17 ×××100: %7: outbound SA has spi 38689139
14:2:13:17 ×××100: %7: protocol esp, DES_CBC
14:2:13:17 ×××100: %7: auth MD5
14:2:13:17 ×××100: %7: fill esp out success!
14:2:13:17 ×××100: %7:^I lifetime of 3600 seconds, soft 3570 seconds
14:2:13:17 ×××100: %7:^I lifetime of 4607000 kilobytes, soft 256 kilobytes
14:1:54:29 ×××100: %7:(33) received packet from 60.190.94.84, (I) MM_SI1_WR1, MM
_SA_SETUP
14:1:54:29 ×××100: %7: Exchange type : 0x2
14:1:54:29 ×××100: %7:main mode r1 process
14:1:54:29 ×××100: %7:(33) Checking ISAKMP transform 1 against priority 1 policy
14:1:54:29 ×××100: %7: encryption DES-CBC
14:1:54:29 ×××100: %7: hash MD5
14:1:54:29 ×××100: %7: auth pre-share -------policy内容
14:1:54:29 ×××100: %7: group 2
14:1:54:29 ×××100: %7: life type in seconds
14:1:54:29 ×××100: %7:life duration 86400 orginal:86400
14:1:54:29 ×××100: %7:(33) atts are acceptable
14:1:54:29 ×××100: %7:vendor_id=0xaf 0xca 0xd7 0x13 0x68 0xa1 0xf1 0xc9 0x6b 0x8
6 0x96 0xfc 0x77 0x57 0x1 0x0
14:1:54:29 ×××100: %7: dpd's vendor id is detected.
14:1:54:29 ×××100: %7:(33) sending packet to 60.190.94.84 (I) MM_SI2_WR2, MM_KEY
_EXCH
14:1:54:29 ×××100: %7:IKE message packet process over.
14:1:54:29 ×××100: %7:Receive IKE message packet.
14:1:54:29 ×××100: %7:(33) received packet from 60.190.94.84, (I) MM_SI2_WR2, MM
_KEY_EXCH
14:1:54:29 ×××100: %7: Exchange type : 0x2
14:1:54:29 ×××100: %7:main mode process R2:(33) processing NONCE payload.
14:1:54:29 ×××100: %7:(33)main mode process R2:SKEYID state generated
14:1:54:29 ×××100: %7:(33) sending packet to 60.190.94.84 (I) MM_SI3_WR3, MM_VER
IFY
14:1:54:29 ×××100: %7:IKE message packet process over.
14:1:54:29 ×××100: %7:Receive IKE message packet.
14:1:54:29 ×××100: %7:(33) received packet from 60.190.94.84, (I) MM_SI3_WR3, MM
_VERIFY
14:1:54:29 ×××100: %7: Exchange type : 0x2
14:1:54:29 ×××100: %7:(33) (auth pre-share) processing ID payload. message ID =
0
14:1:54:29 ×××100: %7:(33) (auth pre-share) processing HASH payload. message ID
= 0
14:1:54:29 ×××100: %7:(33) (auth pre-share) SA has been authenticated with 60.19
0.94.84
14:1:54:29 ×××100: %7:(main mode)(33) (I)Phase_1 negotiate complete! ---主模式成功建立
14:1:54:29 ×××100: %7:++++++++++++++Fill quick sa's dpd_mode(0).
上面为6个报文来IKE的主模式协商过程
下面开始IKE的快速模式(也就是ipsec sa)的协商过程
14:1:54:29 ×××100: %7:(33) Beginning Quick Mode exchange, M-ID of 2060103392
14:1:54:29 ×××100: %7:(33)(quick mode) sending packet to 60.190.94.84 (I) QM_SI1
_WR1
14:1:54:29 ×××100: %7:IKE message packet process over.
14:1:54:29 ×××100: %7:Receive IKE message packet.
14:1:54:29 ×××100: %7:find phase 2 quick sa!
14:1:54:29 ×××100: %7:(33) (2060103392)received packet from 60.190.94.84, (I) QM
_SI1_WR1
14:1:54:29 ×××100: %7: Exchange type : 0x20
14:1:54:29 ×××100: %7:(quick mode)(isakmp_id---33) process r1:processing SA payl
oad. message ID = 2060103392
14:1:54:29 ×××100: %7: set->lifebak_sec=3600
14:1:54:29 ×××100: %7:(quick_mode)(I)phase 2 sa established,begining to update s
ab!
14:1:54:29 ×××100: %7:+++++++++++++Fill sab' dpd_mode(0)
14:1:54:29 ×××100: %7:add first sab into salink.
14:1:54:29 ×××100: %7: life_seconds=3600
14:1:54:29 ×××100: %7: life_back_seconds=3600
14:1:54:29 ×××100: %7:(quick mode)(isakmp_id---33) sending packet to 60.190.94.8
4 (I) QM_IDLE
14:1:54:29 ×××100: %7:(quick mode)(isakmp_id---33)process r1:Phase_2 negotiate c
omplete!
14:1:54:29 ×××100: %7:ike's tunnel (number=1)established.
14:1:54:29 ×××100: %7:IKE message packet process over.
×××100#debug crypto ipsec ipsec sa的调试信息
14:2:13:16 ×××100: %7:Get acquire: 192.168.16.0/0.0.0.255 -> 192.168.1.0/0.0.0.2
55 , prot 0, port 0/0
14:2:13:16 ×××100: %7:Get acquire: negotiate source 60.190.90.66 -> dest 60.190.
94.84
14:2:13:17 ×××100: %7:(33) Creating IPSec SAs-esp.
14:2:13:17 ×××100: %7: inbound SA has spi 276460337
14:2:13:17 ×××100: %7: protocol esp, DES_CBC
14:2:13:17 ×××100: %7: auth MD5
14:2:13:17 ×××100: %7: fill esp in success!
14:2:13:17 ×××100: %7: outbound SA has spi 38689139
14:2:13:17 ×××100: %7: protocol esp, DES_CBC
14:2:13:17 ×××100: %7: auth MD5
14:2:13:17 ×××100: %7: fill esp out success!
14:2:13:17 ×××100: %7:^I lifetime of 3600 seconds, soft 3570 seconds
14:2:13:17 ×××100: %7:^I lifetime of 4607000 kilobytes, soft 256 kilobytes
下面命令可以看到isakmp sa已经建立:
×××100#sh crypto isakmp sa
destination source state conn-id
lifetime(second)
60.190.94.84 60.190.90.66 QM_IDLE 33
86323
bc2ea01385f769db 7017b83ac843c486
IPSEC SA也已经成功建立
RouterA#show crypto ipsec sa
Interface:Fastethernet 1/0
Crypto map tag:mymap, local addr 60.190.90.66
(目前的加密映射集名mymap,使用本地地址60.190.90.66)
media mtu 1500
local ident (addr/mask/prot/port): (192.168.16.0/0.0.0.255/0/0))
remote ident (addr/mask/prot/port): (192.168.1.0/0.0.0.255/0/0))
PERMIT
(保护192.168.16.0/24和192.168.1.0/24之间的通信)
current_peer: 60.190.94.84
(对方对等体地址为60.190.94.84)
#pkts encaps: 3, #pkts encrypt: 3, #pkts digest 3
#pkts decaps: 3, #pkts decrypt: 3, #pkts verify 3
#send errors 0, #recv errors 0
(统计数据,依次为:封装包数,加密包数,摘要包数,拆封包数,加密包数,验证包数,发送错误,接收错误)
inbound esp sas: (进入包处理的安全联盟,协议为ESP)
spi:0x43D3C7 (4445127)(spi的值为4445127)
transform: esp-des esp-md5-hmac(变换集合为esp-des-md5)
in use settings={Tunnel,} (通道模式)
sa timing: remaining key lifetime (k/sec): (4607999/3578)
(离安全联盟的生命周期到期还有:4607999千字节/3578秒)
IV size: 8 bytes(IV向量长度为8)
Replay detection support:Y(抗重播处理)
outbound esp sas: (外出包处理的安全联盟,协议为ESP)
spi:0x106A0DFA (275385850) (spi的值为275385850)
transform: esp-des esp-md5-hmac(变换集合为esp-des-md5)
in use settings={Tunnel,} (通道模式)
sa timing: remaining key lifetime (k/sec): (4607999/3577)
(离安全联盟的生命周期到期还有:4607999千字节/3577秒)
IV size: 8 bytes(IV向量长度为8)
Replay detection support:Y(抗重播处理)
从统计数据可以看出,IPSec已经建立起来并有数据报得到保护
到此,×××就已经成功建立了。
RouterA#show crypto ipsec sa
Interface:Fastethernet 1/0
Crypto map tag:mymap, local addr 60.190.90.66
(目前的加密映射集名mymap,使用本地地址60.190.90.66)
media mtu 1500
local ident (addr/mask/prot/port): (192.168.16.0/0.0.0.255/0/0))
remote ident (addr/mask/prot/port): (192.168.1.0/0.0.0.255/0/0))
PERMIT
(保护192.168.16.0/24和192.168.1.0/24之间的通信)
current_peer: 60.190.94.84
(对方对等体地址为60.190.94.84)
#pkts encaps: 3, #pkts encrypt: 3, #pkts digest 3
#pkts decaps: 3, #pkts decrypt: 3, #pkts verify 3
#send errors 0, #recv errors 0
(统计数据,依次为:封装包数,加密包数,摘要包数,拆封包数,加密包数,验证包数,发送错误,接收错误)
inbound esp sas: (进入包处理的安全联盟,协议为ESP)
spi:0x43D3C7 (4445127)(spi的值为4445127)
transform: esp-des esp-md5-hmac(变换集合为esp-des-md5)
in use settings={Tunnel,} (通道模式)
sa timing: remaining key lifetime (k/sec): (4607999/3578)
(离安全联盟的生命周期到期还有:4607999千字节/3578秒)
IV size: 8 bytes(IV向量长度为8)
Replay detection support:Y(抗重播处理)
outbound esp sas: (外出包处理的安全联盟,协议为ESP)
spi:0x106A0DFA (275385850) (spi的值为275385850)
transform: esp-des esp-md5-hmac(变换集合为esp-des-md5)
in use settings={Tunnel,} (通道模式)
sa timing: remaining key lifetime (k/sec): (4607999/3577)
(离安全联盟的生命周期到期还有:4607999千字节/3577秒)
IV size: 8 bytes(IV向量长度为8)
Replay detection support:Y(抗重播处理)
从统计数据可以看出,IPSec已经建立起来并有数据报得到保护
到此,×××就已经成功建立了。
常见问题:
1. 现象:一端发起协商后,另一端没有任何响应。
可能的原因:
ü 检查发起协商的数据流是否匹配所定义的要保护的数据流;
ü 检查路由器上是否有默认路由或者到远端局域网段的路由;
ü 检查加密映射(map)是否已经应用到接口上去;
ü 检查两端的peer地址是否配置正确,确保两个×××网关本身能够互通;
ü 检查预共享密钥是否已经配置;
1. 现象:一端发起协商后,另一端没有任何响应。
可能的原因:
ü 检查发起协商的数据流是否匹配所定义的要保护的数据流;
ü 检查路由器上是否有默认路由或者到远端局域网段的路由;
ü 检查加密映射(map)是否已经应用到接口上去;
ü 检查两端的peer地址是否配置正确,确保两个×××网关本身能够互通;
ü 检查预共享密钥是否已经配置;
2. 现象:IKE SA(又称第一阶段主模式)协商不成功
可能的原因:
ü 检查两端是否有一致的policy,如果规划使用预共享认证方式,确保双方一致的policy中的认证方式为预共享;
ü 预共享密钥是否配置是否一致;
可能的原因:
ü 检查两端是否有一致的policy,如果规划使用预共享认证方式,确保双方一致的policy中的认证方式为预共享;
ü 预共享密钥是否配置是否一致;
3. 现象:IKE SA协商成功了,但是快速模式协商不成功,IPSec SA无法建立
可能的原因:
ü 两端的是否有一致的变化集合;
ü 两端的所要保护的数据流是否相对应;
ü 两端的完美前向保护参数(pfs)是否一致;
可能的原因:
ü 两端的是否有一致的变化集合;
ü 两端的所要保护的数据流是否相对应;
ü 两端的完美前向保护参数(pfs)是否一致;
4. 现象:IPSec SA已经建立成功,但是两边的局域网中两台主机不通。
可能的原因:(这时候已经与IPSec本身没有多大关系了)
ü 主机上是否已经配置网关,该网关指向路由器的一个接口;
ü 检查两台主机上是否启用了防火墙过滤之类的软件;
ü 数据流在Internet上是否已经穿越了NAT(基本可以从路由器出口的地址是否为公网地址来确定)
可能的原因:(这时候已经与IPSec本身没有多大关系了)
ü 主机上是否已经配置网关,该网关指向路由器的一个接口;
ü 检查两台主机上是否启用了防火墙过滤之类的软件;
ü 数据流在Internet上是否已经穿越了NAT(基本可以从路由器出口的地址是否为公网地址来确定)
第二章 动态对等体
动态获取IP端路由器配置与上面固定IP的一致。
主要是在固定IP端路由器配置部分不同:
!配置默认的预共享密钥,由于对端的ip地址是动态的,不能预先知道需要配置默认的 预共享密钥
crypto isakmp key 123456 address 0.0.0.0 0.0.0.0
crypto isakmp key 123456 address 0.0.0.0 0.0.0.0
!定义动态加密映射
crypto dynamic-map dymymap 1
这部分不需要配置set peer ip-address 因为不能预知对方IP
crypto dynamic-map dymymap 1
这部分不需要配置set peer ip-address 因为不能预知对方IP
添加一个动态的加密映射集到静态的加密映射集
crypto map mymap 10 ipsec-isakmp dynamic dymymap
再把这个静态map的名字应用到接口,非应用动态map的名字,切记。
crypto map mymap 10 ipsec-isakmp dynamic dymymap
再把这个静态map的名字应用到接口,非应用动态map的名字,切记。
IPsec ×××
R1:
conf t
in fa0/0
ip add 170.58.12.1 255.255.255.0
no sh
in lo0
ip add 1.1.1.1 255.255.255.0
exit
ip route 0.0.0.0 0.0.0.0 170.58.12.2
crypto isakmp policy 10
encr 3des
hash md5
authentication pre-share
group 2
exit
crypto isakmp key cisco address 170.58.23.3
crypto ipsec transform-set zhang esp-3des esp-md5-hmac
exit
crypto map wang 10 ipsec-isakmp
set peer 170.58.23.3
set transform-set zhang
match address ***
exit
ip access-list extended ***
permit ip host 1.1.1.1 host 3.3.3.3
exit
in fa0/0
cry map wang
exit
R2:
conf t
in fa0/0
ip add 170.58.12.2 255.255.255.0
no sh
in fa0/1
ip add 170.58.23.2 255.255.255.0
no sh
exit
R3:
conf t
in fa0/1
ip add 170.58.23.3 255.255.255.0
no sh
in lo0
ip add 3.3.3.3 255.255.255.0
exit
ip route 0.0.0.0 0.0.0.0 170.58.23.2
crypto isakmp policy 10
encr 3des
hash md5
authentication pre-share
group 2
exit
crypto isakmp key cisco address 170.58.12.1
crypto ipsec transform-set zhang esp-3des esp-md5-hmac
exit
crypto map wang 10 ipsec-isakmp
set peer 170.58.12.1
set transform-set zhang
match address ***
exit
ip access-list extended ***
permit ip host 3.3.3.3 host 1.1.1.1
exit
in fa0/1
cry map wang
exit
in fa0/1
ip add 170.58.23.3 255.255.255.0
no sh
in lo0
ip add 3.3.3.3 255.255.255.0
exit
ip route 0.0.0.0 0.0.0.0 170.58.23.2
crypto isakmp policy 10
encr 3des
hash md5
authentication pre-share
group 2
exit
crypto isakmp key cisco address 170.58.12.1
crypto ipsec transform-set zhang esp-3des esp-md5-hmac
exit
crypto map wang 10 ipsec-isakmp
set peer 170.58.12.1
set transform-set zhang
match address ***
exit
ip access-list extended ***
permit ip host 3.3.3.3 host 1.1.1.1
exit
in fa0/1
cry map wang
exit