***!--特殊的傳送門
IPSec原理說明:
IPSec是IP Security的簡稱,它的目的是爲IP提供高安全性特性,***則是在實現這種安全特性的方式下產生的解決方案。
IPSec是一個框架性架構,具體由兩類協議組成:
1、AH協議(Authentication Header,使用較少):可以同時提供數據完整性確認、數據來源確認、防重放等安全特性;AH常用摘要算法(單向Hash函數)MD5和SHA1實現該特性。
2、ESP協議(Encapsulated Security Payload,使用較廣):可以同時提供數據完整性確認、數據加密、防重放等安全特性;ESP通常使用DES、3DES、AES等加密算法實現數據加密,使用MD5或SHA1來實現數據完整性。
IPSec ***的應用場景分爲3種:
1、Site-to-Site(站點到站點或者網關到網關):如彎曲評論的3個機構分佈在互聯網的3個不同的地方,各使用一個商務領航網關相互建立***隧道,企業內網(若干PC)之間的數據通過這些網關建立的IPSec隧道實現安全互聯。
2、End-to-End(端到端或者PC到PC): 兩個PC之間的通信由兩個PC之間的IPSec會話保護,而不是網關。
3、End-to-Site(端到站點或者PC到網關):兩個PC之間的通信由網關和異地PC之間的IPSec進行保護。
***協議分類:
二層隧道協議:pptp l2tp l2f ;屬於用戶***【單機----網絡】
三層隧道協議:gre ipsec;屬於企業網***【網絡----網絡】
***的優勢:
1、費用低,能夠節省30%到70%的開銷;
2、安全性高,能實現加密通信;
3、簡化網絡設計;
4、容易擴展;
5、支持新興應用
***的缺點:
1、轉發延遲比較大;
2、硬件***成本高
配置訪問控制列表的目的:
1、用於挑選符合某一特徵的數據流;
2、來確定什麼樣的ip用戶來通過隧道;
3、需要使用擴展的ACL ;
報文封裝形式有什麼?
1、傳輸方式;無隧道服務器,單機----單機;
2、隧道方式;至少有一個隧道服務器;
本端與對端是什麼?
安全隧道是建立在本端和對端網關之間,所以必須正確設置本端地址和對端地址才能成功地建立起一條安全隧道。手工創建的安全策略只能具備一個對端地址,若已經指定了對端地址,必須要先刪除原先的地址後才能指定新的對端地址。雙方只有在正確指定了本端與對端地址後,才能夠創建安全隧道。
案例說明:
在總部路由器R1和分支結構1路由器R2之間和總部路由器R1和分支結構2路由器R3之間各建立一個安全隧道;
實現 PC1代表的子網(192.168.1.x)與PC2代表的子網(192.168.2.x)之間***通信;
實現 PC1代表的子網(192.168.1.x)與PC3代表的子網(192.168.3.x)之間***通信;
安全協議採用 ESP 協議,加密算法採用 DES,認證算法採用 sha1-hmac-96,協商方式採用自動方式;
華爲:
1.第一步:對Router A和Router B做基本配置並定義需保護的數據流。
Router A:
<Quidway>system-view
[Quidway]sysname RouterA
[RouterA] interface Ethernet0/0
[RouterA-Ethernet0/0]ip address 2.2.2.1 255.255.255.0
[RouterA-Ethernet0/0]interface serial 0/0
[RouterA-serial 0/0]ip address 1.1.1.1 255.255.255.0
[RouterA-serial 0/0]quit
[RouterA] ip route-static 3.3.3.0 255.255.255.0 1.1.1.2
[RouterA]acl number 3101
[RouterA -acl-adv-3101] rule permit ip source 2.2.2.0 0.0.0.255 destination
3.3.3.0 0.0.0.255
[RouterA -acl-adv-3101] rule deny ip source any destination an
[RouterA -acl-adv-3101]quit
Router B:
<Quidway>system-view
[Quidway]sysname RouterB
[RouterB] interface Ethernet0/0
[RouterB-Ethernet0/0]ip address 3.3.3.1 255.255.255.0
[RouterB-Ethernet0/0]interface serial 0/0
[RouterB-serial 0/0]ip address 1.1.1.2 255.255.255.0
[RouterB-serial 0/0]quit
[RouterB] ip route-static 2.2.2.0 255.255.255.0 1.1.1.1
[RouterA]acl number 3101
[RouterA -acl-adv-3101] rule permit ip source 3.3.3.0 0.0.0.255 destination
2.2.2.0 0.0.0.255
[RouterA -acl-adv-3101] rule deny ip source any destination an
[RouterA -acl-adv-3101]quit
在定義數據流的時候大家一定要將兩邊的ACL配置互爲鏡像
2、第二步:創建安全提議
Router A:
[Router A] ipsec proposal hello
[Router A-ipsec-proposal-hello] encapsulation-mode tunnel
[Router A-ipsec-proposal-hello] transform esp
[Router A -ipsec-proposal-hello] esp encryption-algorithm des
[Router A-ipsec-proposal-hello] esp authentication-algorithm sha1
[Router A-ipsec-proposal-hello] quit
Router B:
[Router B] ipsec proposal hello
[Router B-ipsec-proposal-hello] encapsulation-mode tunnel
[Router B-ipsec-proposal-hello] transform esp
[Router B -ipsec-proposal-hello] esp encryption-algorithm des
[Router B-ipsec-proposal-hello] esp authentication-algorithm sha1
[Router B-ipsec-proposal-hello] quit
注意此部分配置兩邊必須一致
3、第三步:配置IKE對等體
Router A:
[Router A] ike peer peer
[Router A-ike-peer-peer] pre-shared-key h3c
[Router A-ike-peer-peer] remote- address 1.1.1.2
[Router A-ike-peer-peer]quit
Router B:
[Router B] ike peer peer
[Router B-ike-peer-peer] pre-shared-key h3c
[Router B-ike-peer-peer] remote- address 1.1.1.1
[Router B-ike-peer-peer]quit
注意PRE共享密鑰兩邊也必須一致
4:第四步:定義安全策略,用IKE協商方式
Router A:
[Router A] ipsec policy shiyan 10 isakmp
[Router A-ipsec-policy-isakmp-shiyan-10] proposal hello
[Router A-ipsec-policy-isakmp-shiyan-10] security acl 3101
[Router A-ipsec-policy-isakmp-shiyan-10] ike-peer peer
[Router A-ipsec-policy-isakmp-shiyan-10] quit
Router B:
[Router B] ipsec policy shiyan 10 isakmp
[Router B-ipsec-policy-isakmp-shiyan-10] proposal hello
[Router B-ipsec-policy-isakmp-shiyan-10] security acl 3101
[Router B-ipsec-policy-isakmp-shiyan-10] ike-peer peer
[Router B-ipsec-policy-isakmp-shiyan-10] quit
將安全提議、需保護的數據流、IKE對等體全部引入安全策略
5:第五步:將IPSec策略應用到接口上,讓其生效
Router A:
[RouterA]interface serial 0/0
[RouterA-serial 0/0]ipsec policy shiyan
[RouterA-serial 0/0]quit
Router B:
[Router B]interface serial 0/0
[Router B-serial 0/0]ipsec policy shiyan
[Router B-serial 0/0]quit
將IPSec策略應用到相應的接口上,讓其生效。以上配置完成後,Router A 和Router B 之間如果有子網2.2.2.0 與子網3.3.3.0之間的報文通過,將觸發IKE 進行協商建立安全聯盟。IKE 協商成功並創建了安全聯盟後,子網2.2.2.0與子網3.3.3.0 之間的數據流將被加密傳輸
思科:
crypto isakmp policy 1 //定義策略爲1
hash md5 //定義md5算法,完整性驗證方法
authentication pre-share //定義爲pre-share密鑰認證方式
crypto isakmp key xxxxxx address 202.202.202.1 //定義pre-share密鑰爲xxxxxx,總部IP爲202.202.202.1
crypto ipsec transform-set xxxset esp-des esp-md5-hmac //創建變換集esp-des esp-md5-hmac,定義加密方式爲des,完整性驗證爲md5
crypto map xxxmap 1 ipsec-isakmp //創建正規map
set peer 202.202.202.1 //定義總部IP
set transform-set xxxset //使用上面定義的變換集xxxset
match address 185 //援引訪問列表定義的敏感流量,即進行***轉換的流量
int f0/0
ip ad 192.168.1.0 255.255.255.0
ip nat inside
int f0/1
ip ad 99.99.99.1 255.255.255.0 //這裏很有可能是動態IP
ip nat outside
crypto map xxxmap
ip route 0.0.0.0 0.0.0.0 f0/1 //默認路由指向出口
access-list 185 permit ip 192.168.1.0 0.0.0.255 10.1.1.0 0.0.0.255
// 指定需進行***轉換的數據流
access-list 190 deny ip 192.168.1.0 0.0.0.255 10.1.1.0 0.0.0.255
access-list 190 permit ip 192.168.1.0 0.0.0.255 any
// 指定需進行正常NAT轉換的數據流,符合條件的直接從出口訪問公網,不符合的不做NAT轉換,直接進行***加密並輸送至公司總部端
route-map nonat permit 10
match ip address 190
vpdn enable //以下是ADSL撥號配置
int f0/1
pppoe enable
pppoe-client dialer-pool-number 1 //定義dialer-pool
int dialer1
mtu 1492 //***連接中許多問題是MTU造成的
ip address negotiated //IP地址與對端協商,ISP隨機提供動態IP
encapsulation ppp
dialer pool 1 //引用dialer pool
dialer-group 1 //引用敏感流量,符合條件的觸發ADSL撥號
ppp authentication pap callin //定義pap明文密碼傳輸
ppp pap sent-username xxxx2223030 password 7 ******
dialer-list 1 protocol ip permit //定義敏感流量,這裏爲所有流量