一、IPSEC的原理

1、IPsec是什么?
IPsec是给IP和上层协议提供安全的IP协议扩展。最初是为IPv6标准而开发的,后来返过来又支持IPv4。RFC2401描述了IPsec的体系。下面简单介绍一下IPsec。
IPsec使用两个不同的协议——AH和ESP来确保通信的认证、完整性和机密性。它既可以保护整个IP数据报也可以只保护上层协议。适当的模式称为:隧道模式和传送模式。在隧道模式下,IP数据报被IPsec协议完全加密成新的数据报;在传送模式下,仅仅是有效负荷被IPsec协议将IPsec头插入IP头和上层协议头之间来搬运。

2、IPsec的工作模式

IPsec有两种模式—─传输模式和隧道模式。传输模式只对IP分组应用IPsec协议,对IP报头不进行任何修改,它只能应用于主机对主机的IPsec虚拟专用网×××中。隧道模式中IPsec将原有的IP分组封装成带有新的IP报头的IPsec分组,这样原有的IP分组就被有效地隐藏起来了。隧道主要应用于主机到网关的远程接入的情况。

注: IPsec协议中有两点是我们所关心的:鉴定报头AH(Authentication Header)和封装安全载荷ESP(Encapsulation Security Payload)。

3、IPSec的安全特性
·不可否认性 \"不可否认性\"可以证实消息发送方是唯一可能的发送者,发送者不能否认发送过消息。\"不可否认性\"是采用公钥技术的一个特征,当使用公钥技术时,发送方用私钥产生一个数字签名随消息一起发送,接收方用发送者的公钥来验证数字签名。由于在理论上只有发送者才唯一拥有私钥,也只有发送者才可能产生该数字签名,所以只要数字签名通过验证,发送者就不能否认曾发送过该消息。但\"不可否认性\"不是基于认证的共享密钥技术的特征,因为在基于认证的共享密钥技术中,发送方和接收方掌握相同的密钥。
·反重播性 \"反重播\"确保每个IP包的唯一性,保证信息万一被截取复制后,不能再被重新利用、重新传输回目的地址。该特性可以防止***者截取破译信息,再用相同的信息包冒取非法访问权(即使这种冒取行为发生在数月之后)?
·数据完整性 防止传输过程中数据被篡改,确保发出数据和接收数据的一致性。IPSec利用Hash函数为每个数据包产生一个加密检查和,接收方在打开包前先计算检查和,若包遭篡改导致检查和不相符,数据包即被丢弃。
·数据可靠性(加密) 在传输前,对数据进行加密,可以保证在传输过程中,即使数据包遭截取,信息也无法被读。该特性在IPSec中为可选项,与IPSec策略的具体设置相关。
·认证 数据源发送信任状,由接收方验证信任状的合法性,只有通过认证的系统才可以建立通信连接。

二.案例

1.实验拓扑图

wps_clip_image-23932

2.实验环境说明
设备:3台华为路由器 quidway2600series,1台华为防火墙 f100c
Pc1、R2的lo1和R3的lo1 跨Internet 网络,采用*** 隧道方式进行通信。路由器R14, R2和R3 为***隧道的三个端点,在R14和R2间建立***通道,R14和R3之间建立***通道,实现R14和R2,R14和R3之间互通。
3.实验步骤
R14配置:
接口配置
[R14]interface Ethernet0
[R14-Ethernet0]ip address 1.1.1.1 255.255.255.252

[R14-Ethernet0]interface Ethernet1
[R14-Ethernet1]ip address 192.168.1.1 255.255.255.0

创建访问列表

[R14]ike pre-shared-key qazwsx remote 1.1.3.1
[R14]ike pre-shared-key abcdefg remote 1.1.2.1
[R14]acl 3000 match-order auto
[R14-acl-3000]rule normal permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
[R14-acl-3000]rule normal deny ip source any destination any

acl 3001 match-order auto
[R14-acl-3000]rule normal permit ip source 192.168.1.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
[R14-acl-3000]rule normal deny ip source any destination any

分别创建名为tran1、tran2的安全提议

[R14]ipsec proposal tran1
[R14]ipsec proposal tran2

创建一条安全策略,协商方式为isakmp

[R14]ipsec policy policy1 10 isakmp

引用访问列表

[R14-ipsec-policy-policy1-10]security acl 3000

引用安全提议

[R14-ipsec-policy-policy1-10]proposal tran1

设置末端地址

[R14-ipsec-policy-policy1-10]tunnel remote 1.1.2.1

创建另一条安全策略,及相关配置

[R14-ipsec-policy-policy1-10]ipsec policy 1 11 isakmp
[R14-ipsec-policy-policy1-10]security acl 3001
[R14-ipsec-policy-policy1-10]proposal tran2
[R14-ipsec-policy-policy1-10]tunnel remote 1.1.3.1

使用IKE 协商方式,并配置IKE 预设认证字

[R14]ike pre-shared-key qazwsx remote 1.1.3.1
[R14]ike pre-shared-key abcdefg remote 1.1.2.1

在串口上应用安全策略组

[R14]interface Ethernet0

[R14-Ethernet0]ipsec policy 1

[R14]ip route-static 0.0.0.0 0.0.0.0 1.1.1.2 preference 60 默认路由

R2配置:
接口配置

[R2]interface Ethernet0
[R2-Ethernet0]ip address 1.1.2.1 255.255.255.252
[R2-Ethernet0]interface LoopBack1
[R2-LoopBack1]ip address 192.168.2.1 255.255.255.0
使用ike协商方式,并使用IKE预设认证字

[R2]ike pre-shared-key abcdefg remote 1.1.1.1

创建访问列表

[R2]acl 3000 match-order auto
[R2-acl-3000]rule normal permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
[R2-acl-3000]rule normal deny ip source any destination any

创建名为tran1的安全提议

[R2]ipsec proposal tran1

创建一条安全策略,协商方式为isakmp

[R2]ipsec policy policy2 10 isakmp

引用访问列表

[R14-ipsec-policy-policy2-10]security acl 3000

引用安全提议

[R14-ipsec-policy-policy2-10]proposal tran2

设置末端地址

[R14-ipsec-policy-policy2-10]tunnel remote 1.1.1.1

在串口上应用安全策略组

[R2]interface Ethernet0
[R2-Ethernet0]ipsec policy 2

[R2]ip route-static 0.0.0.0 0.0.0.0 1.1.2.2 preference 60 默认路由

R3配置

接口配置

[R3]interface Ethernet0
[R3-Ethernet0]ip address 1.1.3.1 255.255.255.252
[R3-Ethernet0]interface LoopBack1
[R3-LoopBack1]ip address 192.168.3.1 255.255.255.0

使用IKE 协商方式,并配置IKE 预设认证字

[R3]ike pre-shared-key qazwsx remote 1.1.1.1

创建访问列表

[R3]acl 3001 match-order auto
[R3-acl-3001]rule normal permit ip source 192.168.3.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
[R3-acl-3001]rule normal deny ip source any destination any

创建名为tran2的安全提议

[R3]ipsec proposal tran2

创建一条安全策略,协商方式为isakmp

[R3]ipsec policy policy3 11 isakmp

引用访问列表

[R3-ipsec-policy-policy3-11]security acl 3001

引用安全提议

[R3-ipsec-policy-policy3-11]proposal tran2

设置末端地址

[R3-ipsec-policy-policy3-11]tunnel remote 1.1.1.1

在串口上应用安全策略组

[R3]interface Ethernet0

[R3-Ethernet0]ipsec policy 3

[R3]ip route-static 0.0.0.0 0.0.0.0 1.1.3.2 preference 60 默认路由

防火墙配置

[fw-2]interface Ethernet0/0

[fw-2-Ethernet0/0]ip address 1.1.1.2 255.255.255.252

[fw-2-Ethernet0/0]interface Ethernet0/1

[fw-2-Ethernet0/1]ip address 1.1.2.2 255.255.255.252

[fw-2-Ethernet0/1]interface Ethernet0/2

[fw-2-Ethernet0/2]ip address 1.1.3.2 255.255.255.252

添加trust区域

[fw-2]firewall zone trust

[fw-2-zone-trust]add interface Ethernet0/0

set priority 85

添加untrust区域

[fw-2]firewall zone untrust

[fw-2-zone-untrust]add interface Ethernet0/1

[fw-2-zone-untrust]add interface Ethernet0/2

[fw-2-zone-untrust]add interface Ethernet0/3

set priority 5

测试结果

在R14上pingR2

wps_clip_image-24145

ping通

 

在R14上pingR3

wps_clip_image-1447

Ping通