IPSEC野蠻模式 簡介:
IKE 的協商模式
在RFC2409(The Internet Key Exchange )中規定,IKE 第一階段的協商可以採用兩種模式:主模式(Main Mode )和野蠻模式(Aggressive Mode )。
主模式被設計成將**交換信息與身份、認證信息相分離。這種分離保護了身份信息;交換的身份信息受已生成的 Diffie-Hellman共享**的保護。但這增加了3 條消息的開銷。
野蠻模式則允許同時傳送與SA、**交換和認證相關的載荷。將這些載荷組合到一條消息中減少了消息的往返次數,但是就無法提供身份保護了。雖然野蠻模式存在一些功能限制,但可以滿足某些特定的網絡環境需求。例如:遠程訪問時,如果響應者(服務器端)無法預先知道發起者(終端用戶)的地址、或者發起者的地址總在變化,而雙方都希望採用預共享**驗證方法來創建IKE SA,那麼,不進行身份保護的野蠻模式就是唯一可行的交換方法;另外,如果發起者已知響應者的策略,或者對響應者
野蠻模式的作用:
對於兩端IP地址不是固定的情況(如ADSL撥號上網),並且雙方都希望採用預共享**驗證方法來創建IKE SA,就需要採用野蠻模式。另外如果發起者已知迴應者的策略,採用野蠻模式也能夠更快地創建IKE SA。
ipsec下兩種模式的區別:
1、野蠻模式協商比主模式協商更快。主模式需要交互6個消息,野蠻模式只需要交互3個消息。
2、主模式協商比野蠻模式協商更嚴謹、更安全。因爲主模式在5、6個消息中對ID信息進行了加密。而野蠻模式由於受到交換次數的限制,ID信息在1、2個消息中以明文的方式發送給對端。即主模式對對端身份進行了保護,而野蠻模式則沒有。
3、兩種模式在確定預共享**的方式不同。主模式只能基於IP地址來確定預共享**。而積極模式是基於ID信息(主機名和IP地址)來確定預共享**。
野蠻模式的必要性:
兩邊都是主機名的時候,就一定要用野蠻模式來協商,如果用主模式的話,就會出現根據源IP地址找不到預共享**的情況,以至於不能生成SKEYID。
1、因爲主模式在交換完3、4消息以後,需要使用預共享**來計算SKEYID,但是由於雙方的ID信息在消息5、6中才會被髮送,此時主模式的設備只能使用消息3、4中的源IP地址來找到與其對應的預共享**;如果主模式採用主機名方式,主機名信息卻包含在消息5、6中,而IPSEC雙方又必須在消息5、6之前找到其相應的預共享**,所以就造成了矛盾。
2、在野蠻模式中,ID信息(IP地址或者主機名)在消息1、2中就已經發送了,對方可以根據ID信息查找到對應的預共享**,從而計算出SKEYID。
案例
例:本實驗採用華爲三臺F100防火牆,和一臺s3526交換機,實現ipsec野蠻模式下的***通道的建立。Fw1是總部,實現fw1可以與fw2的內部網絡互訪,fw1和fw3的內部網絡互訪。fw2和fw3通過DHCP服務器動態獲取地址。
實驗圖:
fw1 的配置:
<F1>langu chinese
Change language mode, confirm? [Y/N]y
% 改變到中文模式。
<F1>system-view
進入系統視圖, 鍵入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
查看配置信息:
fw2 的配置:
<F2>langu chin
Change language mode, confirm? [Y/N]y
% 改變到中文模式。
<F2>sys
<F2>system-view
進入系統視圖, 鍵入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
查看配置信息:
fw3 的配置:
<F3>lang chin
Change language mode, confirm? [Y/N]y
% 改變到中文模式。
<F3>sys
<F3>system-view
進入系統視圖, 鍵入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
查看配置信息:
Switch1 的配置:
<SW1>lang chin
Change language mode, confirm? [Y/N]y
% 改變到中文模式。
<SW1>system-view
進入系統視圖, 鍵入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任務已經啓動!
查看配置信息:
[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訪問:
PC2與PC1之間的ping訪問:
PC3與PC1之間的ping訪問: