A-A+

在Cisco路由器上完整实现OSPF跨网段下IPSec Tunnel模式VPN

2015年12月25日 站长资讯 暂无评论

拓扑图如下:

PC1--R1--ISP1--ISP2--R3--PC2

说明:ISP之间使用OSPF动态路由协议,R1和R3模拟边界路由,并启用PAT,PC1和PC2模拟内网主机。

要求:PC1和PC2能够使用私有IP加密互访,其他Internet流量使用常规PAT访问。

各设备配置如下:

PC1的配置:

  1. conf t  
  2. int f0/0  
  3.  ip add 192.168.0.1 255.255.255.0  
  4.  no shut  
  5.  exit  
  6. no ip routing  
  7. ip default-gateway 192.168.0.2  
  8. end  
  9. wr  

PC2的配置:

  1. conf t  
  2. int f0/0  
  3.  ip add 172.16.0.1 255.255.255.0  
  4.  no shut  
  5.  exit  
  6. no ip routing  
  7. ip default-gateway 172.16.0.2  
  8. end  
  9. wr  

R1的配置命令:

  1. conf t  
  2. int e0/0  
  3.  ip add 192.168.0.2 255.255.255.0  
  4.  duplex full  
  5.  ip nat inside  
  6.  no shut  
  7. int e0/1  
  8.  ip add 1.0.0.1 255.255.255.252  
  9.  duplex full  
  10.  ip nat outside  
  11.  no shut  
  12.  exit  
  13. access-list 1 permit any  
  14. ip nat inside source list 1 interface e0/1 overload  
  15. ip route 0.0.0.0 0.0.0.0 1.0.0.2  
  16. crypto isakmp enable  
  17. crypto isakmp policy 1  
  18.  encryption aes  
  19.  hash sha  
  20.  group 2  
  21.  authentication pre-share  
  22.  exit  
  23. crypto isakmp key 0 IPSEC-TUNNEL address 2.0.0.1  
  24. access-list 100 permit gre host 1.0.0.1 host 2.0.0.1  
  25. access-list 100 permit ip 192.168.0.0 0.0.0.255 172.16.0.0 0.0.0.255  
  26. crypto ipsec transform-set myset ah-sha-hmac esp-md5-hmac esp-3des  
  27.  mode tunnel  
  28.  exit  
  29. crypto map mymap 1 ipsec-isakmp  
  30.  match address 100  
  31.  set transform-set myset   
  32.  set peer 2.0.0.1  
  33.  exit  
  34. int e0/1  
  35.  crypto map mymap  
  36. int tunnel 0  
  37.  ip add 100.0.0.1 255.255.255.252  
  38.  tunnel source 1.0.0.1  
  39.  tunnel destination 2.0.0.1  
  40.  crypto map mymap  
  41.  keepalive 2 3  
  42.  no shutdown  
  43.  exit  
  44. ip route 172.16.0.0 255.255.255.0 tunnel 0  
  45. do wr  

R3的配置命令行:

  1. conf t  
  2. int e0/1  
  3.  ip add 172.16.0.2 255.255.255.0  
  4.  duplex full  
  5.  ip nat inside  
  6.  no shut  
  7. int e0/0  
  8.  ip add 2.0.0.1 255.255.255.252  
  9.  duplex full  
  10.  ip nat outside  
  11.  no shut  
  12.  exit  
  13. access-list 1 permit any  
  14. ip nat inside source list 1 interface e0/0 overload  
  15. ip route 0.0.0.0 0.0.0.0 2.0.0.2  
  16. crypto isakmp enable  
  17. crypto isakmp policy 1  
  18.  encryption aes  
  19.  hash sha  
  20.  group 2  
  21.  authentication pre-share  
  22.  exit  
  23. crypto isakmp key 0 IPSEC-TUNNEL address 1.0.0.1  
  24. access-list 100 permit gre host 2.0.0.1 host 1.0.0.1  
  25. access-list 100 permit ip 172.16.0.0 0.0.0.255 192.168.0.0 0.0.0.255  
  26. crypto ipsec transform-set myset ah-sha-hmac esp-md5-hmac esp-3des  
  27.  mode tunnel  
  28.  exit  
  29. crypto map mymap 1 ipsec-isakmp  
  30.  match address 100  
  31.  set transform-set myset   
  32.  set peer 1.0.0.1  
  33.  exit  
  34. int e0/0  
  35.  crypto map mymap  
  36. int tunnel 0  
  37.  ip add 100.0.0.2 255.255.255.252  
  38.  tunnel source 2.0.0.1  
  39.  tunnel destination 1.0.0.1  
  40.  crypto map mymap  
  41.  keepalive 2 3  
  42.  no shutdown  
  43.  exit  
  44. ip route 192.168.0.0 255.255.255.0 tunnel 0  
  45. do wr  

ISP1的配置命令行:

  1. conf t  
  2. int e0/1  
  3.  ip add 1.0.0.2 255.255.255.252  
  4.  duplex full  
  5.  no shut  
  6. int e0/0  
  7.  ip add 12.0.0.1 255.255.255.252  
  8.  duplex full  
  9.  no shut  
  10.  exit  
  11. router ospf 100  
  12.  network 1.0.0.0 0.0.0.3 area 0  
  13.  network 12.0.0.0 0.0.0.3 area 0  
  14.  exit  
  15. do wr  

ISP2的配置命令行:

  1. conf t  
  2. int e0/0  
  3.  ip add 12.0.0.2 255.255.255.252  
  4.  duplex full  
  5.  no shut  
  6. int e0/1  
  7.  ip add 2.0.0.2 255.255.255.252  
  8.  duplex full  
  9.  no shut  
  10.  exit  
  11. router ospf 100  
  12.  network 2.0.0.0 0.0.0.3 area 0  
  13.  network 12.0.0.0 0.0.0.3 area 0  
  14.  exit  
  15. do wr  
标签:

给我留言