A-A+

【思科VPN知识】IPsec VPN基本部署

2015年12月28日 路由器高级应用 暂无评论 阅读 5 views 次

实验目的:如图,R1,R3分别为甲公司下2个子公司的出口路由器,R2为运营商路由器(公网)。通过部署IPsec VPN使子公司A和子公司B下的内网可以互通。

R2作为公网上的路由器,不可能获知公司内网的IP地址,这时候需要部署一条“隧道”,保证子公司之间的私网可以互相通信,不仅可以加快传输效率,还可以保证网络的安全性,这就是VPN部署的目的。

实验步骤:

进行基本配置,通过环回口来模拟内网地址。

  1. R1  
  2. R1#conf t  
  3. R1(config)#int f0/0  
  4. R1(config-if)#ip add 12.0.0.1 255.255.255.0  
  5. R1(config-if)#no sh  
  6.   
  7. R1(config-if)#int l0  
  8. R1(config-if)#ip add 192.168.1.1 255.255.255.0  
  9. R1(config-if)#no sh  
  10. R1(config-if)#ex  
  11.   
  12. R1(config)#ip route 0.0.0.0 0.0.0.0 12.0.0.2  
  13.    
  14. R2  
  15. R2#conf t  
  16. R2(config)#int f0/1  
  17. R2(config-if)#ip add 12.0.0.2 255.255.255.0  
  18. R2(config-if)#no sh  
  19.   
  20. R2(config-if)#int f0/0  
  21. R2(config-if)#ip add 23.0.0.2 255.255.255.0   
  22. R2(config-if)#no sh  
  23.    
  24. R3  
  25. R3#conf t  
  26. R3(config)#int f0/1  
  27. R3(config-if)#ip add 23.0.0.3 255.255.255.0  
  28. R3(config-if)#no sh  
  29. R3(config-if)#int l0  
  30. R3(config-if)#ip add 192.168.3.1 255.255.255.0  
  31. R3(config-if)#no sh  
  32.   
  33. R3(config-if)#ex  
  34. R3(config)#ip route 0.0.0.0 0.0.0.0 23.0.0.2  

2.进行IPsec 配置

R1

首先定义一条ACL,用于匹配VPN路由

  1. R1(config)#access-list 101 permit ip 192.168.1.0 0.0.0.255 192.168.3.0 0.0.0.255    
  2.      
  3. R1(config)#crypto isakmp policy 1                         //配置安全策略,数字表示优先级  
  4.   
  5. R1(config-isakmp)# encr 3des                            //告诉对端使用的对称加密算法            
  6.                                     
  7. R1(config-isakmp)# hash md5                           //hash算法  
  8.                                      
  9. R1(config-isakmp)# authentication pre-share              //认证算法  
  10.                        
  11. R1(config-isakmp)# group 2                                   //DH组                   
  12. R1(config-isakmp)# lifetime 60                                //生存周期  
  13.    
  14. R1(config-isakmp)#crypto isakmp key benet address 23.0.0.3        //预共享密码设置为benet,地址为  
  15.                                                                                                      对端R3路由器地址  
  16.    
  17. R1(config)#crypto ipsec transform-set bset esp-3des esp-sha-hmac                   //配置传输集beset,设  
  18.                                                                                                                         置对数据的加密方式  
  19.    
  20. R1(cfg-crypto-trans)#crypto map bmap 10 ipsec-isakmp            //定义crypto map调用感兴趣流量并且设  
  21.                                                                                               置传输集。  
  22. R1(config-crypto-map)# set peer 23.0.0.3                             //指定对端IP  
  23.   
  24. R1(config-crypto-map)# set transform-set bset                   //调用传输集beset   
  25.   
  26. R1(config-crypto-map)# match address 101                    //调用ACL列表101   

如上,R1的基本配置已经完成,接着需要将配置应用在外网口上。

  1. R1(config)#int f0/0  
  2. R1(config-if)#duplex auto   
  3. R1(config-if)#speed auto   
  4. R1(config-if)#crypto map bmap                      //应用刚才设置的map bmap  

R3上也做一样的配置,只是要将对端的IP设置为R1的外网口

  1. R3(config)#access-list 101 permit ip 192.168.3.0 0.0.0.255 192.168.1.0 0.0.0.255    
  2.        
  3. R3(config)#crypto isakmp policy 1  
  4.    
  5.   
  6. R3(config-isakmp)# encr 3des  
  7.   
  8. R3(config-isakmp)# hash md5  
  9. R3(config-isakmp)# authentication pre-share  
  10.   
  11. R3(config-isakmp)# group 2  
  12.    
  13. R3(config-isakmp)# lifetime 60                                 
  14.   
  15. R3(config-isakmp)#crypto isakmp key benet address 12.0.0.1  
  16. R3(config)#crypto ipsec transform-set bset esp-3des esp-sha-hmac  
  17. R3(cfg-crypto-trans)#crypto map bmap 10 ipsec-isakmp  
  18. R3(config-crypto-map)# set peer 12.0.0.1  
  19.   
  20. R3(config-crypto-map)# set transform-set bset  
  21.   
  22. R3(config-crypto-map)# match address 101  
  23. R3(config-crypto-map)#ex  
  24.   
  25. R3(config)#int f0/1  
  26. R3(config-if)#duplex auto   
  27. R3(config-if)#speed auto   
  28. R3(config-if)#crypto map  
  29. bmap  

IPsec VPN已经部署完毕,下面可以做测试了

  1. R1#ping 192.168.3.1 source 192.168.1.1  
  2. Type escape sequence to abort.  
  3. Sending 5100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:  
  4. Packet sent with a source address of 192.168.1.1   
  5. !!!!!  
  6. Success rate is 100 percent (5/5), round-trip min/avg/max = 36/52/68 ms  

已经通了。

有人说,这样就可以结束了吧?

但是忽略了一个问题,公司内网的员工部署了这个VPN,会与原先部署的NAT冲突。

原先的NAT应该是这样部署的

  1. R1(config)#access-list 1 permit ip 192.168.1.0 0.0.0.255  
  2.    
  3. R1(config)#int l0  
  4. R1(config-if)#ip nat inside  
  5. R1(config-if)#int f0/0  
  6. R1(config-if)#ip nat outside   
  7. R1(config-if)#ex  
  8. R1(config)#ip nat inside source list 1 int f0/0 overload  

这样一来,公司内网IP在出口路由器上会被转化成外网口地址12.0.0.1/24 ,这样就与IPsec VPN的设置(ACL101)冲突了。

  1. R1#p 192.168.3.1 source 192.168.1.1  
  2. Type escape sequence to abort.  
  3. Sending 5100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:  
  4. Packet sent with a source address of 192.168.1.1   
  5. UUUUU  www.19216811.la  
  6. Success rate is 0 percent (0/5)  

不可达。

这时候需要对access-list 1做修改:

R1(config)#access-list 102 deny ip 192.168.1.0 0.0.0.255 192.168.3.0 0.0.0.255

R1(config)#access-list 102 permit ip 192.168.1.0 0.0.0.255 any

R1(config)#ip nat inside source list 102 int f0/0 overload

这样,子公司A内网192.168.1.0/24网段访问子公司B192.168.3.0/24的网段就不会被NAT了

  1. R1#p 12.0.0.2 source 192.168.1.1  
  2. Type escape sequence to abort.  
  3. Sending 5100-byte ICMP Echos to 12.0.0.2, timeout is 2 seconds:  
  4. Packet sent with a source address of 192.168.1.1   
  5. !!!!!  
  6. Success rate is 100 percent (5/5), round-trip min/avg/max = 36/47/60 ms  
  7.    
  8. R1#ping 192.168.3.1 source 192.168.1.1  
  9. Type escape sequence to abort.  
  10. Sending 5100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:  
  11. Packet sent with a source address of 192.168.1.1   
  12. !!!!!  
  13. Success rate is 100 percent (5/5), round-trip min/avg/max = 36/52/68 ms  

没问题了,实验结束。

标签:

给我留言