ipsec(ike野蛮模式)
IPSEC野蛮模式 简介:
IKE 的协商模式
在RFC2409标准中明确规定,在IKE第一阶段的协商过程中可采取两种不同的方式:其中一种为主模式(Main Mode),另一种为野蛮模式(Aggressive Mode),并分别附有相应的注释以说明缩略语的含义。
该模式旨在将密钥交换信息与其相关的身份和认证信息分开处理;通过这种方式进行区分后,在接收端能够分别验证身份和确认通信内容;发送端的身份验证则依赖于已存在的Diffie-Hellman共享密钥。然而这会带来一定的通信开销
野蛮模式则允许同时传输与SA、密钥交换及认证相关的负载。将这些负载整合到一条消息中减少了来回通信次数这一做法虽然有效率优势但牺牲了身份验证功能这一特性使其无法满足对安全要求较高的网络环境需求然而在特定应用场景下这种设计策略仍是可行的选择例如在远程访问场景中当响应端无法预先获取发起端地址或者发起端地址频繁变更且双方均希望通过预共享密钥方法建立IKE SA连接时不带身份验证的野蛮模式便成为唯一可选的解决方案此外如果发起方已知响应方的具体策略或者对响应方有一定的控制权那么也可以通过其他方式实现安全通信
野蛮模式的作用:
对于两端的IP地址不是固定的状况(如使用ADSL拨号上网),以及双方均希望采用预共享密钥验证方法来建立 IKE SA 的情况下,则必须采取野蛮模式进行处理。此外,在这种情况下,如果发起者了解回应者的具体策略时,则 wildjave 可以加快 IKE SA 的建立速度。
ipsec下两种模式的区别:
相较于主模式协商,在野蛮模式协商中所需的时间更少。在主模式中需要进行6次交互,在野蛮模式中则只需3次交互
主模式协商相较于野蛮模式协商更为严谨与安全。这是因为主模式经过五个至六个消息对身份信息进行了加密处理;而野蛮模式受限于交换次数限制,在一至两个消息中直接以明文形式传递身份信息给对端方块即主模式对身份进行了有效保护;反之野蛮模式则无法实现这一层身份验证功能方块
3、两种模式在确定预共享密钥的方式上存在差异。主模式仅限于通过IP地址来确定预共享密钥。而积极模式则依靠ID信息(包括主机名和IP地址)来确定预共享密钥。
野蛮模式的必要性:
当两边均为主机名称时,则必须强制采用粗暴模式进行协商;若选择主模式,则会导致无法检索源IP对应的预共享密钥信息而无法生成相应的SKEYID标识符。
当主模式完成3号和4号消息的交换后, 便需要利用预共享密钥来计算SKEYID. 然而, 双方所需的ID信息仅在第5号和6号消息发送之后才会被获取到. 因此, 在此阶段的情况下,默认情况下, 主模式只能利用第3条和第4条消息中的源IP地址来获取相应的预共享密钥. 如果采用主机名的方式, 这时双方所需的主机名信息却位于第5号和6号 msg 中, 而根据IPSEC的规定, 双方都需要在此前就已经确定各自的预共享密钥. 这就导致了不可调和的矛盾.
在野蛮模式下,在消息1和2中已经包含了作为身份标识的信息(IP地址或主机名)。这些身份标识可以让接收方通过该信息确定相应的预共享密钥,并据此计算出SKEYID值。
案例
本实验通过配置三台华为F100防火墙及一台华为S3526交换机来完成IPsec野蛮模式下的通道建立。作为中心节点的FW1实现了与其他FW之间的内部网络互访功能。FW1不仅实现了与FW2的内部网络互访,还实现了与FW3的内部网络互访。此外,FW2和FW3之间通过 DHCP 服务器进行动态地址分配。
实验图:
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036561qr77.png)
fw1 的配置:
Change language mode, confirm? [Y/N]y
% 改变到中文模式。
进入系统视图, 键入Ctrl+Z退回到用户视图.
配置ip
[F1]firewall zone trust
[F1-zone-trust]add interface Ethernet 0/4
接口已经加入到untrust安全区域了.
[F1-zone-trust]quit
[F1]firewall zone untrust
[F1-zone-untrust]add interface Ethernet 0/1
接口已经加入到DMZ安全区域了.
[F1-zone-untrust]quit
[F1]interface Ethernet0/4
[F1-Ethernet0/4]ip add 192.168.10.1 24
[F1-Ethernet0/4]interface Ethernet0/1
[F1-Ethernet0/1]ip add 192.168.110.200 24
[F1-Ethernet0/1]
%2012/3/29 19:26:47:341 F1 IFNET/4/UPDOWN:链路协议在接口Ethernet0/1上状态变为UP
[F1-Ethernet0/1]quit
默认路由:
[F1]ip route-static 0.0.0.0 0.0.0.0 192.168.110.1
定义ACL实现对数据流的过滤
[F1]acl number 3000
[F1-acl-adv-3000]rule permit ip source 192.168.110.0 0.0.0.255 destination 192.168.120.0 0.0.0.255
[F1-acl-adv-3000]rule deny ip source any destination any
[F1-acl-adv-3000]quit
[F1]acl number 3001
[F1-acl-adv-3001]rule permit ip source 192.168.110.0 0.0.0.255 destination 192.168.130.0 0.0.0.255
[F1-acl-adv-3001]rule deny ip source any destination any
[F1-acl-adv-3001]quit
配置安全提议 :
[F1]ipsec proposal tran1 创建名为tran1的安全协议
$[F1-ipsec-proposal-tran1]encapsulation-mode tunnel 报文封装形式应用了隧道模方案
[F1-ipsec-proposal-tran1]transform esp 安全协议采用esp协议
[F1-ipsec-proposal-tran1]esp encryption-algorithm des 选择加密算法
[F1-ipsec-proposal-tran1]esp authentication-algorithm md5 认证算法
[F1-ipsec-proposal-tran1]quit
[F1]ipsec proposal tran2 创建名为tran2的安全协议
[F1-ipsec-proposal-tran2]encapsulation-mode tunnel
[F1-ipsec-proposal-tran2]transform esp
[F1-ipsec-proposal-tran2] esp encryption-algorithm des
[F1-ipsec-proposal-tran2]esp authentication-algorithm md5
[F1-ipsec-proposal-tran2]quit
创建IKE Peer并进入IKE Peer视图:
[F1]ike local-name fw1 配置IKE协商时的本地ID
[F1]ike peer peer1
[F1-ike-peer-peer1]exchange-mode aggressive 配置IKE协商方式为野蛮模式
[F1-ike-peer-peer1]pre-shared-key simple 123456 配置预共享密钥
[F1-ike-peer-peer1]id-type name 配置对端ID类型
[F1-ike-peer-peer1]remote-name fw2 配置对端名称
[F1-ike-peer-peer1]quit
[F1]ike peer peer2
[F1-ike-peer-peer2]exchange-mode aggressive
[F1-ike-peer-peer2]pre-shared-key simple abcdef
[F1-ike-peer-peer2]id-type name
[F1-ike-peer-peer2]remote-name fw3
[F1-ike-peer-peer2]quit
创建安全策略,协商方式为动态方式
[F1]ipsec poli policy1 10 isakmp
[F1-ipsec-policy-isakmp-policy1-10]proposal tran1 引用安全提议
[F1-ipsec-policy-isakmp-policy1-10]security acl 3000 引用访问列表
[F1-ipsec-policy-isakmp-policy1-10]ike-peer peer1
[F1-ipsec-policy-isakmp-policy1-10]quit
[F1]ipsec poli policy1 20 isakmp
[F1-ipsec-policy-isakmp-policy1-20]proposal tran2
[F1-ipsec-policy-isakmp-policy1-20]security acl 3001
[F1-ipsec-policy-isakmp-policy1-20]ike-peer peer2
[F1-ipsec-policy-isakmp-policy1-20]quit
在接口上应用安全策略组:
[F1]interface Ethernet0/1
[F1-Ethernet0/1]ipsec policy policy1
[F1-Ethernet0/1]quit
查看配置信息:
[

](https://s1.51cto.com/attachment/201203/29/4449121_133303656279EB.png)
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036562vCT6.png)
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036566apOZ.png)
[

](https://s1.51cto.com/attachment/201203/29/4449121_13330365677N5R.png)
fw2 的配置:
Change language mode, confirm? [Y/N]y
% 改变到中文模式。
进入系统视图, 键入Ctrl+Z退回到用户视图.
[F2]firewall zone trust
[F2-zone-trust]add interface Ethernet 0/4
[F2-zone-trust]quit
[F2]firewall zone untrust
[F2-zone-untrust]add interface Ethernet 0/1
[F2-zone-untrust]quit
[F2]inter Ethernet0/4
[F2-Ethernet0/4]ip add 192.168.20.1 24
[F2-Ethernet0/4]inter Ethernet0/1
[F2-Ethernet0/1]ip address dhcp-alloc 配置dhcp动态获取地址
[F2-Ethernet0/1]
%2012/3/29 19:48:16:393 F2 IFNET/4/UPDOWN:链路协议在接口Ethernet0/1上状态变为UP
[F2-Ethernet0/1]quit
[F2] ip route-static 0.0.0.0 0.0.0.0 192.168.120.1
[F2]acl number 3000
[F2-acl-adv-3000]rule permit ip source 192.168.120.0 0.0.0.255 destination 192.168.110.0 0.0.0.255
[F2-acl-adv-3000]rule deny ip source any destination any
[F2-acl-adv-3000]quit
[F2]ipsec proposal tran1
[F2-ipsec-proposal-tran1]encapsulation-mode tunnel
[F2-ipsec-proposal-tran1]transform esp
[F2-ipsec-proposal-tran1]esp encryption-algorithm des
[F2-ipsec-proposal-tran1]esp authentication-algorithm md5
[F2-ipsec-proposal-tran1]quit
[F2]ike local-name fw2
[F2]ike peer peer1
[F2-ike-peer-peer1]exchange-mode aggressive
[F2-ike-peer-peer1]pre-shared-key simple 123456
[F2-ike-peer-peer1]id-type name
[F2-ike-peer-peer1]remote-name fw1
[F2-ike-peer-peer1]quit
[F2]ipsec poli policy2 10 isakmp
[F2-ipsec-policy-isakmp-policy2-10]proposal tran1
[F2-ipsec-policy-isakmp-policy2-10]security acl 3000
[F2-ipsec-policy-isakmp-policy2-10]ike-peer peer1
[F2-ipsec-policy-isakmp-policy2-10]quit
[F2]inter Ethernet0/1
[F2-Ethernet0/1]ipsec policy policy2
[F2-Ethernet0/1]quit
查看配置信息:
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036568bEJ4.png)
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036571m8Bp.png)
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036572c6CS.png)
[

](https://s1.51cto.com/attachment/201203/29/4449121_133303657334eZ.png)
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036575mhBx.png)
fw3 的配置:
Change language mode, confirm? [Y/N]y
% 改变到中文模式。
进入系统视图, 键入Ctrl+Z退回到用户视图.
[F3]firewall zone trust
[F3-zone-trust]add interface Ethernet 0/4
[F3-zone-trust]quit
[F3]firewall zone untrust
[F3-zone-untrust]add interface Ethernet 0/1
[F3-zone-untrust]quit
[F3]inter Ethernet0/4
[F3-Ethernet0/4]ip add 192.168.30.1 24
[F3-Ethernet0/4]inter Ethernet0/1
[F3-Ethernet0/1]ip address dhcp-alloc
[F3-Ethernet0/1]
%2012/3/29 19:06:42:711 F3 IFNET/4/UPDOWN:链路协议在接口Ethernet0/1上状态变为UP
[F3-Ethernet0/1]quit
[F3]ip route-static 0.0.0.0 0.0.0.0 192.168.130.1
[F3]acl number 3000
[F3-acl-adv-3000]rule permit ip source 192.168.130.0 0.0.0.255 destination 192.168.110.0 0.0.0.255
[F3-acl-adv-3000]rule deny ip source any destination any
[F3-acl-adv-3000]quit
[F3]ipsec proposal tran2
[F3-ipsec-proposal-tran2]encapsulation-mode tunnel
[F3-ipsec-proposal-tran2]transform esp
[F3-ipsec-proposal-tran2]esp encryption-algorithm des
[F3-ipsec-proposal-tran2]esp authentication-algorithm md5
[F3-ipsec-proposal-tran2]quit
[F3]ike local-name fw3
[F3]ike peer peer2
[F3-ike-peer-peer2]exchange-mode aggressive
[F3-ike-peer-peer2]pre-shared-key simple abcdef
[F3-ike-peer-peer2]id-type name
[F3-ike-peer-peer2]remote-name fw1
[F3-ike-peer-peer2]quit
[F3]ipsec poli policy3 20 isakmp
[F3-ipsec-policy-isakmp-policy3-20]proposal tran2
[F3-ipsec-policy-isakmp-policy3-20]security acl 3001
[F3-ipsec-policy-isakmp-policy3-20]ike-peer peer2
[F3-ipsec-policy-isakmp-policy3-20]quit
[F3]inter Ethernet0/1
[F3-Ethernet0/1]ipsec policy policy3
查看配置信息:
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036579M8yq.png)
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036580VYHC.png)
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036582pLWK.png)
Switch1 的配置:
Change language mode, confirm? [Y/N]y
% 改变到中文模式。
进入系统视图, 键入Ctrl+Z退回到用户视图.
划分vlan,并把他们加入接口:
[SW1]vlan 10
[SW1-vlan10]port Ethernet0/1
[SW1-vlan10]vlan 20
[SW1-vlan20]port Ethernet0/5
[SW1-vlan20]vlan 30
[SW1-vlan30]port Ethernet0/3
[SW1-vlan30]inter
[SW1-vlan30]quit
配置vlan地址:
[SW1]interface Vlan-interface 10
[SW1-Vlan-interface10]
%2012/3/29 20:13:12:150 SW1 L2INF/5/VLANIF LINK STATUS CHANGE:
Vlan-interface10: link状态变为UP
[SW1-Vlan-interface10]ip add 192.168.110.1 255.255.255.0
[SW1-Vlan-interface10]
%2012/3/29 20:13:36:503 SW1 IFNET/5/UPDOWN:
链路协议在接口Vlan-interface10上状态变为UP
[SW1-Vlan-interface10]interface Vlan-interface 20
[SW1-Vlan-interface20]
%2012/3/29 20:13:45:493 SW1 L2INF/5/VLANIF LINK STATUS CHANGE:
Vlan-interface20: link状态变为UP
[SW1-Vlan-interface20]ip add 192.168.120.1 255.255.255.0
[SW1-Vlan-interface20]
%2012/3/29 20:13:55:184 SW1 IFNET/5/UPDOWN:
链路协议在接口Vlan-interface20上状态变为UP
[SW1-Vlan-interface20]interface Vlan-interface 30
[SW1-Vlan-interface30]
%2012/3/29 20:14:02:434 SW1 L2INF/5/VLANIF LINK STATUS CHANGE:
Vlan-interface30: link状态变为UP
[SW1-Vlan-interface30]ip add 192.168.130.1 255.255.255.0
[SW1-Vlan-interface30]
%2012/3/29 20:14:12:405 SW1 IFNET/5/UPDOWN:
链路协议在接口Vlan-interface30上状态变为UP
[SW1-Vlan-interface30]quit
配置dhcp服务:
[SW1]dhcp server ip-pool fw2
[SW1-dhcp-fw2]network 192.168.120.0 mask 255.255.255.0
[SW1-dhcp-fw2]quit
[SW1]dhcp server ip-pool fw3
[SW1-dhcp-fw3]network 192.168.130.0 mask 255.255.255.0
[SW1-dhcp-fw3]quit
[SW1]dhcp enable
DHCP任务已经启动!
查看配置信息:
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036587Phgi.png)
[SW1]dis cu
sysname SW1
local-server nas-ip 127.0.0.1 key huawei
local-user user1
password simple 123
service-type telnet level 3
dhcp server ip-pool fw2
network 192.168.120.0 mask 255.255.255.0
dhcp server ip-pool fw3
network 192.168.130.0 mask 255.255.255.0
vlan 1
vlan 10
vlan 20
vlan 30
interface Vlan-interface10
ip address 192.168.110.1 255.255.255.0
interface Vlan-interface20
ip address 192.168.120.1 255.255.255.0
interface Vlan-interface30
ip address 192.168.130.1 255.255.255.0
interface Aux0/0
interface Ethernet0/1
port access vlan 10
interface Ethernet0/2
interface Ethernet0/3
port access vlan 30
interface Ethernet0/4
interface Ethernet0/5
port access vlan 20
interface Ethernet0/6
interface Ethernet0/7
return
测试:
PC1与PC2,PC3之间的ping访问:

[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036591SYuh.jpg)
PC2与PC1之间的ping访问:
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036592CCAK.png)
PC3与PC1之间的ping访问:
[

](https://s1.51cto.com/attachment/201203/29/4449121_1333036593QKnr.png)
