1. 實驗拓撲:
使用GNS3(版本號0.8.6)+c2691-advsecurityk9-mz.124-11.T2.
2. 實驗需求:
a) C1可以和C2通信,實現跨互聯網私網通信
b) C1、C2可以和R2的環回口loopback0通信,實現C1、C2及可以私網通信也可以上公網
3. 實驗步驟:
a) IP地址規劃
R1 | f0/0 |
| R3 | f0/0 |
|
f0/1 |
| f0/1 |
| ||
R2 | f0/0 |
| C1 |
| |
f0/1 |
| ||||
Loopback0 |
| C2 |
|
b) 配置腳本如下
R1
R1#conf t
R1(config)#int f0/0
R1(config-if)#ip add 12.0.0.1 255.255.255.0
R1(config-if)#no shut
R1(config)#int f0/1
R1(config-if)#ip add 172.16.10.1 255.255.255.0
R1(config-if)#no shut
R2
R1#conf t
R2(config)#int f0/0
R2(config-if)#ip add 12.0.0.2 255.255.255.0
R2(config-if)#no shut
R2(config)#int f0/1
R2(config-if)#ip add 23.0.0.2 255.255.255.0
R2(config-if)#no shut
R2(config)#int loo 0
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#no shut
R3
R3#conf t
R3(config)#int f0/0
R3(config-if)#ip add 23.0.0.3 255.255.255.0
R3(config-if)#no shut
R3(config)#int f0/1
R3(config-if)#ip add 172.16.30.1 255.255.255.0
R3(config-if)#no shut
C1
C2
R1
R1(config)#ip route 0.0.0.0 0.0.0.0 12.0.0.2 //公司出口配置默認路由
R3
R3(config)#ip route 0.0.0.0 0.0.0.0 23.0.0.2
---------------------------------以上是IP地址和路由配置----------------------------------
R1
R1(config)#crypto isakmp policy 1 //配置安全策略,數字表示優先級
R1(config-isakmp)#encryption 3des //告訴對端使用的對稱加密算法
R1(config-isakmp)#hash md5 //告訴對端使用的hash算法
R1(config-isakmp)#authentication pre-share //告訴對端使用的認證算法
R1(config-isakmp)#group 5 //告訴對端使用的DH組
R1(config-isakmp)#lifetime 1200 //生存週期,有默認可以不設置
R1(config-isakmp)#exit
R1(config)#crypto isakmp key 6 123 address 23.0.0.3 //預共享密碼設置爲123,地址爲對端R3的地址
R1(config)#crypto ipsec transform-set bset esp-aes esp-sha-hmac //配置傳輸集bset,設置對數據的加密方式
R1(cfg-crypto-trans)#exit
R1(config)#access-list 110 permit ip 172.16.10.0 0.0.0.255 172.16.30.00.0.0.255 //定義感興趣的流量
R1(config)#crypto map bmap 1 ipsec-isakmp //定義cryptomap調用感興趣流量並且設置傳輸集
R1(config-crypto-map)#set peer 23.0.0.3 //指定對端IP
R1(config-crypto-map)#set transform-set bset //調用傳輸集bset
R1(config-crypto-map)#match address 110 //調用列表110
R1(config-crypto-map)#int f0/0
R1(config-if)#crypto map bmap //將crypto map 應用到接口
R3
R3(config)#crypto isakmp policy 1
R3(config-isakmp)#encryption 3des
R3(config-isakmp)#hash md5
R3(config-isakmp)#authentication pre-share
R3(config-isakmp)#group 5
R3(config-isakmp)#lifetime 1200
R3(config-isakmp)#exit
(config)#crypto isakmp key 6 123 address 12.0.0.1
R3(config)#crypto ipsec transform-set bset esp-aes esp-sha-hmac
R3(cfg-crypto-trans)#exit
R3(config)#access-list 110 permit ip 172.16.30.00.0.0.255 172.16.10.0 0.0.0.255
R3(config)#crypto map bmap 1 ipsec-isakmp
R3(config-crypto-map)#set peer 12.0.0.1
R3(config-crypto-map)#set transform-set bset
R3(config-crypto-map)#match address 110
R3(config-crypto-map)#int f0/0
R3(config-if)#crypto map bmap
測試
PC1
PC2
---------------------------以上是ipsec***配置----------------------------
R1(config-crypto-map)#int f0/0
R1(config-if)#ip nat outside
R1(config-if)#int f0/1
R1(config-if)#ip nat inside
R1(config-if)#exit
R1(config)#access-list 120 deny ip 172.16.10.0 0.0.0.255 172.16.30.00.0.0.255
R1(config)#access-list 120 permit ip 172.16.10.0 0.0.0.255 any
R1(config)#ip nat inside source list 120 int f0/0 overload
R3(config-crypto-map)#int f0/0
R3(config-if)#ip nat outside
R3(config-if)#int f0/1
R3(config-if)#ip nat inside
R3(config)#access-list 120 deny ip 172.16.30.0 0.0.0.255 172.16.10.00.0.0.255
R3(config)#access-list 120 permit ip 172.16.30.0 0.0.0.255 any
R3(config)#ip nat inside source list 120 int f0/0 overload
--------------------------以上是PAT外網口複用配置---------------------------------
4. 驗證結果:
a) C1和C2通信,和R2環回口通信
b) C2和R2環回口通信