资源描述
CCIE R&S v4.0 理论
IPSec VPN
目录
隧道技术
举例
手动点对点GRE
IPSec
VPN分类
IPSec特征
加密
术语
加密算法
数字签名
IPSec安全协议
验证报头(AH)
封装安全有效负载(ESP)
密钥管理和安全关联
IPSec分组的处理
配置步骤总结
各类IPSec范畴VPN
普通LAN_to_LAN VPN
Dynamic LAN_to_LAN VPN
Dynamic Multipoint VPN (DMVPN)
Easy VPN (EzVPN) 又名远程VPN或接入VPN
SSL VPN
隧道技术
图1:
如上图所示,在普通情况下,穿越了公网的两个LAN的PC,是无法直接通过输入对方LAN的内网IP地址进行访问的,无法解决公司的某些办公问题和数据访问问题。
图2:
如上图所示,如果两个LAN的路由器是直接相连,那么任何PC都可以直接输入对方LAN的内网IP地址进行访问,解决公司的办公和数据访问等任何问题。
但是LAN和LAN之间,有时因为距离问题或成本问题,无法做到直接相连路由器,必须得穿越公网,这样就无法解决上述的访问需求,要解决此类问题,可通过隧道技术,对IP包头重新封装,保留内网地址同时对ISP隐藏,待穿越了ISP之后,到达目标LAN路由器,再还原IP包头,此时再查看最初的目的IP(即内网IP)。
如下图:
返回目录
举例
返回目录
手动点对点GRE
通过手动Tunnel来解决远程LAN之间使用内网地址互访:
返回目录
IPSec
在穿越了公网的LAN需要直接使用内网地址访问对端PC时,可通过隧道技术来解决,而且隧道技术是当前解决此问题的唯一方法,隧道技术可在OSI二层的三层实施,隧道技术,正是VPN技术。
然而,由于LAN与LAN之间传输的数据带有私密性,有时必须考虑到数据的安全性,需要对数据进行加密后再传输。所以在隧道技术VPN的环境下,最好能够在隧道中集成加密技术。
而IPSec,正是在这种需求下诞生的,IPSec就同时集成了隧道技术和加密技术,称为IPSec VPN,而IPSec,是定义隧道如何实现,加密如何实施,是一系列框架的总结,IPSec并非一个单纯的协议。
返回目录
VPN分类
二层VPN
递送报头在二层,如:ATM,帧中继
三层VPN
递送报头在三层,如:GRE,MPLS,IPSec
GRE(通用路由选择封装)由Cisco开发,并被标准化,但没有安全机制。
MPLS VPN,也是Cisco倡导的,也被IETF标准化。
IPSec VPN
用户关心数据安全性,IPSec是IETF开发的一组协议,支持身份验证,完整性,访问控制和机密性。
在普通情况下,两个LAN之间建立隧道的VPN,称为LAN_to_LAN VPN,
VPN另一方预先不知道的,可使用远程接入VPN,称为easy VPN (EzVPN)。
返回目录
IPSec特征
安全协议:验证报头(AH),封装安全有效负载(ESP)
密钥管理:ISAKMP , IKE , SKEME
算法:用于加密和身份验证
返回目录
加密
以往的字母替换法。
返回目录
术语
返回目录
加密算法
加密和解密的数学函数,数据安全是建立在密钥基础上的,知道算法没关系,没有密钥没用。
加密算法分:对称加密算法和非对称加密算法。
对称加密算法:发送方和接收方使用相同的密钥,使用什么加密,就使用什么解密,所以要有好的方法分发密钥,要不然被截取,依然不安全,常见算法有:DES,3DES,AES.
DES 56位,不推荐,24小时内可枚举破解。
非对称加密算法:也叫公钥算法,用两个密钥,加密的叫公钥,可以公开,解密的是私钥,在数学上是相关的,但无法推导。任何有公钥的人都可以加密,但只有有私钥的人才能解密,而私钥只有接受方才知道,可以不传出去。
公钥算法没有完全取代对称算法,只是用作他们的密钥分发,因为自己慢,所以不会取代对称加密,只是他们的补充。
返回目录
数字签名
公钥加密可以用来验证消息,叫做数字签名,有不可抵赖性,思想是将变长的消息转换成定长的压缩输出-消息摘要,根据消息摘要无法重建原始消息。
过程:
要发文件给对方,先计算一个摘要,然后公钥对摘要进行加密变成数字签名,将文件和签名一起发过去,如果对方根据文件计算出的摘要与原有不符,便认为被改过.
对消息摘要进行加密,称为加密的消息摘要,或叫消息验证码(HMAC) (HASH)
返回目录
IPSec安全协议
IPSec提供访问控制,数据完整性,身份验证,防止重放和数据机密性。
安全协议有:验证报头(AH),封装安全有效负载(ESP),为IP数据提供安全。
有两种模式,传输模式和隧道模式。
传输模式:
在IP报头和高层协议报头之间插入一个IPSec报头(AH或ESP),IPSec报头和数据都有加密验证,认为目的地是可达的,所以源不会修改目标IP地址,只能用于IP端点和IPSec端点相同的情形。(比如就是两个点之间直接给自己使用VPN,而不是给别人使用)
所以传输模式不能进行NAT转换。
隧道模式:
保留原始IP报头,写入新报头,并加密其它。
返回目录
验证报头(AH)
提供数据完整性,身份验证,防止重放,但没有机密性。
它是一种IP协议,位置同ESP。
返回目录
封装安全有效负载(ESP)
提供数据完整性,身份验证,防止重放和数据机密性,将原始的加密后封装在报头和报尾,保护IP分组。
返回目录
密钥管理和安全关联
加密算法用的最多的是DES和3DES,所以要解决分发问题。生成,分发和存储统称为密钥管理, 下面Internet密钥交换(IKE)协议就是协商密钥的。
SA(安全关联)
(IKE)ISAKMP
在IOS上配置IKE:
crypto isakmp policy 10
encr 3des
hash md5
authentication pre-share
group 2
加密算法包括:DES,3DES,AES
验证方法有4种:预共享密钥(最多),数字签名(最多),2次公钥加密和4次公钥加密。
预共享密钥必须双方一致,
数字签名验证时,IOS只支持RSA,要用证书。
返回目录
IPSec分组的处理
安全策略数据库(SPD)
安全关联数据库(SADB)
安全策略数据库(SPD)决定了如何处理对等体之间的IP数据流
安全关联数据库(SADB)包含每个活动安全关联参数
安全策略数据库(SPD)包含:目标IP,源IP,名称,数据敏感性等级,传输层协议,源和目标端口。
安全关联数据库(SADB),每个条目都宣言了一个SA,有关以下参数:
序列号,序列号溢出,反重放窗口,SA寿命,
模式:传输还是隧道
AH验证算法:MD5还是SHA
ESP验证算法:MD5还是SHA
ESP加密算法:DES,3DES
查看SA:sh cry ipsec sa
配置加密算法和封装方法(还可定义模式):
crypto ipsec transform-set xxx esp-3des esp-sha-hmac
使用安全协议ESP,用3DES来加密,用sha-hmac来确保数据完整性,使用隧道模式来封装(默认),
查看使用:sh cry ipsec transform-set
看IKE协商
sh cry isakmp policy
配置:
authentication pre-share
group 2 (默认组1,就是IKE相关算法)
配置密钥:
crypto isakmp key cisco123 address 23.1.1.3
查看:sh cry isakmp sa
返回目录
配置步骤总结
一:ISAKMP SA步骤:
1.定义IKE(Internet密钥交换),即ISAKMP
2.配置密钥
3.配置加密和封装
二:IPSec SA步骤:
1.创建邻居
2.调用ISAKMP的加密和封装
3.定义要穿越VPN的流量
三:应用IPSec SA到接口
返回目录
各类IPSec范畴VPN
返回目录
1. 普通LAN_to_LAN VPN
此类VPN,即两个穿越了ISP的LAN之间建立VPN连接,为其内网PC与远程LAN的PC直接通过内网IP进行互访。
配置:
一:ISAKMP SA步骤:
1.定义IKE(Internet密钥交换),即ISAKMP
router(config)#crypto isakmp policy 1
router(config-isakmp)#encryption 3des
router(config-isakmp)#hash md5
router(config-isakmp)#authentication pre-share
router(config-isakmp)#group 2
router(config-isakmp)#exit
2.配置密钥
router(config)#crypto isakmp key 0 cisco123 address 12.1.1.1
3.配置加密和封装
router(config)#crypto ipsec transform-set abc esp-3des esp-md5-hmac
router(cfg-crypto-trans)#exit
二:IPSec SA步骤:
router(config)#access-list 100 permit ip 192.168.1.0 0.0.0.255 10.1.1.0 0.0.0.255
router(config)#crypto map vpn 1 ipsec-isakmp
1.创建邻居
router(config-crypto-map)#set peer 12.1.1.1
2.调用ISAKMP的加密和封装
router(config-crypto-map)#set transform-set abc
3.定义要穿越VPN的流量
router(config-crypto-map)#mat address 100
router(config-crypto-map)#exit
三:应用IPSec SA到接口
router(config)#int f0/0
router(config-if)#crypto map vpn
router(config-if)#exit
返回目录
2.Dynamic LAN_to_LAN VPN
此类VPN,用于当需要建立VPN的LAN多于两个,需要在多个场点之间建立连接,可能有的场点IP地址不固定,使用了DHCP服务。那么,在多个LAN之间建立LAN_to_LAN VPN时,其中一方必须固定IP地址,但其它均可浮动IP地址,只要保证两点之间,一方能够找到另一方即可。之前普通LAN_to_LAN VPN的某些规则在此便不适用,因为对端LAN是浮动IP时,本端无法为明确的对端配置预共享密钥,只能对任意IP配置。
此类VPN,需要调用一个组的概念,而密钥和对端0.0.0.0的IP均是在组下完成。并且将该组与加密和封装做好动态组映射,集成到IPSec SA中,最后应用到接口下:
HUB端:
配置:
HUB端(固定的IP地址):
一:ISAKMP SA步骤:
1.定义IKE(Internet密钥交换),即ISAKMP
router(config)#crypto isakmp policy 10
router(config-isakmp)#encryption 3des
router(config-isakmp)#hash md5
router(config-isakmp)#authentication pre-share
router(config-isakmp)#group 2
router(config-isakmp)#exi
2.配置密钥
router(config)#crypto keyring spokes
router(conf-keyring)#pre-shared-key address 0.0.0.0 0.0.0.0 key 0 cisco123
router(conf-keyring)#exi
3.配置加密和封装
router(config)#crypto ipsec transform-set myset esp-3des esp-md5-hmac
router(cfg-crypto-trans)#exi
Dynamic部分
1.将邻居和密钥映射成动态框架
router(config)#crypto isakmp profile l2l
router(conf-isa-prof)#keyring spokes
router(conf-isa-prof)#mat identity address 0.0.0.0
router(conf-isa-prof)#exi
2.创建动态组(集合动态框架和加密封装方法)
router(config)#crypto dynamic-map mmm 5
router(config-crypto-map)#set transform-set myset
router(config-crypto-map)#set isakmp-profile l2l
router(config-crypto-map)#exit
二:IPSec SA步骤:
router(config)#crypto map vpn 10 ipsec-isakmp dynamic mmm
三:应用IPSec SA到接口
router(config)#int s0/0
router(config-if)#crypto map vpn
router(config-if)#exit
Spoke端(浮动的IP地址):
配置同普通LAN_to_LAN VPN
一:ISAKMP SA步骤:
1.定义IKE(Internet密钥交换),即ISAKMP
router(config)#crypto isakmp policy 1
router(config-isakmp)#encryption 3des
router(config-isakmp)#hash md5
router(config-isakmp)#authentication pre-share
router(config-isakmp)#group 2
router(config-isakmp)#exit
2.配置密钥
router(config)#crypto isakmp key 0 cisco123 address 12.1.1.1
3.配置加密和封装
router(config)#crypto ipsec transform-set abc esp-3des esp-md5-hmac
router(cfg-crypto-trans)#exit
二:IPSec SA步骤:
router(config)#access-list 100 permit ip 192.168.1.0 0.0.0.255 10.1.1.0 0.0.0.255
router(config)#crypto map vpn 1 ipsec-isakmp
1.创建邻居
router(config-crypto-map)#set peer 12.1.1.1
2.调用ISAKMP的加密和封装
router(config-crypto-map)#set transform-set abc
3.定义要穿越VPN的流量
router(config-crypto-map)#mat address 100
router(config-crypto-map)#exit
三:应用IPSec SA到接口
router(config)#int f0/0
router(config-if)#crypto map vpn
router(config-if)#exit
返回目录
3. Dynamic Multipoint VPN (DMVPN)
背景:
多点GRE
Next Hop Resolution Protocol (NHRP)
配置:
HUB端配置
interface Tunnel0
ip address 66.6.6.1 255.255.255.0
ip mtu 1440
ip nhrp authentication cisco123 双方必须相同
ip nhrp map multicast dynamic 没有这条,用组播的路由协议无法建立
ip nhrp network-id 100 双方标识符
ip ospf network point-to-multipoint
tunnel source Serial1/1
tunnel mode gre multipoint
tunnel key 0
tunnel protection ipsec profile cisco
crypto isakmp policy 10
en 3des
hash md5
authentication pre-share
group 2
crypto isakmp key cisco123 address 0.0.0.0 0.0.0.0
crypto ipsec transform-set strong esp-3des esp-md5-hmac
crypto ipsec profile cisco
set security-association lifetime seconds 120
set transform-set strong
interface Tunnel0
tunnel protection ipsec profile cisco
Spoke配置
interface Tunnel0
ip address 66.6.6.3 255.255.255.0
ip mtu 1440
ip nhrp authentication cisco123
ip nhrp map multicast dynamic
ip nhrp map 66.6.6.1 12.1.1.1 向12.1.1.1去请求GRE并注册
ip nhrp map multicast 12.1.1.1 没有这条,用组播的路由协议无法建立
ip nhrp network-id 100
ip nhrp nhs 66.6.6.1 配置下一跳服务器
ip ospf network point-to-multipoint
tunnel source FastEthernet0/0
tunnel mode gre multipoint
tunnel key 0
tunnel protection ipsec profile cisco
crypto isakmp policy 10
en 3des
hash md5
authentication pre-share
group 2
crypto isakmp key cisco123 address 0.0.0.0 0.0.0.0
crypto ipsec transform-set strong esp-3des esp-md5-hmac
crypto ipsec profile cisco
set security-association lifetime seconds 120 维护SA状态的时间,默认一小时
set transform-set strong
interface Tunnel0
tunnel protection ipsec profile cisco
查看命令:
Show ip protocol 查看NHRP
show ip nhrp brief
show ip nhrp
IPSec查看:
show crypto isakmp sa
show crypto isakmp peers
show crypto session
show crypto ipsec sa 只能看到对端,不能看到后面LAN
额外补充:
默认情况下,CDP不开,在tunnel下是看不到对端的
但在spoke情况下,最好在外网接口不开CDP,因为开了,运行ODR时,会把外网地址发过去,然后HUB就会从tunnel到该外网地址,可tunnel是依靠外网地址的,成为死循环。
返回目录
4. Easy VPN (EzVPN) 又名远程VPN或接入VPN
此类VPN可使用传输模式,突破NAT限制。
配置:
Server配置
aaa authentication login hyhy local
aaa authorization network abc local
username aaa password bbb
crypto isakmp policy 1
en 3des
hash md5
authentication pre-share
group 2
crypto isakmp client configuration group ghd
key cisco
domain
pool ccie
acl 111
crypto ipsec transform-set ttt esp-des esp-md5-hmac
ip local pool ccie 10.10.10.10 10.10.10.20
access-list 111 permit ip any any
有类似DynamicVPN的部分
创建动态组(集合动态框架和加密封装方法)
crypto dynamic-map jiaojiao 1
set transform-set ttt
reverse-route
IPSec SA步骤:
crypto map vpn client authentication list hyhy
crypto map vpn isakmp authorization list abc
crypto map vpn client configuration address respond
crypto map vpn 1 ipsec-isakmp dynamic jiaojiao
interface Serial0/0
crypto map vpn
返回目录
5. SSL VPN
EzVPN在拨入时,PC需要安装client软件,通过软件来认证,SSL VPN 则省略PC安装client软件的过程,认证过程采用登陆网页的方式来认证,但须支持java。
配置:
开AAA
router(config)#aaa authentication login default local
router(config)#aaa authentication login ssl local
router(config)#username aaa password bbb
上传软件:
router#format flash:
Format operation may take a while. Continue? [confirm]
Format operation will destroy all data in "flash:". Continue? [confirm]
Current Low End File System flash card in flash: will be formatted into DOS File System flash card! Continue? [confirm]
Primary Partition created...Size 16 MB
Drive communication & 1st Sector Write OK...
Writing Monlib sectors....
Monlib write complete
Format: All system sectors written. OK...
Format: Total sectors in formatted partition: 32736
Format: Total bytes in formatted partition: 16760832
Format: Operation completed successfully.
Format of flash: complete
router#copy ftp: flash:
Address or name of remote host []? 200.1.1.2
Source filename []? sslclient.pkg
Destination filename [sslclient.pkg]?
Accessing ftp://200.1.1.2/sslclient.pkg...
Loading sslclient.pkg !!!!!!!!!
[OK - 2208871/4096 bytes]
2208871 bytes copied in 196.552 secs (11238 bytes/sec)
router#
安装软件:
router(config)#webvpn install svc flash:sslclient.pkg
SSLVPN Package SSL-VPN-Client : installed successfully
router(config)#ip local pool hehe 80.1.1.10 80.1.1.100
router(config)#int loopback 0
router(config-if)#ip add 80.1.1.1 255.255.255.0
router(config-if)#exi
定义WebVPN认证方法
定义WebVPN在哪个接口上进行监听,此时IOS会自动产生自签名证书。
router(config)#webvpn gateway good
router(config-webvpn-gateway)#ip address 211.1.1.1 port 443
router(config-webvpn-gateway)#inservice
router(config-webvpn-gateway)#exi
router(config)#webvpn context goodtt
router(config-webvpn-context)#gateway good domain group1
router(config-webvpn-context)#aaa authentication list ssl
router(config-webvpn-context)#inservice
router(config-webvpn-context)#policy group context1-policy
router(config-webvpn-group)#functions svc-enabled
router(config-webvpn-group)#svc address-pool hehe
router(config-webvpn-group)#exi
router(config-webvpn-context)#default-group-policy context1-policy
router(config-webvpn-context)#exi
测试
在浏览器中输入https://198.1.1.1/group1访问WebVPN。
注:本人能力有限,如遇不足之处,还请指正!
展开阅读全文