Total Pageviews

Monday 8 October 2012

IPSec在企业网上的应用


VPN!--特殊的传送门
IPSec原理说明:
IPSec是IP Security的简称,它的目的是为IP提供高安全性特性,VPN则是在实现这种安全特性的方式下产生的解决方案。
IPSec是一个框架性架构,具体由两类协议组成:
1、AH协议(Authentication Header,使用较少):可以同时提供数据完整性确认、数据来源确认、防重放等安全特性;AH常用摘要算法(单向Hash函数)MD5和SHA1实现该特性。
2、ESP协议(Encapsulated Security Payload,使用较广):可以同时提供数据完整性确认、数据加密、防重放等安全特性;ESP通常使用DES、3DES、AES等加密算法实现数据加密,使用MD5或SHA1来实现数据完整性。
IPSec VPN的应用场景分为3种:
1、Site-to-Site(站点到站点或者网关到网关):如弯曲评论的3个机构分布在互联网的3个不同的地方,各使用一个商务领航网关相互建立VPN隧道,企业内网(若干PC)之间的数据通过这些网关建立的IPSec隧道实现安全互联。
2、End-to-End(端到端或者PC到PC): 两个PC之间的通信由两个PC之间的IPSec会话保护,而不是网关。
3、End-to-Site(端到站点或者PC到网关):两个PC之间的通信由网关和异地PC之间的IPSec进行保护。
VPN协议分类:
二层隧道协议:pptp  l2tp  l2f ;属于用户vpn【单机----网络】
三层隧道协议:gre ipsec;属于企业网vpn【网络----网络】
VPN的优势:
1、费用低,能够节省30%到70%的开销;
2、安全性高,能实现加密通信;
3、简化网络设计;
4、容易扩展;
5、支持新兴应用
VPN的缺点:
1、转发延迟比较大;
2、硬件vpn成本高
配置访问控制列表的目的:
1、用于挑选符合某一特征的数据流;
2、来确定什么样的ip用户来通过隧道;
3、需要使用扩展的ACL ;
报文封装形式有什么?
1、传输方式;无隧道服务器,单机----单机;
2、隧道方式;至少有一个隧道服务器;
本端与对端是什么?
安全隧道是建立在本端和对端网关之间,所以必须正确设置本端地址和对端地址才能成功地建立起一条安全隧道。手工创建的安全策略只能具备一个对端地址,若已 经指定了对端地址,必须要先删除原先的地址后才能指定新的对端地址。双方只有在正确指定了本端与对端地址后,才能够创建安全隧道。
案例1:
案例说明
在总部路由器R1和分支结构1路由器R2之间和总部路由器R1和分支结构2路由器R3之间各建立一个安全隧道;
实现 PC1代表的子网(192.168.1.x)与PC2代表的子网(192.168.2.x)之间VPN通信;
实现 PC1代表的子网(192.168.1.x)与PC3代表的子网(192.168.3.x)之间VPN通信;
安全协议采用 ESP 协议,加密算法采用 DES,认证算法采用 sha1-hmac-96,协商方式采用手工方式;
拓扑图:
QQ拼音截图未命名
实验要求:
1、实现分支机构1与总部之间的VPN加密通信;
2、实现分支机构2与总部之间的VPN加密通信;
3、实现分支机构1与分支机构2之间的VPN加密通信;
步骤综述:
1、配置扩展ACL
2、创建安全提议
a) 选取隧道模式
b) 选取协议类型
c) 选取加密算法
d) 选取认证算法
3、创建安全策略
a) 引用ACL
b) 引用安全提议
c) 设置本端与对端地址
d) 设置SPI
e) 设置密钥
4、在Internet网出口应用安全策略组
详细步骤:
配置路由器R1:
#配置接口
int eth 0
ip add 192.168.1.1 24
quit
int eth 1
ip add 10.1.1.1 24
quit
#配置一条默认路由
ip route 0.0.0.0 0.0.0.0 10.1.1.2
#配置扩展ACL
acl 3001
rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
#配置从分支机构2到分支机构1的中转ACL条目
rule permit ip source 192.168.3.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
rule deny ip source any destination any
quit
acl 3002
rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
#配置从分支机构1到分支机构2的中转ACL条目
rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
rule deny ip source any destination any
quit
#创建安全提议
ipsec proposal tran1
#选取隧道模式
encapsulation-mode tunnel
#选取协议类型
transform esp-new
#选取加密算法
esp-new encryption-algorithm des
#选取认证算法
esp-new authentication-algorithm sha1-hmac-96
quit
#创建到分支机构1的安全策略,使用编号10;并设置成自动匹配
ipsec policy policy1 10 isakmp
#引用ACL
security acl 3001
#引用安全提议
proposal tran1
#设置对端地址
tunnel remote 10.2.2.1
quit
#创建到分支机构2的安全策略,使用编号20;并设置成自动匹配
ipsec policy policy1 20 isakmp
#引用ACL
security acl 3002
#引用安全提议
proposal tran1
#设置对端地址
tunnel remote 10.3.3.1
quit
#在Internet网出口应用安全策略组
interface eth 1
ipsec policy policy1
quit
#配置相应的IKE
ike pre-shared-key abcde remote 10.2.2.1
ike pre-shared-key 12345 remote 10.3.3.1
配置路由器R2:
#配置接口
int eth 0
ip add 192.168.2.1 24
quit
int eth 1
ip add 10.2.2.1 24
quit
#配置一条默认路由
ip route 0.0.0.0 0.0.0.0 10.2.2.2
#配置扩展ACL
acl 3001
rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
#配置从分支机构1到分支机构2的ACL条目
rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
rule deny ip source any destination any
quit
#创建安全提议
ipsec proposal tran1
#选取隧道模式
encapsulation-mode tunnel
#选取协议类型
transform esp-new
#选取加密算法
esp-new encryption-algorithm des
#选取认证算法
esp-new authentication-algorithm sha1-hmac-96
quit
#创建安全策略;并设置成自动匹配
ipsec policy policy1 10 isakmp
#引用ACL
security acl 3001
#引用安全提议
proposal tran1
#设置对端地址
tunnel remote 10.1.1.1
quit
#在Internet网出口应用安全策略组
interface eth 1
ipsec policy policy1
quit
#配置相应的IKE
ike pre-shared-key abcde remote 10.1.1.1
配置路由器R3:
#配置接口
int eth 0
ip add 192.168.3.1 24
quit
int eth 1
ip add 10.3.3.1 24
quit
#配置一条默认路由
ip route 0.0.0.0 0.0.0.0 10.3.3.2
#配置扩展ACL
acl 3001
rule permit ip source 192.168.3.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
#配置从分支机构2到分支机构1的ACL条目
rule permit ip source 192.168.3.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
rule deny ip source any destination any
quit
#创建安全提议
ipsec proposal tran1
#选取隧道模式
encapsulation-mode tunnel
#选取协议类型
transform esp-new
#选取加密算法
esp-new encryption-algorithm des
#选取认证算法
esp-new authentication-algorithm sha1-hmac-96
quit
#创建安全策略;并设置成自动匹配
ipsec policy policy1 20 isakmp
#引用ACL
security acl 3001
#引用安全提议
proposal tran1
#设置对端地址
tunnel remote 10.1.1.1
quit
#在Internet网出口应用安全策略组
interface eth 1
ipsec policy policy1
quit
#配置相应的IKE
ike pre-shared-key 12345 remote 10.1.1.1
配置三层交换机:
#创建vlan并划分端口
vlan 10
port eth0/1
quit
vlan 20
port eth0/3
quit
vlan 30
port eth0/5
quit
#给vlan配置ip地址
int vlan 10
ip add 10.1.1.2 255.255.255.0
quit
int vlan 20
ip add 10.2.2.2 255.255.255.0
quit
int vlan 30
ip add 10.3.3.2 255.255.255.0
quit
测试:
PC1主机ping PC2主机:
wps_clip_image-20793
wps_clip_image-2216
PC2主机ping PC1主机:
wps_clip_image-14441
wps_clip_image-12269
PC1主机ping PC3主机:
wps_clip_image-23098
wps_clip_image-31032
PC3主机ping PC1主机:
wps_clip_image-4417
wps_clip_image-15883
PC2主机ping PC3主机:
wps_clip_image-7475
wps_clip_image-17049
PC3主机ping PC2主机:
wps_clip_image-28541
wps_clip_image-8314
查看VPN在R1上的协商内容和查看全局配置(相关内容):
wps_clip_image-31156
[R1]dis cu
  Now create configuration...
  Current configuration
  !
    version 1.74
    local-user user1 service-type administrator password simple 123
    sysname R1
    undo pos-server addr-switch
    firewall enable
    aaa-enable
    aaa accounting-scheme optional
  !
ike pre-shared-key 12345 remote 10.3.3.1
  ike pre-shared-key abcde remote 10.2.2.1
  !
  acl 3001 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 permit ip source 192.168.3.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
    rule normal deny ip source any destination any
  !
  acl 3002 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 permit ip source 192.168.2.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
    rule normal deny ip source any destination any
  !
  ipsec proposal tran1
    esp-new authentication-algorithm sha1-hmac-96
  !
  ipsec policy policy1 10 isakmp
    security acl 3001
    proposal tran1
    tunnel remote 10.2.2.1
  !
  ipsec policy policy1 20 isakmp
    security acl 3002
    proposal tran1
    tunnel remote 10.3.3.1
  !
  interface Ethernet0
    ip address 192.168.1.1 255.255.255.0
  !
  interface Ethernet1
    ip address 10.1.1.1 255.255.255.0
    ipsec policy policy1
  !
  quit
ip route-static 0.0.0.0 0.0.0.0 10.1.1.2 preference 60
  !                                   
  return
[R1]
查看VPN在R2上的协商内容和查看全局配置(相关内容):
wps_clip_image-12264
[R2]dis cu
  Now create configuration...
  Current configuration
  !
    version 1.74
    local-user user1 service-type administrator password simple 123
    sysname R2
    undo pos-server addr-switch
    firewall enable
    aaa-enable
    aaa accounting-scheme optional
  !
ike pre-shared-key abcde remote 10.1.1.1
  !
  acl 3001 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 permit ip source 192.168.2.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
    rule normal deny ip source any destination any
  !
  ipsec proposal tran1
    esp-new authentication-algorithm sha1-hmac-96
  !
  ipsec policy policy1 10 isakmp
    security acl 3001
    proposal tran1
    tunnel remote 10.1.1.1
  !
  interface Ethernet0
    ip address 192.168.2.1 255.255.255.0
  !
  interface Ethernet1
    ip address 10.2.2.1 255.255.255.0
ipsec policy policy1
  !
  !
  quit
ip route-static 0.0.0.0 0.0.0.0 10.2.2.2 preference 60
  !
  return
[R2]
查看VPN在R3上的协商内容和查看全局配置(相关内容):
wps_clip_image-29777
[R3]dis cu
  Now create configuration...
  Current configuration
  !
    version 1.74
    sysname R3
    firewall enable
    aaa-enable
    aaa accounting-scheme optional
  !
ike pre-shared-key 12345 remote 10.1.1.1
  !
  acl 3001 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 permit ip source 192.168.3.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
    rule normal deny ip source any destination any
  !
  ipsec proposal tran1
    esp-new authentication-algorithm sha1-hmac-96
  !
ipsec policy policy1 20 isakmp
    security acl 3001
    proposal tran1
    tunnel remote 10.1.1.1
  !
  interface Ethernet0
    ip address 192.168.3.1 255.255.255.0
  !
  interface Ethernet1
    ip address 10.3.3.1 255.255.255.0
ipsec policy policy1
  !
  quit
ip route-static 0.0.0.0 0.0.0.0 10.3.3.2 preference 60
  !
  return
小结:
在VPN网关上想要实现多个IPSes策略时,需要注意三点:
1、需要多个相应的扩展ACL;
例如:
acl 3001
rule …
acl 3002
rule …
2、需要使用同一个策略名,并且使用不同的编号来进行区分;而且只需要在端口上引用一次;
例如:
ipsec policy policy1 10 isakmp
...
ipsec policy policy1 20 isakmp
...
interface Ethernet1
ipsec policy policy1
3、如果策略配置为手工匹配,每个策略上的SPI必须是不同的;
---------------------------------------------------------------------
一:IPSec概述
IPSec(IP Security)协议族是IETF制定的一系列协议,它为ip数据包提供了高质量的、可互操作的、基于密码学的安全性。特定通信方之间
在ip层通过加密与数据源验证等方式,来保证数据包在网络上传输时的私有性、完整性、真实性和防重放
1:私有性指对用户数据进行加密保护,用密文的形式传送
2:完整性指对接收的数据进行验证,以判定报文是否被篡改
3:真实性指验证数据源,以保证数据来自真实的发送者
4:防重放指防止恶意用户通过重复发送捕获到的数据包所进行的攻击,即接收方会拒绝旧的或重复的数据包
IPSec 是网络层的安全机制。通过对网络层包信息的保护,上层应用程序即使没有实现安全性,也能够自动从网络层提供的安全性中获益。这
打消了人们对VPN(Virtual Private Network,虚拟专用网络)安全性的顾虑。使得VPN 得以广泛应用。
二:IPSec的两种工作模式:传输模式和隧道模式
1:在AH协议中,传输模式只在数据的前面加上了一个AH字段,而原ip数据包头在显示在整个数据报的前面,在这中模式中,源ip地址是不
加认证发送的;在隧道模式中,源ip地址被隐藏在在AH协议字段中,在最前面新加上了一个ip包头,这种模式对原始ip数据报都进行了验证。
image
2:在ESP协议中,传输模式只在数据部分的前面加上了一个ESP头部,在数据部分的前面加上了ESP尾部和ESP验证,而原ip数据包头在显
示在整个数据报的前面,在这种模式中,源ip地址是不加密发送的。在隧道模式中,将源ip数据报全部包含在ESP中,最前面加上了一个新ip
包头,尾部加上了一个ESP验证。这种模式对原始ip数据报都进行了加密和认证
image 
三:IPSec使用安全协议:
1:AH(认证头,协议号51):是一个用户提供ip数据报完整性和认证的机制。其完整性是保证数据包不被无意的或恶意的方式改变。它是
通过散列算法来保证数据的完整性,散列算法是一种单向算法,首先将数据进行散列算法,得到一个散列值,然后重新计算得到的散列值同传
送过来的散列值相比较,如果相同则表示数据是完整的,如不同则表示数据被改动过。常见的散列算法有:HMAC-MD5(128位保密密钥)
和HMAC-SHA-1(160位保密密钥)。AH不提供数据的加密机制,只提供数据的完整性的认证
2:ESP(封装安全荷载):ESP提供IP数据报的完整性和可信心服务。它可以对数据进行认证,认证方法主要是散列算法(HMAC-MD5和
HMAC-SHA-1),并且可以对数据进行加密。加密算法有:des、3des等。
3:IKE(因特网密钥交换协议):ike是混合协议,其中包含部分oakley协议以及内置在ISAKMP协议中的部分SKEMK协议,所以ike也可以
写作ISAKMP/oakley,它是针对密钥安全的是用来保证密钥的安全传输、交互以及存储,主要针对密钥进行操作
四:安全联盟(SA)
1:安全联盟(SA)是IPsec的基础,也是本质。SA是通信对等体间对某些要素的约定。例如:使用哪种协议(AH、ESP)、协议的操作模
式(隧道模式和传输模式)、加密算法(DES、3DES等)、特定流中保护数据的共享密钥以及密钥的生存周期等
2:安全联盟(SA)是单向的、在两个对等体之间的双向通信,最少需要两个安全联盟来分别两个方向的数据流进行安全保护。安全联盟由一
个三元组来唯一标识,这个三元组包括SPI(安全参数索引)、目的ip地址、安全协议号(AH或ESP)。SPI是为唯一标识SA而生成的一个32
比特的数据,他在AH或ESP投中传输。
3:安全联盟可通过手工配置(manual)和自动协商(ISAKMP)两种方式建立。手工建立(manual)安全联盟的方式是指用户通过在两端
手工设置一些参数,然后在接口上应用安全策略建立安全联盟。自动协商方式(ISAKMP)由IKE 生成和维护,通信双方基于各自的安全策略
库经过匹配和协商,最终建立安全联盟而不需要用户的干预。手动方式配置相对
复杂,对于节点较多的情况则使用自动协商方式比较合适。
案例:
1:原理:如图所以:R9路由器为北京所在总公司,R6和R14是下属的分支机构,通过在这个三个路由器上配置IPSec实现总公司与分支机构
的网络互通。
2:拓扑方案:
image 
3:配置:
R9:
[R9]int e 0
[R9-Ethernet0]ip add 172.16.1.1 24
[R9-Ethernet0]int e 1
[R9-Ethernet1]ip add 192.168.1.1 24
[R9-Ethernet1]qu
[R9]acl 3000
[R9-acl-3000]rule permit ip source 192.168.1.0 0.0.0.255 des 192.168.2.0 0.0.0.255    #创建acl,允许192.168.1.0/24网段访问192.168.2.0/24
[R9-acl-3000]rule deny ip source any des any      #其他的流量全部拒绝
[R9]acl 3001
[R9-acl-3001]rule permit ip source 192.168.1.0 0.0.0.255 des 192.168.3.0 0.0.0.255    #创建acl,允许192.168.1.0/24网段访问192.168.3.0/24
[R9-acl-3001]rule deny ip sour any des any
[R9-acl-3001]qu
[R9]ipsec proposal tran1      #定义安全提议tran1
[R9-ipsec-proposal-tran1]encapsulation-mode  tunnel    #选择隧道模式tunnel
[R9-ipsec-proposal-tran1]transform esp-new        #选择安全协议esp
[R9-ipsec-proposal-tran1]esp-new encryption-algorithm des      #选择加密算法des
[R9-ipsec-proposal-tran1]esp-new authentication-algorithm sha1-hmac-96      #选择认证方式sha1-hmac-96
[R9-ipsec-proposal-tran1]qu
[R9]ipsec policy policy1 10 isakmp      #使用自动协商方式建立安全联盟SA,策略命名为policy1,编号10
[R9-ipsec-policy-policy1-10]secur acl 3000       #使用acl3000 ,定义需要加密的流量
[R9-ipsec-policy-policy1-10]tunnel remote 172.16.2.1      #设置安全隧道的终点
[R9-ipsec-policy-policy1-10]proposal tran1      #配置安全策略中的使用的安全提议
[R9-ipsec-policy-policy1-10]qu
[R9]ipsec policy policy1 11 isakmp      #使用自动协商方式建立安全联盟SA,策略命名为policy1,编号11
[R9-ipsec-policy-policy1-11]secur acl 3001          #使用acl3001,定义需要加密的流量
[R9-ipsec-policy-policy1-11]tunnel remote 172.16.3.1      #设置安全隧道的终点
[R9-ipsec-policy-policy1-11]proposal tran1       #配置安全策略中的使用的安全提议
[R9-ipsec-policy-policy1-11]qu
[R9]int e 0
[R9-Ethernet0]ipsec policy policy1          #将安全策略policy1运用在端口上
[R9]ike pre-shared-key abcd remote 172.16.2.1         #定义通信双方预共享认证密钥abcd,隧道终点为172.16.2.1
[R9]ike pre-shared-key abcde remote 172.16.3.1        #定义通信双方预共享认证密钥abcde,隧道终点为172.16.3.1
[R9]ip route 0.0.0.0 0.0.0.0 172.16.1.2        #配置静态路由,使数据能够发送向互联网

R6:
[R6]int e 0
[R6-Ethernet0]ip add 172.16.2.1 24
[R6-Ethernet0]int e 1
[R6-Ethernet1]ip add 192.168.2.1 24
[R6-Ethernet1]qu
[R6]acl 3000
[R6-acl-3000]rule permit ip source 192.168.2.0 0.0.0.255 des 192.168.1.0 0.0.0.255
[R6-acl-3000]rule deny ip source any dest any
[R6]ipsec proposal proposal1
[R6-ipsec-proposal-proposal1]encapsulation-mode tunnel     #与R9上的模式选择必须相同
[R6-ipsec-proposal-proposal1]transform esp-new        #与R9上的选择的安全协议相同
[R6-ipsec-proposal-proposal1]esp-new encryption-algorithm des      #与R9上的加密方法相同
[R6-ipsec-proposal-proposal1]esp-new authentication-algorithm sha1-hmac-96      #与R9上的认证方法相同
[R6-ipsec-proposal-proposal1]qu
[R6]ipsec policy policy1 10 isakmp
[R6-ipsec-policy-policy1-10]secur acl 3000
[R6-ipsec-policy-policy1-10]tunnel remote 172.16.1.1
[R6-ipsec-policy-policy1-10]proposal proposal1
[R6-ipsec-policy-policy1-10]qu
[R6]int  e0
[R6-Ethernet0]ipsec policy policy1
[R6-Ethernet0]qu
[R6]ip route 0.0.0.0 0.0.0.0 172.16.2.2 
[R6]ike pre-shared-key abcd remote 172.16.1.1        #与R9上在同一链路的共享密钥保持一致

R16:
[r16]interface e0
[r16-Ethernet0]ip add 172.16.3.1 255.255.255.0
[r16]interface e 1
[r16-Ethernet1]ip add 192.168.3.1 255.255.255.0
[r16]acl 3000
[r16-acl-3000]rule permit ip source 192.168.3.0 0.0.0.255 dest 192.168.1.0 0.0.0.255
[r16-acl-3000]rule deny ip source any dest any
[r16-acl-3000]qu
[r16]ipsec proposal tran1
[r16-ipsec-proposal-tran1]encapsulation-mode tunnel       #与R9上选择相同模式
[r16-ipsec-proposal-tran1]transform esp-new           #与R9上选择相同的安全协议
[r16-ipsec-proposal-tran1]esp-new encryption-algorithm des        #与R9选择相同的加密算法
[r16-ipsec-proposal-tran1]esp-new authentication-algorithm sha1-hmac-96         #与R9采用相同的认证机制
[r16-ipsec-proposal-tran1]qu
[r16]ipsec policy policy1 10 isakmp
[r16-ipsec-policy-policy1-10]tunnel remote 172.16.1.1
[r16-ipsec-policy-policy1-10]proposal tran1
[r16-ipsec-policy-policy1-10]security acl 3000
[r16]interface e 0
[r16-Ethernet0]ipsec policy policy1
[r16-Ethernet0]qu
[r16]ip route-static 0.0.0.0 0.0.0.0 172.16.3.2
[r16]ike pre-shared-key abcde remote 172.16.1.1        #与R9上在同一链路的共享密钥保持一致

中间防火墙模拟互联网,简单配置:
image
image
测试:
1:测试R9到两个分支机构R6和R16的连通性:
image
image
2:测试分支机构R6和R16到总公司R9的网络连通性:
image
image
3:查看R9的安全倡议、安全策略:
image
image
查看R9、的安全联盟,在R9上要建立起两个安全联盟SA:
image
image
4:查看R6的安全倡议、安全策略及安全联盟:
image
image
image
5:查看R16的安全倡议、安全策略及安全联盟:
image
image
image

-------------------------------------------------------------------------------------------
一、基本原理及相关知识的介绍!
image
image
image
image
image
image
image
image
相关知识:
image
image
image
image

二、案例:(利用IKE动态)
1. 作业要求:
在公司与分支机构之间实现跨Internet的通信。用Ipsec 实现 vpn 在总部与公司建立隧道来实现!
2. 拓扑图:
image
IP 地址分配情况:
R7  Loopback 1 192.168.1.1 /24
      Ethernet 1 200.100.1.1 /24
S1  Ethernet 0/1 200.100.1.2/24  (中间的交换机
      Ehternet 0/2 200.100.2.1/24
      Ethernet 0/3 200.100.3.1/24
F1  Ethernet 0/1 200.100.2.2/24
     Ethernet 0/2 192.168.2.1 /24
F2  Ethernet 0/1 200.100.3.2/24
     Ethernet 0/2 192.168.3.1 /24
3. 设备描述:
路由器: H3C Quidway R2621
交换机: H3C Quidway S3526E
防火墙: H3C SecPath F100-c
4. 配置如下:
路由器配置:
  • 配ip
[Router]sysname r7
[r7]int loopback 1
[r7-LoopBack1]ip add 192.168.1.1 255.255.255.0
[r7-LoopBack1]int e1
[r7-Ethernet1]ip add 200.100.1.1 255.255.255.0
  • 配默认路由:
[r7]ip route 0.0.0.0 0.0.0.0 200.100.1.2
  • 配访问控制列表:
[r7]acl 3000
[r7-acl-3000]rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
[r7-acl-3000]rule deny ip source any dest any
[r7]acl 3001
[r7-acl-3001]rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
[r7-acl-3001]rule deny ip source any dest any
  • 配安全提议:
[r7]ipsec proposal gjp1   名称随意
[r7-ipsec-proposal-gjp1]encapsulation tunnel
[r7-ipsec-proposal-gjp1]transform esp-new
[r7-ipsec-proposal-gjp1]esp encryp des
[r7-ipsec-proposal-gjp1]esp auth md5
[r7-ipsec-proposal-gjp1]dis ipsec propo  //显示配置的提议
proposal set name: gjp1
proposal set mode: tunnel
transform: esp-new
ESP protocol: authentication md5-hmac-96, encryption-algorithm des
[r7]ipsec policy py1 10 isakmp //动态
[r7-ipsec-policy-py1-10]security acl 3000
[r7-ipsec-policy-py1-10]proposal gjp1 //安全协议采用 ESP协议
[r7-ipsec-policy-py1-10]tunnel remote 200.100.2.2  使用隧道的对端IP
[r7-ipsec-policy-py1-10]ike pre-shared-key abc remote 200.100.2.2
[r7-ipsec-policy-py1-10]quit
[r7]int e1
[r7-Ethernet1]ipsec policy py1
[r7]dis ipsec policy all
ipsec policy name: py1
ipsec policy sequence: 10
negotiation mode: isakmp
security acl: 3000
remote address 0: 200.100.2.2
Proposal name: gjp1
ipsec sa duration: 3600 seconds
ipsec sa duration: 1843200 kilobytes
OutBound SA has NOT been established.
InBound SA has NOT been established.
[r7]ipsec policy py1 11 isakmp
[r7-ipsec-policy-py1-11]sec acl 3001
[r7-ipsec-policy-py1-11]proposal gjp1
[r7-ipsec-policy-py1-11]tunnel remote 200.100.3.2
[r7]ike pre-shared-key abc remote 200.100.3.2  //钥匙双方要一致
交换机配置:
<Quidway>sys
[Quidway]vlan 10   建vlan
[Quidway-vlan10]port e0/1   加接口
[Quidway-vlan10]vlan 20
[Quidway-vlan20]port e0/2
[Quidway-vlan20]vlan 30
[Quidway-vlan30]port e0/3
[Quidway-vlan30]quit
[Quidway]int vlan 10   进入接口
[Quidway-Vlan-interface10]ip add 200.100.1.2 255.255.255.0  配ip
[Quidway-Vlan-interface10]int vlan 20
[Quidway-Vlan-interface20]ip add 200.100.2.1 255.255.255.0
[Quidway-Vlan-interface20]int vlan 30
[Quidway-Vlan-interface30]ip add 200.100.3.1 255.255.255.0

第一个防火墙(f1) 配置:
  • 配IP:
H3C] int eth0/1
[H3C-Ethernet0/1]ip add 200.100.2.2 255.255.255.0
[H3C-Ethernet0/1]int et0/2
[H3C-Ethernet0/2]ip add 192.168.2.1 255.255.255.0
  • 添加区域:
[H3C]firewall zone untrust
[H3C-zone-untrust]add interface eth0/1
[H3C-zone-untrust]quit
[H3C]firewall zone trust
[H3C-zone-trust]add interface eth0/2
  • Acl
[H3C]acl number 3000
[H3C-acl-adv-3000]rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
[H3C-acl-adv-3000]rule deny ip source any dest any
[H3C-acl-adv-3000]QUIT
  • 默认路由:
[H3C]ip route-static 0.0.0.0 0.0.0.0 200.100.2.1
创建名为gjp2的安全提议:
[H3C]ipsec proposal gjp2
[H3C-ipsec-proposal-gjp2]encapsulation-mode tunnel //报文封装形式采用隧道模式
[H3C-ipsec-proposal-gjp2]transform esp //安全协议采用 ESP协议
[H3C-ipsec-proposal-gjp2]esp encryption-algorithm des //选择算法
[H3C-ipsec-proposal-gjp2]esp authentication-algorithm md5 //选择认证
  • 配IKE对等体
[H3C]ike peer r1 (名字可随意)
[H3C-ike-peer-r1]pre-shared-key abc //双方要一致
[H3C-ike-peer-r1]remote-address 200.100.1.1 //隧道对端的ip
  • 创建一条安全策略,协商方式为isakmp
[H3C]ipsec policy py2 10 isakmp
[H3C-ipsec-policy-isakmp-py2-10]security acl 3000 //引用访问控制列表
[H3C-ipsec-policy-isakmp-py2-10]proposal gjp2 // 引用安全提议
[H3C-ipsec-policy-isakmp-py2-10]ike-peer r1 //引用IKE对等体
[H3C]int et0/1
[H3C-Ethernet0/1]ipsec policy py2 //应用安全策略
测试:使用一台PC
clip_image004
C:\Users\Administrator&gt;ping 192.168.1.1 //公司总部的IP
正在 Ping 192.168.1.1 具有 32 字节的数据:
请求超时。
来自 192.168.1.1 的回复: 字节=32 时间=8ms TTL=254
来自 192.168.1.1 的回复: 字节=32 时间=8ms TTL=254
第二个防火墙(f2)配置:
[H3C]int eth0/1
[H3C-Ethernet0/1]ip add 200.100.3.2 24
[H3C-Ethernet0/1]int eth0/2
[H3C-Ethernet0/2]ip add 192.168.3.1 24
[H3C-Ethernet0/2]qu
[H3C]firewall zone trust
[H3C-zone-trust]add interface eth0/2
[H3C-zone-trust]qu
[H3C]firewall zone untrust
[H3C-zone-untrust]add interface eth0/1
[H3C-zone-untrust]qu
[H3C]acl number 3000
[H3C-acl-adv-3000]rule permit ip source 192.168.3.0 0.0.0.255 dest 192.168.1.0 0.0.0.255
[H3C-acl-adv-3000]rule deny ip source any dest any
[H3C-acl-adv-3000]qu
[H3C]ip route-static 0.0.0.0 0.0.0.0 200.100.3.1
(其他的参考第一个防火墙的配置)
测试:使用一台PC
clip_image006
clip_image008
C:\Users\Administrator&gt;ping 192.168.1.1
正在 Ping 192.168.1.1 具有 32 字节的数据:
请求超时。
来自 192.168.1.1 的回复: 字节=32 时间=9ms TTL=254
来自 192.168.1.1 的回复: 字节=32 时间=7ms TTL=254
来自 192.168.1.1 的回复: 字节=32 时间=9ms TTL=254