IPSEC在企業網中的應用

IPSEC在企業網中的應用
1.IPSEC簡介
IPSec 包括安全協議(Security Protocol)和密鑰交換協議(IKE,由IETFInternet Engineering TaskForceInternet 工程任務組)開發的,可爲通訊雙方提供訪問控制、無連接的完整性、數據來源認證、反重放、加密以及對數據流分類加密等服務的一系列網絡安全協議的總稱,其中安全協議又包括AH(頭驗證協議)和ESP(安全封裝載荷);而IKE是一種基於ISAKMPInternet Security Association and Key Management Protocol,互聯網安全關聯和密鑰管理協議)中TCP/IP框架,合併了Oakley(密鑰交換協議)的一部分和SKEME(密鑰技術協議)的混合協議。
2.IPSEC的安全特性
(1)不可否認性"不可否認性"可以證實消息發送方是唯一可能的發送者,發送者不能否認發送過消息。"不可否認性"是採用公鑰技術的一個特徵,當使用公鑰技術時,發送方用私鑰產生一個數字簽名隨消息一起發送,接收方用發送者的公鑰來驗證數字簽名。由於在理論上只有發送者才唯一擁有私鑰,也只有發送者纔可能產生該數字簽名,所以只要數字簽名通過驗證,發送者就不能否認曾發送過該消息。但"不可否認性"不是基於認證的共享密鑰技術的特徵,因爲在基於認證的共享密鑰技術中,發送方和接收方掌握相同的密鑰。  
(2)抗重播性(Anti-Replay): IPsec接收方可根據數據包數據段前加入的32位序列號來檢測每個IP包的唯一性並拒絕接收過時或重複的報文,以防止***者截取破譯信息後,再用相同的信息包冒取非法訪問權(即使這種冒取行爲發生在數月之後)。
(3)數據完整性(Data Integrity): IPsec接收方利用md5,sha-1等哈希算法對發送方發送來的包進行認證,防止傳輸過程中數據被篡改,確保發出數據和接收數據的一致性。  
(4)數據可靠性(Confidentiality)IPsec發送方在通過des,3des,aes等對稱加密算法在網絡傳輸包前對包進行加密,保證在傳輸過程中,即使數據包遭截取,信息也無法被讀。該特性在IPSec中爲可選項,與IPSec策略的具體設置相關。
(5)數據來源認證(Data Authentication):IPsec在接收端通過preshared key(域共享密鑰),證書,kerberos v5等可以認證發送IPsec報文的發送端是否合法。
3.IPSEC的工作模式
  (1)隧道(tunnel)模式:用戶的整個IP數據包被用來計算AHESP頭,AHESP頭以及ESP加密的用戶數據被封裝在一個新的IP數據包中。通常,隧道模式應用在兩個安全網關之間的通訊。
  (2)傳輸(transport)模式:只是傳輸層數據被用來計算AHESP頭,AHESP頭以及ESP加密的用戶數據被放置在原IP包頭後面。通常,傳輸模式應用在兩臺主機之間的通訊,或一臺主機和一個安全網關之間的通訊。
4.IPSEC安全機制中兩種協議的比較
AH協議IP協議號爲51)提供數據源認證、數據完整性校驗和防報文重放功能,它能保護通信免受篡改,但不能防止竊聽,適合用於傳輸非機密數據。AH的工作原理是在每一個數據包上添加一個身份驗證報文頭,此報文頭插在標準IP包頭後面,對數據提供完整性保護。,因爲IP頭部分包含很多變量比如type of service(TOS),flags,fragment offset,TTL以及header checksum。所以這些值在進行authtication前要全部清零。否則hash會mismatch導致丟包。因此AH不支持NAT轉換。
ESP協議IP協議號爲50)提供加密、數據源認證、數據完整性校驗和防報文重放功能。ESP的工作原理是在每一個數據包的標準IP包頭後面添加一個ESP報文頭,並在數據包後面追加一個ESP尾。與AH協議不同的是,ESP將需要保護的用戶數據進行加密後再封裝到IP包中,以保證數據的機密性。
下圖更好的解釋了AHESPIPSEC兩種工作模式下對數據包的加密與認證

5.IPsec基本概念(基於H3C)
1. 數據流: IPSec 中,一組具有相同源地址/掩碼/端口、目的地址/掩碼/端口和上層協議的數據集稱爲數據流。通常,一個數據流採用一個訪問控制列表(acl)來定義,所有爲ACL 允許通過的報文在邏輯上作爲一個數據流。
2.安全策略:由用戶手工配置,規定對什麼樣的數據流採用什麼樣的安全措施。對數據流的定義是通過在一個訪問控制列表中配置多條規則來實現,在安全策略中引用這個訪問控制列表來確定需要進行保護的數據流。一條安全策略由“名字”和“順序號”共同唯一確定。
3.安全策略組:所有具有相同名字的安全策略的集合。在一個接口上,可應用或者取消一個安全策略組,使安全策略組中的多條安全策略同時應用在這個接口上,從而實現對不同的數據流進行不同的安全保護。在同一個安全策略組中,順序號越小的安全策略,優先級越高。
4.安全聯盟(Security Association,簡稱SA):IPSec 對數據流提供的安全服務通過安全聯盟SA 來實現,它包括協議、算法、密鑰等內容,具體確定瞭如何對IP 報文進行處理。一個SA 就是兩個IPSec 系統之間的一個單向邏輯連接,輸入數據流和輸出數據流由輸入安全聯盟與輸出安全聯盟分別處理。安全聯盟由一個三元組(安全參數索引(SPI)、IP 目的地址、安全協議號(AHESP))來唯一標識。
安全聯盟可通過手工配置自動協商兩種方式建立。
手工建立安全聯盟的方式是指用戶通過在兩端手工設置
SA的全部信息,然後在接口上應用安全策略建立安全聯盟,缺點是配置複雜,而且不支持一些高級特性(如定時更新密鑰),適用於小型企業。
自動協商方式由
IKE 生成和維護,通信雙方基於各自的安全策略庫經過匹配和協商,最終建立安全聯盟而不需要用戶的干預,配置簡單,適用於大型企業。在自動協商中又分爲主模式野蠻模式,野蠻模式交換與主模式交換的主要差別在於,野蠻模式不提供身份保護。在對身份保護要求不高的場合,使用交換報文較少的野蠻模式可以提高協商的速度;在對身份保護要求較高的場合,則應該使用主模式。
5.安全參數索引(SPI):是一個32 比特的數值,在每一個IPSec 報文中都攜帶該值。SPIIP 目的地址、安全協議號三者結合起來共同構成三元組,來唯一標識一個特定的安全聯盟。在手工配置安全聯盟時,需要手工指定SPI 的取值。爲保證安全聯盟的唯一性,每個安全聯盟需要指定不同的SPI 值;使用IKE協商產生安全聯盟時,SPI 將隨機生成。
6.安全提議:包括安全協議、安全協議使用的算法、安全協議對報文的封裝形式,規定了把普通的IP 報文轉換成IPSec 報文的方式。在安全策略中,通過引用一個安全提議來規定該安全策略採用的協議、算法等。
6.IPsecIPSEC配置步驟
創建加密訪問控制列表

根據是否與加密訪問控制列表匹配,可以確定那些 IP 包加密後發送,那些IP 包直

接轉發。需要保護的安全數據流使用擴展IP 訪問控制列表進行定義。

acl acl-number

rule { normal | special }{ permit | deny } pro-number[source source-addr source-wildcard | any ][source-port operator port1 [ port2 ] ] [ destination dest-addr dest- wildcard | any ][destination-port operator port1 [ port2 ] ] [icmp-type icmp-type icmp-code][logging]

  定義安全提議

 定義安全提議 ipsec proposal proposal-name

設置安全協議對 IP 報文的封裝模式encapsulation-mode { transport | tunnel }

 選擇安全協議transform { ah-new | ah-esp-new | esp-new }

選擇加密算法與認證算法

Esp協議下 transform { ah-new | ah-esp-new | esp-new }

AH協議下  transform { ah-new | ah-esp-new | esp-new }

創建安全策略

手工創建安全策略的配置包括:

  手工創建安全策略ipsec policy policy-name sequence-number manual

     配置安全策略引用的訪問控制列表 security acl access-list-number

 指定安全隧道的起點與終點 tunnel local ip-address

                                                                                 tunnel remote ip-address

  配置安全策略中引用的安全提議 proposal proposal-name

       配置安全策略聯盟的 SPI 及使用的密鑰

SPI的配置                 sa inbound { ah | esp } spi spi-number

sa outbound { ah | esp } spi spi-number

密鑰的配置

AH16進制密鑰   sa { inbound | outbound } ah hex-key-string hex-key

                                            AH 字符密鑰     sa { inbound | outbound } ah string-key string-key

                                           ESP16進制密鑰  sa { inbound | outbound } esp encryption-hex hex-key

                                           ESP字符密鑰    sa { inbound | outbound } esp string-key string-key

     在接口上應用安全策略組

                     ipsec policy policy-name

IKE 創建安全策略聯盟的配置包括:

     IKE 創建安全策略聯盟

      ipsec policy policy-name sequence-number isakmp

  配置安全策略引用的訪問控制列表

      security acl access-list-number

 指定安全隧道的終點

       tunnel remote ip-address

  配置安全策略中引用的安全提議

      proposal proposal-name1 [ proposal-name2...proposal-name6 ]

 配置安全聯盟的生存時間(可選)

  配置全局時間
     ipsec sa global-duration time-based seconds

        ipsec sa global-duration traffic-based kilobytes

  配置獨立時間

     sa duration { time-based seconds |traffic-based kilobytes }

7.IPsec配置案例
實驗環境說明:
本實驗採用華爲2600系列路由器三臺,3526系列交換機(三層)一臺。實現1.0網段的主機可以喝2.0,3.0網段的主機通過***互訪。但是2.0和3.0之間不建立***。

配置詳解
R14的配置:
給接口配置IP
Int e0
Ip add 192.168.1.1
Int e1
Ip add 192.168.10.200
配置默認路由
Ip route 0.0.0.0 0 192.168.10.1
創建加密訪問控制列表
Acl 3000
Rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
rule deny ip source any destination any
Acl 3001
rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
rule deny ip source any destination any
創建安全提議
ipsec proposal tran1
encapsulation-mode tunnel
transform esp-new
esp-new encryption-algorithm des
esp-new authentication-algorithm sha1-hmac-96
ipsec proposal tran2
transform esp-new
esp-new encryption-algorithm des
esp-new authentication-algorithm sha1-hmac-96
創建安全策略
ipsec policy policy1 10 isakmp
security acl 3000                    
proposal tran1                       
tunnel remote 192.168.20.200
ipsec policy policy1 20 isakmp
security acl 3001                    
proposal tran2                      
tunnel remote 192.168.30.200
在外出接口上應用策略
Int e1
ipsec policy policy1
配置相應的IKE
ike pre-shared-key abcd remote 192.168.30.200
ike pre-shared-key 123456 remote 192.168.20.200
查看當前配置
Dis cu
!
 ike pre-shared-key abcd remote 192.168.30.200
 ike pre-shared-key 123456 remote 192.168.20.200
 !
  !
 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

    rule normal deny ip source any destination any

 !
 acl 3001 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 deny ip source any destination any

 !

 ike proposal 1

 !                                      

 ipsec proposal tran2

 !                                      

 ipsec proposal tran1

 !                                      

 ipsec policy policy1 10 isakmp

    security acl 3000                     

    proposal tran1                       

    tunnel remote 192.168.20.200         

 !                                      

 ipsec policy policy1 20 isakmp

    security acl 3001                    

    proposal tran2                       

    tunnel remote 192.168.30.200   !
 interface Ethernet0
    ip address 192.168.1.1 255.255.255.0
 !
 interface Ethernet1
    ip address 192.168.10.200 255.255.255.0
    ipsec policy policy1
ip route-static 0.0.0.0 0.0.0.0 192.168.10.1 preference 60
 
 
R5配置:
給接口配置IP
Int e0
Ip add 192.168.2.1
Int e1
Ip add 192.168.20.200
配置默認路由
ip route-static 0.0.0.0 0.0.0.0 192.168.20.1
創建加密訪問控制列表
Acl 3000
Rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
rule deny ip source any destination any
創建安全提議
ipsec proposal tran1
encapsulation-mode tunnel
transform esp-new
esp-new encryption-algorithm des
esp-new authentication-algorithm sha1-hmac-96
創建安全策略
ipsec policy policy1 10 isakmp
security acl 3000                    
proposal tran1                        
tunnel remote 192.168.10.200
在外出接口上應用策略
Int e1
ipsec policy policy1
配置相應的IKE
ike pre-shared-key 123456 remote 192.168.10.200
查看當前配置
Dis cu
 
!

 ike pre-shared-key 123456 remote 192.168.10.200

 !

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

 !
 ipsec proposal tran1
 !
 ipsec policy policy1 10 isakmp

    security acl 3000

    proposal tran1

    tunnel remote 192.168.10.200

 !
 
 interface Ethernet0

    ip address 192.168.2.1 255.255.255.0

 !
 interface Ethernet1

    ip address 192.168.20.200 255.255.255.0

    ipsec policy policy1

 !
ip route-static 0.0.0.0 0.0.0.0 192.168.20.1 preference 60
 !
R9配置:
給接口配置IP
Int e0
Ip add 192.168.3.1
Int e1
Ip add 192.168.30.200
配置默認路由
ip route-static 0.0.0.0 0.0.0.0 192.168.30.1
創建加密訪問控制列表
Acl 3000
Rule permit ip source 192.168.3.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
rule deny ip source any destination any
創建安全提議
ipsec proposal tran2
encapsulation-mode tunnel
transform esp-new
esp-new encryption-algorithm des
esp-new authentication-algorithm sha1-hmac-96
創建安全策略
ipsec policy policy1 20 isakmp
security acl 3000                    
proposal tran1                       
tunnel remote 192.168.10.200
在外出接口上應用策略
Int e1
ipsec policy policy1
配置相應的IKE
ike pre-shared-key abcd remote 192.168.10.200
查看當前配置
Dis cu
[R9]dis cu
 Now create configuration...
 Current configuration
 !
    version 1.74

    local-user user1 service-type administrator password simple 123

    sysname R9

    firewall enable

    aaa-enable

    aaa accounting-scheme optional

 !

 ike pre-shared-key abcd remote 192.168.10.200

 !

 acl 3000 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 deny ip source any destination any

 !
 ipsec proposal tran2
 !
 ipsec policy policy1 20 isakmp

    security acl 3000

    proposal tran2

    tunnel remote 192.168.10.200

 !                                       
 interface Aux0

    async mode flow

    link-protocol ppp

 !
 interface Ethernet0

    ip address 192.168.3.1 255.255.255.0

 !
 interface Ethernet1

    ip address 192.168.30.200 255.255.255.0

    ipsec policy policy1

 !
 
 quit
 ip route-static 0.0.0.0 0.0.0.0 192.168.30.1 preference 60
 !
 return
SW10的配置:
創建vlan並把接口加入vlan
Vlan 10
Por e0/10
Vlan 20
Por e0/20
Vlan 30
Port e0/30
給vlan配置ip地址
Int vlan 10
ip address 192.168.10.1 255.255.255.0
Int vlan 20
ip address 192.168.20.1 255.255.255.0
Int vlan 30
ip address 192.168.30.1 255.255.255.0
查看當前生效的配置
#
vlan 10
#
vlan 20
#
vlan 30
#
interface Vlan-interface1
 ip address 192.168.100.10 255.255.255.0
#
interface Vlan-interface10
 ip address 192.168.10.1 255.255.255.0
#
interface Vlan-interface20
 ip address 192.168.20.1 255.255.255.0
#
interface Vlan-interface30
 ip address 192.168.30.1 255.255.255.0
測試:
1.10訪問2.45

1.10訪問3.45

2.45訪問1.10

3.100訪問1.10

IPSEC野蠻模式案例
實驗設備
防火牆:華爲F100
三層交換:s3526交換機
實驗描述
fw1Ethernet1接口固定IP地址,fw2fw3的外網接口爲動態獲取IP地址,所以fw1fw2,fw3建立起IPSEC連接必須具備IKE野蠻模式,爲了保證信息安全採用IPsec/IKE方式創建安全隧道。

 

詳細配置步驟
fw1的配置
基本配置
firewall packet-filter default permit
firewall zone trust
add interface Ethernet0/0
add interface Ethernet0/1
add interface Ethernet0/4
interface Ethernet0/1                    
ip address 192.168.10.200 255.255.255.0
interface Ethernet0/4
ip address 192.168.1.1 255.255.255.0
ip route-static 0.0.0.0 0.0.0.0 192.168.10.1
配置安全訪問控制列表
acl number 3000
  rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
 rule deny ip source any destination ayn
acl number 3001
 rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
 rule permit ip source ayn destination any
配置IKE
本地設備名稱
ike local-name fw1
設置對等體
ike peer peer1
 exchange-mode aggressive    協商模式爲野蠻模式
 pre-shared-key 1234         共享密鑰
 id-type name               ID類型爲名稱
 remote-name fw2           對端設備名稱
 local-address 192.168.10.200 本端IP地址
ike peer peer2
 exchange-mode aggressive
  pre-shared-key abcd
  id-type name
 remote-name fw3
 local-address 192.168.10.200
配置安全提議
ipsec proposal tran1
encapsulation-mode tunnel
transform esp
esp encryption-algorithm des
esp authentication-algorithm md5
ipsec proposal tran2
encapsulation-mode tunnel
transform esp
esp encryption-algorithm des
esp authentication-algorithm md5
配置安全策略
ipsec policy policy 10 isakmp
  security acl 3000
 ike-peer peer1        引用對等體
  proposal tran1
ipsec policy policy 20 isakmp
  security acl 3001
  ike-peer peer2
 proposal tran2
在接口上引用安全策略
interface Ethernet0/1
ipsec policy policy
SW12配置
基本配置
vlan 10
port Ethernet0/1
vlan 20
port Ethernet0/5
vlan 30
port Ethernet0/3
interface Vlan-interface10
 ip address 192.168.10.1 255.255.255.0   
interface Vlan-interface20
 ip address 192.168.20.1 255.255.255.0
interface Vlan-interface30
 ip address 192.168.30.1 255.255.255.0
配置DHCP
dhcp server ip-pool fw2
 network 192.168.20.0 mask 255.255.255.0
 gateway-list 192.168.20.1
dhcp server ip-pool fw3
  network 192.168.30.0 mask 255.255.255.0
 gateway-list 192.168.30.1
dhcp server forbidden-ip 192.168.20.1
dhcp server forbidden-ip 192.168.30.1
dhcp server enable
fw2配置
基本配置
firewall packet-filter default permit
firewall zone trust
add interface Ethernet0/0
add interface Ethernet0/1
add interface Ethernet0/4
interface Ethernet0/1                    
ip address dhcp-alloc
interface Ethernet0/4
ip address 192.168.2.1 255.255.255.0
ip route-static 0.0.0.0 0.0.0.0 192.168.20.1
配置安全訪問控制列表
acl number 3000
  rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
 rule deny ip source any destination any
配置IKE
ike local-name fw1
ike peer peer1
 exchange-mode aggressive
 pre-shared-key 1234
 id-type name
 remote-name fw1
 remote-address 192.168.10.200 設對端IP地址
配置安全提議
ipsec proposal tran1
encapsulation-mode tunnel
transform esp
esp encryption-algorithm des
esp authentication-algorithm md5
配置安全策略
ipsec policy policy 10 isakmp
  security acl 3000
 ike-peer peer1
  proposal tran1
在接口上引用安全策略
interface Ethernet0/1
ipsec policy policy
 
fw3配置
基本配置
firewall packet-filter default permit
firewall zone trust
add interface Ethernet0/0
add interface Ethernet0/1
add interface Ethernet0/4
interface Ethernet0/1                    
ip address dhcp-alloc
interface Ethernet0/4
ip address 192.168.3.1 255.255.255.0
ip route-static 0.0.0.0 0.0.0.0 192.168.30.1
配置安全訪問控制列表
acl number 3001
  rule permit ip source 192.168.3.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
 rule deny ip source any destination any
配置IKE
ike local-name fw1
ike peer peer2
 exchange-mode aggressive
 pre-shared-key abcd
 id-type name
 remote-name fw1
 remote-address 192.168.10.200
配置安全提議
ipsec proposal tran2
encapsulation-mode tunnel
transform esp
esp encryption-algorithm des
esp authentication-algorithm md5
配置安全策略
ipsec policy policy 20 isakmp
  security acl 3001
 ike-peer peer2
  proposal tran2
在接口上引用安全策略
interface Ethernet0/1
ipsec policy policy
查看E0/1動態獲得的地址

 

sw12上可以查看已經分配出去的地址

 

實驗結果
1.0訪問3.0

 

1.0訪問2.0

 

2.0訪問1.0

3.0訪問1.0

 

此時分別查看三臺設備的SA
fw3 display ipscek sa

 

fw1

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章