IPSec ×××的配置
实现环境
Benet公司总部在北京,随着业务的扩大,在西安和上海两地分别创立了分公司,而且需要总公司能够和分公司,分公司和分公司之间能够互相通信。租用专线需要高额的费用,因此公司选择使用IPSec ×××来实现北京总公司与分公司,分公司与分公司(站点到站点间的×××)的通信。
实验需求
? ISP路由器模拟ISP提供商的网络设备(Internet)。
? IPSec ×××阶段1的加密算法使用3DES、认证算法使用SHA、DH组选用组2;阶段2的数据加密和认证过程均使用ESP协议实现。
? 三家公司各自访问Internet的流量通过NAT技术实现。
拓扑图
实现步骤
1.配置各路由器(接口IP地址,路由)
①配置R2
1) 配置接口IP地址
R2(config)#interface e0/0 R2(config-if)#ip address 200.0.20.1 255.255.255.252 R2(config-if)#no shutdown R2(config-if)#texit R2(config)#interface e0/1 R2(config-if)#ip address 192.168.1.254 255.255.255.0 R2(config-if)#no shutdown R2(config-if)#texit |
2)配置路由
R2(config)#ip route 0.0.0.0 0.0.0.0 200.0.20.2 |
②配置R3
1)配置接口IP地址
R3(config)#interface e0/0 R3(config-if)#ip address 200.0.30.1 255.255.255.252 R3(config-if)#no shutdown R3(config-if)#exit R3(config)#interface e0/1 R3(config-if)#ip address 192.168.2.254 255.255.255.0 R3(config-if)#no shutdown R3(config-if)#exit |
2)配置路由
R3(config)#ip route 0.0.0.0 0.0.0.0 200.0.30.2 |
③配置R4
1)配置接口IP地址
R4(config)#interface e0/0 R4(config-if)#ip address 200.0.40.1 255.255.255.252 R4(config-if)#no shutdown R4(config-if)#exit R4(config)#interface e0/1 R4(config-if)#ip address 192.168.3.254 255.255.255.0 R4(config-if)#no shutdown R4(config-if)#exit |
2)配置路由
R4(config)#ip route 0.0.0.0 0.0.0.0 200.0.40.2 |
④配置ISP接口IP地址(不用配置路由)
ISP(config)#interface e0/0 ISP(config-if)#ip address 200.0.20.2 255.255.255.252 ISP(config-if)#no shutdown ISP(config-if)#exit ISP(config)#interface e0/1 ISP(config-if)#ip address 200.0.30.2 255.255.255.252 ISP(config-if)#no shutdown ISP(config-if)#exit ISP(config)#interface e0/2 ISP(config-if)#ip address 200.0.40.2 255.255.255.252 ISP(config-if)#no shutdown ISP(config-if)#exit |
2.分别在R2与R3,R3与R4,R2与R4之间配置IPSec ×××通道
①在R2上配置
R2(config)#crypto isakmp policy 1 R2(config-isakmp)#encryption 3des R2(config-isakmp)#hash md5 R2(config-isakmp)#authentication pre-share R2(config-isakmp)#group 2 R2(config-isakmp)#lifetime 20000 R2(config-isakmp)#exit R2(config)#crypto isakmp key 0 haha address 200.0.30.1 R2(config)#crypto isakmp key 0 haha address 200.0.40.1 R2(config)#access-list 100 permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255 R2(config)#access-list 101 permit ip 192.168.1.0 0.0.0.255 192.168.3.0 0.0.0.255 R2(config)#crypto ipsec transform-set haha-set esp-des esp-sha-hmac R2(cfg-crypto-trans)#mode tunnel R2(cfg-crypto-trans)#exit R2(config)#crypto map haha-map 1 ipsec-isakmp R2(config-crypto-map)#set peer 200.0.30.1 R2(config-crypto-map)#set transform-set haha-set R2(config-crypto-map)#match address 100 R2(config-crypto-map)#exit R2(config)#crypto map haha-map 2 ipsec-isakmp R2(config-crypto-map)#set peer 200.0.40.1 R2(config-crypto-map)#set transform-set haha-set R2(config-crypto-map)#match address 101 R2(config-crypto-map)#exit R2(config)#int e0/0 R2(config-if)#crypto map haha-map R2(config-if)#exit |
②在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 2 R3(config-isakmp)#lifetime 20000 R3(config-isakmp)#exit R3(config)#crypto isakmp key 0 haha address 200.0.20.1 R3(config)#crypto isakmp key 0 haha address 200.0.40.1 R3(config)#access-list 100 permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255 R3(config)#access-list 101 permit ip 192.168.2.0 0.0.0.255 192.168.3.0 0.0.0.255 R3(config)#crypto ipsec transform-set haha-set esp-des esp-sha-hmac R3(cfg-crypto-trans)#mode tunnel R3(cfg-crypto-trans)#exit R3(config)#crypto map haha-map 1 ipsec-isakmp R3(config-crypto-map)#set peer 200.0.20.1 R3(config-crypto-map)#set transform-set haha-set R3(config-crypto-map)#match address 100 R3(config-crypto-map)#exit R3(config)#crypto map haha-map 2 ipsec-isakmp R3(config-crypto-map)#set peer 200.0.40.1 R3(config-crypto-map)#set transform-set haha-set R3(config-crypto-map)#match address 101 R3(config-crypto-map)#exit R3(config)#int e0/0 R3(config-if)#crypto map haha-map R3(config-if)#exit |
③在R4上配置
R4(config)#crypto isakmp policy 1 R4(config-isakmp)#encryption 3des R4(config-isakmp)#hash md5 R4(config-isakmp)#authentication pre-share R4(config-isakmp)#group 2 R4(config-isakmp)#lifetime 20000 R4(config-isakmp)#exit R4(config)#crypto isakmp key 0 haha address 200.0.20.1 R4(config)#crypto isakmp key 0 haha address 200.0.30.1 R4(config)#access-list 100 permit ip 192.168.3.0 0.0.0.255 192.168.1.0 0.0.0.255 R4(config)#access-list 101 permit ip 192.168.3.0 0.0.0.255 192.168.2.0 0.0.0.255 R4(config)#crypto ipsec transform-set haha-set esp-des esp-sha-hmac R4(cfg-crypto-trans)#mode tunnel R4(cfg-crypto-trans)#exit R4(config)#crypto map haha-map 1 ipsec-isakmp R4(config-crypto-map)#set peer 200.0.20.1 R4(config-crypto-map)#set transform-set haha-set R4(config-crypto-map)#match address 100 R4(config-crypto-map)#exit R4(config)#crypto map haha-map 2 ipsec-isakmp R4(config-crypto-map)#set peer 200.0.30.1 R4(config-crypto-map)#set transform-set haha-set R4(config-crypto-map)#match address 101 R4(config-crypto-map)#exit R4(config)#int e0/0 R4(config-if)#crypto map haha-map R4(config-if)#exit |
3.测试总公司与分公司,分公司与分公司之间能否相互通信。
①配置各PC的网络参数(IP地址等)
1) PC1的配置
2) PC2的配置
3)PC3的配置
②使用PING命令在总公司与分公司,分公司与分公司之间测试能否互通
1) 北京总公司PING(PC2)分公司(PC1,PC3)
2) 上海分公司(PC1)PING西安分公司(PC3)、北京总公司(PC2)
3)西安分公司(PC3)PING上海分公司(PC1)、北京总公司(PC2)
③在总公司和分公司内的PC上搭建Web服务器,确保能够相互访问。
1) 在各PC上测试搭建的Web服务器
在PC1上测试
在PC2上测试
在PC3上测试
2) 测试总公司能否访问分公司Web服务器,分公司能否访问分公司和总公司、Web服务器。
在北京总公司(PC1)上访问分公司的Web服务器
在上海分公司(PC1)上访问北京总公司和西安分公司的Web服务器
在西安分公司(PC3)上访问北京总公司和上海分公司的Web服务器
4.从上面测试结果,可以看出,总公司与分公司,分公司与分公司之间都可以相互通信,从而不但节约了租用专线的费用,而且保证了数据传输的安全。