CCIE思科教育培训 CCIE培训

华为IPsec协议实现VPN 实现安全通信案例

Ipsec原理:IPSec 协议简介 

1. IPSec 协议 

IPSec 是一系列网络安全协议的总称,它是由 IETF (Internet Engineering TaskForce,Internet 工程任务组)开发的,可为通讯双方提供访问控制、无连接的完整性、数据来源认证、反重放、加密以及对数据流分类加密等服务。IPSec 是网络层的安全机制。通过对网络层包信息的保护,上层应用程序即使没有实现安全性,也能够自动从网络层提供的安全性中获益。这打消了人们对 VPN (Virtual Private Network ,虚拟专用网络)安全性的顾虑,使得 VPN 得以广泛应用。 

2. 加密卡 

在实际应用中,IPSec 对报文的处理包括进行 ESP 协议处理、加密后给报文添加认证头、对报文完成认证后删除认证头。

3、IPSec 的配置 

IPSec 的配置包括: 

创建加密访问控制列表 

定义安全提议 

选择加密算法与认证算法 

创建安全策略 

在接口上应用安全策略组 

加密卡实现 IPSec 的配置包括: 

创建加密访问控制列表 

配置加密卡 

使能 VRP 主体软件备份 

定义安全提议 

选择加密算法与认证算法 

创建安全策略 

在接口上应用安全策略组 

为了实现北京和上海、北京和广州各子公司安全的通信,我们建立VPN通道这里我们用自动协商的策略来实现:

 

实验环境:三台路由器(型号:华为R2621)、一台交换机(型号:华为S2000)、网线数根、serial-usb线。

 

拓扑图如下:

我们来看看配置:

 

 

交换机配置:

[sw-1]dis cu

#

sysname sw-1

#

radius scheme system

server-type huawei

primary authentication 127.0.0.1 1645

primary accounting 127.0.0.1 1646

user-name-format without-domain

 

domain system

radius-scheme system

access-limit disable

state active

idle-cut disable

self-service-url disable

messenger time disable

 

domain default enable system

#

local-server nas-ip 127.0.0.1 key huawei

#

vlan 1

#

vlan 10 

vlan 20 

vlan 24 

interface Vlan-interface10 

ip address 1.1.1.2 255.255.255.0 

interface Vlan-interface20 

ip address 1.1.2.2 255.255.255.0 

interface Vlan-interface24 

ip address 1.1.3.2 255.255.255.0 

Vlan上所有ip都能ping通:

[sw-1]ping 1.1.1.2

PING 1.1.1.2: 56 data bytes, press CTRL_C to break

Reply from 1.1.1.2: bytes=56 Sequence=1 ttl=255 time = 2 ms

Reply from 1.1.1.2: bytes=56 Sequence=2 ttl=255 time = 1 ms

Reply from 1.1.1.2: bytes=56 Sequence=3 ttl=255 time = 2 ms

Reply from 1.1.1.2: bytes=56 Sequence=4 ttl=255 time = 2 ms

Reply from 1.1.1.2: bytes=56 Sequence=5 ttl=255 time = 2 ms

 

--- 1.1.1.2 ping statistics ---

5 packet(s) transmitted

5 packet(s) received

0.00% packet loss

round-trip min/avg/max = 1/1/2 ms

[sw-1]ping 1.1.2.2

PING 1.1.2.2: 56 data bytes, press CTRL_C to break

Reply from 1.1.2.2: bytes=56 Sequence=1 ttl=255 time = 2 ms

Reply from 1.1.2.2: bytes=56 Sequence=2 ttl=255 time = 1 ms

Reply from 1.1.2.2: bytes=56 Sequence=3 ttl=255 time = 3 ms

Reply from 1.1.2.2: bytes=56 Sequence=4 ttl=255 time = 1 ms

Reply from 1.1.2.2: bytes=56 Sequence=5 ttl=255 time = 1 ms

 

--- 1.1.2.2 ping statistics ---

5 packet(s) transmitted

5 packet(s) received

0.00% packet loss

round-trip min/avg/max = 1/1/3 ms

 

这时继续配R1:

配置如下:

 

[R1]dis cu

Now create configuration...

Current configuration

!

version 1.74

sysname R1

undo pos-server addr-switch

firewall enable

aaa-enable

aaa accounting-scheme optional

!

ike pre-shared-key 123 remote 1.1.2.1

!

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

!

ipsec proposal tran1

!

ipsec policy policy1 10 isakmp

security acl 3000

proposal tran1

tunnel remote 1.1.2.1

!

controller e1 0

interface Aux0 

async mode flow 

link-protocol ppp 

interface Ethernet0 

loopback 

ip address 192.168.1.1 255.255.255.0 

interface Ethernet1 

ip address 1.1.1.1 255.255.255.0 

ipsec policy policy1 

interface Serial0 

link-protocol ppp 

interface Serial1 

link-protocol ppp 

quit

ip route-static 0.0.0.0 0.0.0.0 1.1.1.2 preference 60 

return

使用的是自动协商验证方式:

 

接下来是R2的配置:

[R2]dis cu

Now create configuration...

Current configuration

!

version 1.74

sysname R2

firewall enable

aaa-enable

aaa accounting-scheme optional

!

ike pre-shared-key 123 remote 1.1.1.1

!

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 20 source any destination any

!

ipsec proposal tran1

!

ipsec policy policy1 10 isakmp

security acl 3000

proposal tran1

tunnel remote 1.1.1.1

!

interface Aux0 

async mode flow 

link-protocol ppp 

interface Ethernet0 

loopback 

ip address 192.168.2.1 255.255.255.0 

interface Ethernet1 

ip address 1.1.2.1 255.255.255.0 

ipsec policy policy1 

interface Serial0 

link-protocol ppp 

interface Serial1 

link-protocol ppp 

interface Async0 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async1 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async2 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async3 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async4 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async5 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async6 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async7 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async8 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async9 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async10 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async11 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async12 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async13 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async14 

physical-mode async 

async mode protocol 

link-protocol ppp 

interface Async15 

physical-mode async 

async mode protocol 

link-protocol ppp 

quit

ip route-static 0.0.0.0 0.0.0.0 1.1.2.2 preference 60 

return

这时我们做完了ipsec的配置,接下来验证北京和上海是不是能够利用者条VPN安全通道进行通信:

R1路由器上:

[R1]ping -a 192.168.1.1 192.168.2.1

PING 192.168.2.1: 56 data bytes, press CTRL_C to break

Reply from 192.168.2.1: bytes=56 Sequence=0 ttl=255 time = 1 ms

Reply from 192.168.2.1: bytes=56 Sequence=1 ttl=255 time = 1 ms

Reply from 192.168.2.1: bytes=56 Sequence=2 ttl=255 time = 1 ms

Reply from 192.168.2.1: bytes=56 Sequence=3 ttl=255 time = 1 ms

Reply from 192.168.2.1: bytes=56 Sequence=4 ttl=255 time = 1 ms

 

--- 192.168.2.1 ping statistics ---

5 packets transmitted

5 packets received

0.00% packet loss

round-trip min/avg/max = 1/1/1 ms

R2路由器上:

[R2]ping -a 192.168.2.1 192.168.1.1

PING 192.168.1.1: 56 data bytes, press CTRL_C to break

Reply from 192.168.1.1: bytes=56 Sequence=0 ttl=255 time = 2 ms

Reply from 192.168.1.1: bytes=56 Sequence=1 ttl=255 time = 1 ms

Reply from 192.168.1.1: bytes=56 Sequence=2 ttl=255 time = 1 ms

Reply from 192.168.1.1: bytes=56 Sequence=3 ttl=255 time = 1 ms

Reply from 192.168.1.1: bytes=56 Sequence=4 ttl=255 time = 2 ms

 

--- 192.168.1.1 ping statistics ---

5 packets transmitted

5 packets received

0.00% packet loss

round-trip min/avg/max = 1/1/2 ms

最后来总结下IPsec对报文的处理过程:

IPSec 对报文的处理过程如下(以 AH 协议为例): 

(1) 对报文添加认证头:从 IPSec 队列中读出 IP 模块送来的 IP 报文,根据配置选 择的协议模式(传输或是隧道模式)对报文添加 AH 头,再由 IP 层转发。 

(2) 对报文进行认证后解去认证头:IP 层收到 IP 报文经解析是本机地址,并且协 

议号为 51,则查找相应的协议开关表项,调用相应的输入处理函数。此处理 函数对报文进行认证和原来的认证值比较,若相等则去掉添加的AH 头,还原出原始的 IP 报文再调用 IP 输入流程进行处理;否则此报文被丢弃。 

 

4. 与IPSec 相关的几个术语 

数据流:在 IPSec 中,一组具有相同源地址/掩码、目的地址/掩码和上层协议 

的数据集称为数据流。通常,一个数据流采用一个访问控制列表(acl )来定 义,所有为 ACL 允许通过的报文在逻辑上作为一个数据流。为更容易理解数据流可以比作是主机之间一个的 TCP 连接。IPSec 能够对不同的数据流施 加不同的安全保护,例如对不同的数据流使用不同的安全协议、算法或密钥。安全策略:由用户手工配置,规定对什么样的数据流采用什么样的安全措施。对数据流的定义是通过在一个访问控制列表中配置多条规则来实现,在安全策略中引用这个访问控制列表来确定需要进行保护的数据流。一条安全策略由 “名字”和“顺序号”共同唯一确定。 

安全策略组:所有具有相同名字的安全策略的集合。在一个接口上,可应用或 

者取消一个安全策略组,使安全策略组中的多条安全策略同时应用在这个接口 

上,从而实现对不同的数据流进行不同的安全保护。在同一个安全策略组中, 

顺序号越小的安全策略,优先级越高。 安全联盟(Security Association,简称 SA ):IPSec 对数据流提供的安全服 务通过安全联盟 SA 来实现,它包括协议、算法、密钥等内容,具体确定了如何对 IP 报文进行处理。一个 SA 就是两个 IPSec 系统之间的一个单向逻辑连 接,输入数据流和输出数据流由输入安全联盟与输出安全联盟分别处理。安全联盟由一个三元组(安全参数索引(SPI )、IP目的地址、安全协议号(AH 或 ESP))来唯一标识。安全联盟可通过手工配置和自动协商两种方式建手工建立安全联盟的方式是指用户通过在两端手工设置一些参数,然后在接口上应用安全策略建立安全联盟。自动协商方式由 IKE 生成和维护,通信双方基于各自的安全策略库经过匹配和协商,最终建立安全联盟而不需要用户干预。安全联盟超时处理:安全联盟更新时间有“计时间”(即每隔定长的时间进行更新)和“计流量”(即每传输一定字节数量的信息就进行更新)两种方式。安全参数索引(SPI ):是一个 32 比特的数值,在每一个 IPSec 报文中都带该值。SPI、IP 目的地址、安全协议号三者结合起来共同构成三元组,来唯 一标识一个特定的安全联盟。在手工配置安全联盟时,需要手工指定 SPI 的取值。为保证安全联盟的唯一性,每个安全联盟需要指定不同的 SPI 值;使用 IKE 协商产生安全联盟时,SPI 将随机生成。安全提议:包括安全协议、安全协议使用的算法、安全协议对报文的封装形式,规定了把普通的 IP 报文转换成 IPSec 报文的方式。在安全策略中,通过引用一个安全提议来规定该安全策略采用的协议、算法等。 



Tags:

发布: admin 分类: CCIE思科 评论: 0 浏览: 30
留言列表
发表留言
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。