雏鹰部落

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2511|回复: 5

[讨论/求助] VPN实例配置方案-中文注解

  [复制链接]
发表于 2011-6-14 12:55:09 | 显示全部楼层 |阅读模式
VPN实例配置方案-中文注解

Router:sam-i-am(VPN Server)

Current configuration:
!
version 12.2
service timestamps debug uptime
service timestamps log up time
no service password-encryption
!
hostname sam-i-am
!
ip subnet-zero

!--- IKE配置

sam-i-am(config)#crypto isakmp policy 1 //定义策略为1
sam-i-am(isakmp)#hash md5 //定义MD5散列算法
sam-i-am(isakmp)#authentication pre-share //定义为预共享密钥认证方式
sam-i-am(config)#crypto isakmp key cisco123 address 0.0.0.0 0.0.0.0

!--- 配置预共享密钥为cisco123,对等端为所有IP

!--- IPSec协议配置

sam-i-am(config)#crypto ipsec transform-set rtpset esp-des esp-md5-hmac

!--- 创建变换集 esp-des esp-md5-hmac

sam-i-am(config)#crypto dynamic-map rtpmap 10 //创建动态保密图rtpmap 10
san-i-am(crypto-map)#set transform-set rtpset //使用上面的定义的变换集rtpset
san-i-am(crypto-map)#match address 115 //援引访问列表确定受保护的流量
sam-i-am(config)#crypto map rtptrans 10 ipsec-isakmp dynamic rtpmap

!--- 将动态保密图集加入到正规的图集中

!
interface Ethernet0
ip address 10.2.2.3 255.255.255.0
no ip directed-broadcast
ip nat inside

no mop enabled
!
interface Serial0
ip address 99.99.99.1 255.255.255.0
no ip directed-broadcast
ip nat outside
crypto map rtptrans //将保密映射应用到S0接口上

!
ip nat inside source route-map nonat interface Serial0 overload
!--- 这个NAT配置启用了路由策略,内容为10.2.2.010.1.1.0的访问不进行地址翻译
!--- 到其他网络的访问都翻译成SO接口的IP地址

ip classless
ip route 0.0.0.0 0.0.0.0 Serial0 //配置静态路由协议
no ip http server
!
access-list 115 permit ip 10.2.2.0 0.0.0.255 10.1.1.0 0.0.0.255
access-list 115 deny ip 10.2.2.0 0.0.0.255 any
!
access-list 120 deny ip 10.2.2.0 0.0.0.255 10.1.1.0 0.0.0.255
access-list 120 permit ip 10.2.2.0 0.0.0.255 any
!
sam-i-am(config)#route-map nonat permit 10 //使用路由策略
sam-i-am(router-map)#match ip address 120
!
line con 0
transport input none
line aux 0
line vty 0 4
password ww
login
!
end


Router:dr_whoovie(VPN Client)


Current configuration:
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname dr_whoovie
!
ip subnet-zero
!
dr_whoovie(config)#crypto isakmp policy 1 //定义策略为1
dr_whoovie(isakmp)#hash md5 //定义MD5散列算法
dr_whoovie(isakmp)#authentication pre-share //定义为预共享密钥认证方式
dr_whoovie(config)#crypto isakmp key cisco123 address 99.99.99.1

!--- 配置预共享密钥为cisco123,对等端为服务器端IP99.99.99.1

!--- IPSec协议配置

dr_whoovie(config)#crypto ipsec transform-set rtpset esp-des esp-md5-hmac

!--- 创建变换集 esp-des esp-md5-hmac

dr_whoovie(config)#crypto map rtp 1 ipsec-isakmp

!--- 使用IKE创建保密图rtp 1

dr_whoovie(crypto-map)#set peer 99.99.99.1 //确定远程对等端
dr_whoovie(crypto-map)#set transform-set rtpset //使用上面的定义的变换集rtpset
dr_whoovie(crypto-map)#match address 115 //援引访问列表确定受保护的流量

!
interface Ethernet0
ip address 10.1.1.1 255.255.255.0
no ip directed-broadcast
ip nat inside

no mop enabled
!
interface Serial0
ip address negotiated //IP地址自动获取
no ip directed-broadcast
ip nat outside
encapsulation ppp //S0接口封装ppp协议
no ip mroute-cache
no ip route-cache
crypto map rtp //将保密映射应用到S0接口上

!
ip nat inside source route-map nonat interface Serial0 overload
!--- 这个NAT配置启用了路由策略,内容为10.1.1.010.2.2.0的访问不进行地址翻译
!--- 到其他网络的访问都翻译成SO接口的IP地址

ip classless
ip route 0.0.0.0 0.0.0.0 Serial0 //配置静态路由协议
no ip http server

!
access-list 115 permit ip 10.1.1.0 0.0.0.255 10.2.2.0 0.0.0.255
access-list 115 deny ip 10.1.1.0 0.0.0.255 any

access-list 120 deny ip 10.1.1.0 0.0.0.255 10.2.2.0 0.0.0.255
access-list 120 permit ip 10.1.1.0 0.0.0.255 any

!
dialer-list 1 protocol ip permit
dialer-list 1 protocol ipx permit
route-map nonat permit 10 //使用路由策略
match ip address 120
!
line con 0
transport input none
line aux 0
line vty 0 4
password ww
login
!
end



-----------IKE配置----------------

IPSec VPN对等端为了建立信任关系,必须交换某种形式的认证密钥。
Internet 密钥交换(Internet Key ExchangeIKE)是一种为IPSec管理和交换密钥的标准方法。
一旦两个对等端之间的IKE协商取得成功,那么IKE就创建到远程对等端的安全关联(security associationSA)SA是单向的;在两个对等端之间存在两
SA
IKE使用UDP端口500进行协商,确保端口500不被阻塞。

配置

1、(可选)启用或者禁用IKE
(global)crypto isakmp enable
或者
(global)no crypto isakmp enable
默认在所有接口上启动IKE

2、创建IKE策略
(1)定义策略
(global)crypto isakmp policy priority
注释:policy 1表示策略1,假如想多配几个VPN,可以写成policy 2policy3

(2)(可选)定义加密算法
(isakmp)encryption {des | 3des}
加密模式可以为56位的DES-CBC(des,默认值)或者168位的3DES(3des)

(3)(可选)定义散列算法
(isamkp)hash {sha | md5}
默认sha

(4)(可选)定义认证方式
(isamkp)authentication {rsa-sig | rsa-encr | pre-share}
rsa-sig 要求使用CA并且提供防止抵赖功能;默认值
rsa-encr 不需要CA,提供防止抵赖功能
pre-share 通过手工配置预共享密钥

(5)(可选)定义Diffie-Hellman标识符
(isakmp)group {1 | 2}
注释:除非购买高端路由器,或是VPN通信比较少,否则最好使用group 1长度的密钥,group命令有两个参数值:12。参数值1表示密钥使用768位密钥,
参数值2表示密钥使用1024位密钥,显然后一种密钥安全性高,但消耗更多的CPU时间。

(6)(可选)定义安全关联的生命期
(isakmp)lifetime seconds
注释:对生成新SA的周期进行调整。这个值以秒为单位,默认值为86400,也就是一天。值得注意的是两端的路由器都要设置相同的SA周期,否则VPN在正
常初始化之后,将会在较短的一个SA周期到达中断。

3(rsa-sig)使用证书授权(CA)
(1)确保路由器有主机名和域名
(global)hostname hostname
(global)ip domain-name domain

(2)产生RSA密钥
(global)crypto key generate rsa

(3)使用向IPSec对等端发布证书的CA
--设定CA的主机名
(global)crypto ca identity name
--设定联络CA所使用的URL
(ca-identity)enrollment url url
URL应该采用http://ca-domain-nameort/cgi-bin-location的形式
--(可选)使用RA模式
(ca-identity)enrollment mode ra
(ca-identity)query url url
--(可选)设定注册重试参数
(ca-identity)enrollment retry period minutes
(ca-identity)enrollment retry count number
minutes(160;默认为1) number(1100;默认为0,代表无穷次)
--(可选)可选的证书作废列表
(ca-identity)crl optional

(4)(可选)使用可信的根CA
--确定可信的根CA
(global)crypto ca trusted-root name
--(可选)从可信的根请求CRL
(ca-root)crl query url
--定义注册的方法
(ca-root)root {CEP url | TFTP server file | PROXY url}

(5)认证CA
(global)crypto ca authenticate name

(6)CA注册路由器
(global)crypto ca enroll name

4(rsa-encr)手工配置RSA密钥(不使用CA
(1)产生RSA密钥
(global)crypto key generate rsa

(2)指定对等端的ISAKMP标识
(global)crypto isakmp identity {address | hostname}

(3)指定其他所有对等端的RSA密钥
--配置公共密钥链
(global)crypto key pubkey-chain rsa

--用名字或地址确定密钥
(pubkey-chain)named-key key-name [encryption | signature]
(pubkey-chain)addressed-key key-name [encryption | signature]

--(可选)手工配置远程对等端的IP地址
(pubkey-key)address ip-addr

--指定远程对等端的公开密钥
(pubkey-key)key-string key-string

5(preshare)配置预共享密钥
(global)crypto isakmp key key-string {addrss | hostname} {peer-address | peer-hostname}
注释:返回到全局设置模式确定要使用的预先共享密钥和指归VPN另一端路由器IP地址,即目的路由器IP地址。相应地在另一端路由器配置也和以上命令类


6、(可选)使用IKE模式
(1)定义要分发的内部或者受保护IP地址库
(global)ip local pool pool-name start-address end-address

(2)启动IKE模式协商
(global)crypto isakmp client configuration address-pool local pool-name

--------------IPSec配置----------------

IPSec 使用加密、数据完整性、源发鉴别以及拒绝重演分组来保护和认证网络层对等端之间的IP分组

IPSec对于构建内因网、外因网以及远程用户接入VPN来说非常有用处

IPSec支持以下标准
--Internet协议的安全体系结构
--IKE(Internet密钥交换)
--DES(数据加密标准)
--MD5
--SHA
--AH(Authentication Header,认证首部)数据认证和反重演(anti-reply)服务
--ESP(Encapsulation Security Payload,封装安全净荷)数据隐私、数据验证以及反重演(anti-reply)服务

敏感流量由访问列表所定义,并且通过crypto map(保密图)集被应用到接口上。

配置

1、为密钥管理配置IKE

2、(可选)定义SA的全局生命期
(global)crypto ipsec security-association lifetime seconds seconds
(global)crypto ipsec security-association lifetime killobytes kilobytes

3、定义保密访问列表来定义受保护的流量
(global)access-list access-list-number ....
或者
(global)ip access-list extended name
扩展的访问列表必须定义由IPSec保护哪种IP流量。保密图(crypto map)援引这个访问列表来确定在接口上要保护的流量。

4、定义IPSec交换集
(1)创建变换集
(global)crypto ipsec transform-set name [transform1 | transform2 | transform3]
可以在一个保密图(crypto map)中定义多个变换集。如果没有使用IKE,那么只能定义一种变换集。用户能够选择多达三种变换。
(可选)选择一种AH变换
--ah-md5-hmac
--ah-sha-hmac
--ah-rfc-1828
(可选)选择一种ESP加密编号
--esp-des
--esp-3des
--esp-rfc-1829
--esp-null
以及这些验证方法之一
--esp-md5-hmac
--esp-sha-hmac
(可选)选择IP压缩变换
--comp-lzs

(2)(可选)选择变换集的模式
(crypto-transform)mode {tunnel | transport}

5、使用IPSec策略定义保密映射
保密图(crypto map)连接了保密访问列表,确定了远程对等端、本地地址、变换集和协商方法。

(1)(可选)使用手工的安全关联(没有IKE协商)
--创建保密图
(global)crypto map map-name sequence ipsec-manual

--援引保密访问列表来确定受保护的流量
(crypto-map)match address access-list

--确定远程的IPSec对等端
(crypto-map)set peer {hostname | ip_addr}

--指定要使用的变换集
(crypto-map)set transform-set name
变换集必须和远程对等端上使用的相同

--(仅适用于AH验证)手工设定AH密钥
(crypto-map)set session-key inbound ah spi hex-key-data
(crypto-map)set session-key outbound ah spi hex-key-data

--(仅适用于ESP验证)手工设定ESP SPI和密钥
(crypto-map)set session-key inbound ah spi hex-key-data [authenticator hex-key-data]
(crypto-map)set session-key outbound ah spi hex-key-data [authenticator hex-key-data]

(2)(可选)使用IKE建立的安全关联
--创建保密图
(global)crypto map map-name sequence ipsec-isakmp

--援引保密访问列表来确定受保护的流量
(crypto-map)match address access-list

--确定远程的IPSec对等端
(crypto-map)set peer {hostname | ip_addr}

--指定要使用的变换集
(crypto-map)set transform-set name
变换集必须和远程对等端上使用的相同

--(可选)如果SA生命期和全局默认不同,那么定义它:
(crypto-map)set security-association lifetime seconds seconds
(crypto-map)set security-association lifetime kilobytes kilobytes

--(可选)为每个源/目的主机对使用一个独立的SA
(crypto-map)set security-association level per-host

--(可选)对每个新的SA使用完整转发安全性
(crypto-map)set pfs [group1 | group2]

(3)(可选)使用动态安全关联
--创建动态的保密图
(global)crypto dynamic-map dyn-map-name dyn-seq-num

--(可选)援引保密访问列表确定受保护的流量
(crypto-map)match address access-list

--(可选)确定远程的IPSec对等端
(crypto-map)set peer {hostname | ip_addr}

--(可选)指定要使用的变换集
(crypto-map)set transform-set tranform-set-name

--(可选)如果SA生命期和全局默认不同,那么定义它:
(crypto-map)set security-association lifetime seconds seconds
(crypto-map)set security-association lifetime kilobytes kilobytes

--(可选)对每个新的SA使用完整转发安全性
(crypto-map)set pfs [group1 | group2]

--将动态保密图集加入到正规的图集中
(global)crypto map map-name sequence ipsec-isakmp dynamic dyn-map-name [discover]

--(可选)使用IKE模式的客户机配置
(global)crypto map map-name client configuration address [initiate | respond]

--(可选)使用来自AAA服务器的预共享IKE密钥
(global)crypto map map-name isakmp authorization list list-name

6、将保密映射应用到接口上

(1)指定要使用的保密映射
(interface)crypto map map-name

(2)(可选)和其他接口共享保密映射
(global)crypto map map-name local-address interface-id

发表于 2011-6-14 14:09:32 | 显示全部楼层
这个帖强大了~楼主最近技术贴出的真不少~向您学习了~
发表于 2011-6-14 14:11:55 | 显示全部楼层
最近发现论坛技术贴越来越多了。这下大伙可有福了
 楼主| 发表于 2011-6-14 14:39:38 | 显示全部楼层
共享盛宴!
发表于 2013-3-31 21:36:03 | 显示全部楼层
知识很详细,谢谢...要是能来个简单的案例实现就好了   哈哈
发表于 2013-4-25 12:46:12 | 显示全部楼层
收藏了先,谢谢
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|熊猫同学技术论坛|小黑屋| 网络工程师论坛 ( 沪ICP备09076391 )

GMT+8, 2024-5-4 12:47 , Processed in 0.083352 second(s), 21 queries , Gzip On.

快速回复 返回顶部 返回列表