IPSEC在企业网中的应用

1.IPSEC简介

IPSec 是包括安全协议(Security Protocol)和**交换协议(IKE),由IETF(Internet Engineering TaskForce,Internet 工程任务组)开发的,可为通讯双方提供访问控制、无连接的完整性、数据来源认证、反重放、加密以及对数据流分类加密等服务的一系列网络安全协议的总称,其中安全协议又包括AH(头验证协议)和ESP(安全封装载荷);而IKE是一种基于ISAKMP(Internet Security Association and Key Management Protocol,互联网安全关联和**管理协议)中TCP/IP框架,合并了Oakley(**交换协议)的一部分和SKEME(**技术协议)的混合协议。

2.IPSEC的安全特性

1)不可否认性:"不可否认性"可以证实消息发送方是唯一可能的发送者,发送者不能否认发送过消息。"不可否认性"是采用公钥技术的一个特征,当使用公钥技术时,发送方用私钥产生一个数字签名随消息一起发送,接收方用发送者的公钥来验证数字签名。由于在理论上只有发送者才唯一拥有私钥,也只有发送者才可能产生该数字签名,所以只要数字签名通过验证,发送者就不能否认曾发送过该消息。但"不可否认性"不是基于认证的共享**技术的特征,因为在基于认证的共享**技术中,发送方和接收方掌握相同的**。

2)抗重播性(Anti-Replay): IPsec接收方可根据数据包数据段前加入的32位***来检测每个IP包的唯一性并拒绝接收过时或重复的报文,以防止***者截取破译信息后,再用相同的信息包冒取非法访问权(即使这种冒取行为发生在数月之后)。

3)数据完整性(Data Integrity): IPsec接收方利用md5,sha-1等哈希算法对发送方发送来的包进行认证,防止传输过程中数据被篡改,确保发出数据和接收数据的一致性。

4)数据可靠性(Confidentiality:IPsec发送方在通过des,3des,aes等对称加密算法在网络传输包前对包进行加密,保证在传输过程中,即使数据包遭截取,信息也无法被读。该特性在IPSec中为可选项,与IPSec策略的具体设置相关。

5)数据来源认证(Data Authentication):IPsec在接收端通过preshared key(域共享**),证书,kerberos v5等可以认证发送IPsec报文的发送端是否合法。

3.IPSEC的工作模式

1)隧道(tunnel)模式:用户的整个IP数据包被用来计算AH或ESP头,AH或ESP头以及ESP加密的用户数据被封装在一个新的IP数据包中。通常,隧道模式应用在两个安全网关之间的通讯。

2)传输(transport)模式:只是传输层数据被用来计算AH或ESP头,AH或ESP头以及ESP加密的用户数据被放置在原IP包头后面。通常,传输模式应用在两台主机之间的通讯,或一台主机和一个安全网关之间的通讯。

4.IPSEC安全机制中两种协议的比较

AH协议(IP协议号为51)提供数据源认证、数据完整性校验和防报文重放功能,它能保护通信免受篡改,但不能防止窃听,适合用于传输非机密数据。AH的工作原理是在每一个数据包上添加一个身份验证报文头,此报文头插在标准IP包头后面,对数据提供完整性保护。,但因为IP头部分包含很多变量,比如type of service(TOS),flags,fragment offset,TTL以及header checksum。所以这些值在进行authtication前要全部清零。否则hash会mismatch导致丢包。因此AH不支持NAT转换。

ESP协议(IP协议号为50)提供加密、数据源认证、数据完整性校验和防报文重放功能。ESP的工作原理是在每一个数据包的标准IP包头后面添加一个ESP报文头,并在数据包后面追加一个ESP尾。与AH协议不同的是,ESP将需要保护的用户数据进行加密后再封装到IP包中,以保证数据的机密性。

下图更好的解释了AH和ESP在IPSEC两种工作模式下对数据包的加密与认证

IPSEC在企业网中的应用

5.IPsec基本概念(基于H3C)

1. 数据流:在 IPSec 中,一组具有相同源地址/掩码/端口、目的地址/掩码/端口和上层协议的数据集称为数据流。通常,一个数据流采用一个访问控制列表(acl)来定义,所有为ACL 允许通过的报文在逻辑上作为一个数据流。

2.安全策略:由用户手工配置,规定对什么样的数据流采用什么样的安全措施。对数据流的定义是通过在一个访问控制列表中配置多条规则来实现,在安全策略中引用这个访问控制列表来确定需要进行保护的数据流。一条安全策略由“名字”和“顺序号”共同唯一确定。

3.安全策略组:所有具有相同名字的安全策略的集合。在一个接口上,可应用或者取消一个安全策略组,使安全策略组中的多条安全策略同时应用在这个接口上,从而实现对不同的数据流进行不同的安全保护。在同一个安全策略组中,顺序号越小的安全策略,优先级越高。

4.安全联盟(Security Association,简称SA):IPSec 对数据流提供的安全服务通过安全联盟SA 来实现,它包括协议、算法、**等内容,具体确定了如何对IP 报文进行处理。一个SA 就是两个IPSec 系统之间的一个单向逻辑连接,输入数据流和输出数据流由输入安全联盟与输出安全联盟分别处理。安全联盟由一个三元组(安全参数索引(SPI)、IP 目的地址、安全协议号(AH或ESP))来唯一标识。
安全联盟可通过手工配置和自动协商两种方式建立。
手工建立安全联盟的方式是指用户通过在两端手工设置SA的全部信息,然后在接口上应用安全策略建立安全联盟,缺点是配置复杂,而且不支持一些高级特性(如定时更新**),适用于小型企业。
自动协商方式由IKE 生成和维护,通信双方基于各自的安全策略库经过匹配和协商,最终建立安全联盟而不需要用户的干预,配置简单,适用于大型企业。在自动协商中又分为主模式与野蛮模式,野蛮模式交换与主模式交换的主要差别在于,野蛮模式不提供身份保护。在对身份保护要求不高的场合,使用交换报文较少的野蛮模式可以提高协商的速度;在对身份保护要求较高的场合,则应该使用主模式。

5.安全参数索引(SPI):是一个32 比特的数值,在每一个IPSec 报文中都携带该值。SPI、IP 目的地址、安全协议号三者结合起来共同构成三元组,来唯一标识一个特定的安全联盟。在手工配置安全联盟时,需要手工指定SPI 的取值。为保证安全联盟的唯一性,每个安全联盟需要指定不同的SPI 值;使用IKE协商产生安全联盟时,SPI 将随机生成。

6.安全提议:包括安全协议、安全协议使用的算法、安全协议对报文的封装形式,规定了把普通的IP 报文转换成IPSec报文的方式。在安全策略中,通过引用一个安全提议来规定该安全策略采用的协议、算法等。

6.IPsecIPSEC配置步骤

创建加密访问控制列表

根据是否与加密访问控制列表匹配,可以确定那些 IP 包加密后发送,那些IP 包直

接转发。需要保护的安全数据流使用扩展IP 访问控制列表进行定义。

acl acl-number

rule { normal | special }{ permit | deny } pro-number[source source-addr source-wildcard | any ][source-port operator port1 [ port2 ] ] [ destination dest-addr dest- wildcard | any ][destination-port operator port1 [ port2 ] ] [icmp-type icmp-type icmp-code][logging]

定义安全提议

定义安全提议 ipsec proposal proposal-name

设置安全协议对 IP 报文的封装模式encapsulation-mode { transport | tunnel }

选择安全协议transform { ah-new | ah-esp-new | esp-new }

选择加密算法与认证算法

Esp协议下 transform { ah-new | ah-esp-new | esp-new }

AH协议下 transform { ah-new | ah-esp-new | esp-new }

创建安全策略

手工创建安全策略的配置包括:

手工创建安全策略ipsec policy policy-name sequence-number manual

配置安全策略引用的访问控制列表 security acl access-list-number

指定安全隧道的起点与终点 tunnel local ip-address

tunnel remote ip-address

配置安全策略中引用的安全提议 proposal proposal-name

配置安全策略联盟的 SPI 及使用的**

SPI的配置 sa inbound { ah | esp } spi spi-number

sa outbound { ah | esp } spi spi-number

**的配置

AH16进制** sa { inbound | outbound } ah hex-key-string hex-key

AH 字符** sa { inbound | outbound } ah string-key string-key

ESP16进制** sa { inbound | outbound } esp encryption-hex hex-key

ESP字符** sa { inbound | outbound } esp string-key string-key

在接口上应用安全策略组

ipsec policy policy-name

IKE 创建安全策略联盟的配置包括:

IKE 创建安全策略联盟

ipsec policy policy-name sequence-number isakmp

配置安全策略引用的访问控制列表

security acl access-list-number

指定安全隧道的终点

tunnel remote ip-address

配置安全策略中引用的安全提议

proposal proposal-name1 [ proposal-name2...proposal-name6 ]

配置安全联盟的生存时间(可选)

配置全局时间

ipsec sa global-duration time-based seconds

ipsec sa global-duration traffic-based kilobytes

配置独立时间

sa duration { time-based seconds |traffic-based kilobytes }

7.IPsec配置案例

实验环境说明:

本实验采用华为2600系列路由器三台,3526系列交换机(三层)一台。实现1.0网段的主机可以喝2.0,3.0网段的主机通过***互访。但是2.0和3.0之间不建立***。

IPSEC在企业网中的应用

配置详解

R14的配置:

给接口配置IP

Int e0

Ip add 192.168.1.1

Int e1

Ip add 192.168.10.200

配置默认路由

Ip route 0.0.0.0 0 192.168.10.1

创建加密访问控制列表

Acl 3000

Rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255

rule deny ip source any destination any

Acl 3001

rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.3.0 0.0.0.255

rule deny ip source any destination any

创建安全提议

ipsec proposal tran1

encapsulation-mode tunnel

transform esp-new

esp-new encryption-algorithm des

esp-new authentication-algorithm sha1-hmac-96

ipsec proposal tran2

transform esp-new

esp-new encryption-algorithm des

esp-new authentication-algorithm sha1-hmac-96

创建安全策略

ipsec policy policy1 10 isakmp

security acl 3000

proposal tran1

tunnel remote 192.168.20.200

ipsec policy policy1 20 isakmp

security acl 3001

proposal tran2

tunnel remote 192.168.30.200

在外出接口上应用策略

Int e1

ipsec policy policy1

配置相应的IKE

ike pre-shared-key abcd remote 192.168.30.200

ike pre-shared-key 123456 remote 192.168.20.200

查看当前配置

Dis cu

!

ike pre-shared-key abcd remote 192.168.30.200

ike pre-shared-key 123456 remote 192.168.20.200

!

!

acl 3000 match-order auto

rule normal permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255

rule normal deny ip source any destination any

!

acl 3001 match-order auto

rule normal permit ip source 192.168.1.0 0.0.0.255 destination 192.168.3.0 0.0.0.255

rule normal deny ip source any destination any

!

ike proposal 1

!

ipsec proposal tran2

!

ipsec proposal tran1

!

ipsec policy policy1 10 isakmp

security acl 3000

proposal tran1

tunnel remote 192.168.20.200

!

ipsec policy policy1 20 isakmp

security acl 3001

proposal tran2

tunnel remote 192.168.30.200 !

interface Ethernet0

ip address 192.168.1.1 255.255.255.0

!

interface Ethernet1

ip address 192.168.10.200 255.255.255.0

ipsec policy policy1

ip route-static 0.0.0.0 0.0.0.0 192.168.10.1 preference 60

R5配置:

给接口配置IP

Int e0

Ip add 192.168.2.1

Int e1

Ip add 192.168.20.200

配置默认路由

ip route-static 0.0.0.0 0.0.0.0 192.168.20.1

创建加密访问控制列表

Acl 3000

Rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255

rule deny ip source any destination any

创建安全提议

ipsec proposal tran1

encapsulation-mode tunnel

transform esp-new

esp-new encryption-algorithm des

esp-new authentication-algorithm sha1-hmac-96

创建安全策略

ipsec policy policy1 10 isakmp

security acl 3000

proposal tran1

tunnel remote 192.168.10.200

在外出接口上应用策略

Int e1

ipsec policy policy1

配置相应的IKE

ike pre-shared-key 123456 remote 192.168.10.200

查看当前配置

Dis cu

!

ike pre-shared-key 123456 remote 192.168.10.200

!

acl 3000 match-order auto

rule normal permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255

rule normal deny ip source any destination any

!

ipsec proposal tran1

!

ipsec policy policy1 10 isakmp

security acl 3000

proposal tran1

tunnel remote 192.168.10.200

!

interface Ethernet0

ip address 192.168.2.1 255.255.255.0

!

interface Ethernet1

ip address 192.168.20.200 255.255.255.0

ipsec policy policy1

!

ip route-static 0.0.0.0 0.0.0.0 192.168.20.1 preference 60

!

R9配置:

给接口配置IP

Int e0

Ip add 192.168.3.1

Int e1

Ip add 192.168.30.200

配置默认路由

ip route-static 0.0.0.0 0.0.0.0 192.168.30.1

创建加密访问控制列表

Acl 3000

Rule permit ip source 192.168.3.0 0.0.0.255 destination 192.168.1.0 0.0.0.255

rule deny ip source any destination any

创建安全提议

ipsec proposal tran2

encapsulation-mode tunnel

transform esp-new

esp-new encryption-algorithm des

esp-new authentication-algorithm sha1-hmac-96

创建安全策略

ipsec policy policy1 20 isakmp

security acl 3000

proposal tran1

tunnel remote 192.168.10.200

在外出接口上应用策略

Int e1

ipsec policy policy1

配置相应的IKE

ike pre-shared-key abcd remote 192.168.10.200

查看当前配置

Dis cu

[R9]dis cu

Now create configuration...

Current configuration

!

version 1.74

local-user user1 service-type administrator password simple 123

sysname R9

firewall enable

aaa-enable

aaa accounting-scheme optional

!

ike pre-shared-key abcd remote 192.168.10.200

!

acl 3000 match-order auto

rule normal permit ip source 192.168.3.0 0.0.0.255 destination 192.168.1.0 0.0.0.255

rule normal deny ip source any destination any

!

ipsec proposal tran2

!

ipsec policy policy1 20 isakmp

security acl 3000

proposal tran2

tunnel remote 192.168.10.200

!

interface Aux0

async mode flow

link-protocol ppp

!

interface Ethernet0

ip address 192.168.3.1 255.255.255.0

!

interface Ethernet1

ip address 192.168.30.200 255.255.255.0

ipsec policy policy1

!

quit

ip route-static 0.0.0.0 0.0.0.0 192.168.30.1 preference 60

!

return

SW10的配置:

创建vlan并把接口加入vlan

Vlan 10

Por e0/10

Vlan 20

Por e0/20

Vlan 30

Port e0/30

给vlan配置ip地址

Int vlan 10

ip address 192.168.10.1 255.255.255.0

Int vlan 20

ip address 192.168.20.1 255.255.255.0

Int vlan 30

ip address 192.168.30.1 255.255.255.0

查看当前生效的配置

#

vlan 10

#

vlan 20

#

vlan 30

#

interface Vlan-interface1

ip address 192.168.100.10 255.255.255.0

#

interface Vlan-interface10

ip address 192.168.10.1 255.255.255.0

#

interface Vlan-interface20

ip address 192.168.20.1 255.255.255.0

#

interface Vlan-interface30

ip address 192.168.30.1 255.255.255.0

测试:

1.10访问2.45:

IPSEC在企业网中的应用

1.10访问3.45:

IPSEC在企业网中的应用

2.45访问1.10:

IPSEC在企业网中的应用

3.100访问1.10:

IPSEC在企业网中的应用

 

 

IPSEC野蛮模式案例

实验设备

防火墙:华为F100

三层交换:s3526交换机

实验描述

fw1的Ethernet1接口固定IP地址,fw2和fw3的外网接口为动态获取IP地址,所以fw1和fw2,fw3建立起IPSEC连接必须具备IKE野蛮模式,为了保证信息安全采用IPsec/IKE方式创建安全隧道。

IPSEC在企业网中的应用

详细配置步骤

fw1的配置

基本配置

firewall packet-filter default permit

firewall zone trust

add interface Ethernet0/0

add interface Ethernet0/1

add interface Ethernet0/4

interface Ethernet0/1

ip address 192.168.10.200 255.255.255.0

interface Ethernet0/4

ip address 192.168.1.1 255.255.255.0

ip route-static 0.0.0.0 0.0.0.0 192.168.10.1

配置安全访问控制列表

acl number 3000

rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255

rule deny ip source any destination ayn

acl number 3001

rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.3.0 0.0.0.255

rule permit ip source ayn destination any

配置IKE

本地设备名称

ike local-name fw1

设置对等体

ike peer peer1

exchange-mode aggressive 协商模式为野蛮模式

pre-shared-key 1234 共享**

id-type name ID类型为名称

remote-name fw2 对端设备名称

local-address 192.168.10.200 本端IP地址

ike peer peer2

exchange-mode aggressive

pre-shared-key abcd

id-type name

remote-name fw3

local-address 192.168.10.200

配置安全提议

ipsec proposal tran1

encapsulation-mode tunnel

transform esp

esp encryption-algorithm des

esp authentication-algorithm md5

ipsec proposal tran2

encapsulation-mode tunnel

transform esp

esp encryption-algorithm des

esp authentication-algorithm md5

配置安全策略

ipsec policy policy 10 isakmp

security acl 3000

ike-peer peer1 引用对等体

proposal tran1

ipsec policy policy 20 isakmp

security acl 3001

ike-peer peer2

proposal tran2

在接口上引用安全策略

interface Ethernet0/1

ipsec policy policy

SW12配置

基本配置

vlan 10

port Ethernet0/1

vlan 20

port Ethernet0/5

vlan 30

port Ethernet0/3

interface Vlan-interface10

ip address 192.168.10.1 255.255.255.0

interface Vlan-interface20

ip address 192.168.20.1 255.255.255.0

interface Vlan-interface30

ip address 192.168.30.1 255.255.255.0

配置DHCP

dhcp server ip-pool fw2

network 192.168.20.0 mask 255.255.255.0

gateway-list 192.168.20.1

dhcp server ip-pool fw3

network 192.168.30.0 mask 255.255.255.0

gateway-list 192.168.30.1

dhcp server forbidden-ip 192.168.20.1

dhcp server forbidden-ip 192.168.30.1

dhcp server enable

fw2配置

基本配置

firewall packet-filter default permit

firewall zone trust

add interface Ethernet0/0

add interface Ethernet0/1

add interface Ethernet0/4

interface Ethernet0/1

ip address dhcp-alloc

interface Ethernet0/4

ip address 192.168.2.1 255.255.255.0

ip route-static 0.0.0.0 0.0.0.0 192.168.20.1

配置安全访问控制列表

acl number 3000

rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255

rule deny ip source any destination any

配置IKE

ike local-name fw1

ike peer peer1

exchange-mode aggressive

pre-shared-key 1234

id-type name

remote-name fw1

remote-address 192.168.10.200 设对端IP地址

配置安全提议

ipsec proposal tran1

encapsulation-mode tunnel

transform esp

esp encryption-algorithm des

esp authentication-algorithm md5

配置安全策略

ipsec policy policy 10 isakmp

security acl 3000

ike-peer peer1

proposal tran1

在接口上引用安全策略

interface Ethernet0/1

ipsec policy policy

fw3配置

基本配置

firewall packet-filter default permit

firewall zone trust

add interface Ethernet0/0

add interface Ethernet0/1

add interface Ethernet0/4

interface Ethernet0/1

ip address dhcp-alloc

interface Ethernet0/4

ip address 192.168.3.1 255.255.255.0

ip route-static 0.0.0.0 0.0.0.0 192.168.30.1

配置安全访问控制列表

acl number 3001

rule permit ip source 192.168.3.0 0.0.0.255 destination 192.168.1.0 0.0.0.255

rule deny ip source any destination any

配置IKE

ike local-name fw1

ike peer peer2

exchange-mode aggressive

pre-shared-key abcd

id-type name

remote-name fw1

remote-address 192.168.10.200

配置安全提议

ipsec proposal tran2

encapsulation-mode tunnel

transform esp

esp encryption-algorithm des

esp authentication-algorithm md5

配置安全策略

ipsec policy policy 20 isakmp

security acl 3001

ike-peer peer2

proposal tran2

在接口上引用安全策略

interface Ethernet0/1

ipsec policy policy

查看E0/1动态获得的地址

IPSEC在企业网中的应用

sw12上可以查看已经分配出去的地址

IPSEC在企业网中的应用

实验结果

1.0访问3.0

IPSEC在企业网中的应用

1.0访问2.0

IPSEC在企业网中的应用

2.0访问1.0

IPSEC在企业网中的应用

3.0访问1.0

IPSEC在企业网中的应用

此时分别查看三台设备的SA

fw3上 display ipscek sa

IPSEC在企业网中的应用

fw1上display ipscek sa

IPSEC在企业网中的应用