A-A+

两台Cisco路由器上配置VPN的方法和实例

2015年11月18日 站长资讯 暂无评论

对于cisco路由器的管理和维护人员来说,配置VPN是一项非常基本的技能了,下面就通过一个实例来讲解一个简单的两台路由器配置成VPN网络的方法,并且附上完整的配置命令。

网络环境介绍:

用两台路由器分别代表公司总部(R1)和公司分部(R2).公司总部内部地址为192.168.1.0/24网段.分部内部地址为192.168.2.0/24网段.

实验配置:

  1. R1  
  2.    
  3. r1#show run   
  4. Building configuration...  
  5. Current configuration : 1505 bytes   
  6. !  
  7. version 12.3  
  8. service timestamps debug datetime msec  
  9. service timestamps log datetime msec  
  10. no service password-encryption  
  11. !  
  12. hostname r1  
  13. !  
  14. boot-start-marker  
  15. boot-end-marker  
  16. !  
  17. !  
  18. no aaa new-model  
  19. ip subnet-zero  
  20. !  
  21. !  
  22. ip cef  
  23. no ip domain lookup  
  24. !  
  25. ip audit po max-events 100  
  26. no ftp-server write-enable  
  27. !           
  28. !  
  29. !  
  30. !  
  31. !  
  32. !  
  33. !  
  34. !  
  35. !  
  36. !  
  37. !  
  38. !  
  39. !  
  40. !   
  41. !  
  42. crypto isakmp policy 1     定义策略集,下面是策略集的内容,两边要一致.  
  43.  hash md5          
  44.  authentication pre-share  
  45.  lifetime 64000  
  46. crypto isakmp key cisco address 202.10.1.2   设置共享密钥和对端地址!  
  47. !  
  48. crypto ipsec transform-set benet ah-md5-hmac esp-des 配置IPSec的相关参数,两边也要一致.   
  49. !           
  50. crypto map map1 1 ipsec-isakmp  配置端口应用,就是将IKE与IPSec做个关联,我是这样理解的.  
  51.  set peer 202.10.1.2  
  52.  set transform-set benet   
  53.  match address 101  
  54. !  
  55. !  
  56. !  
  57. !  
  58. interface Loopback0    回环地址模拟公司内部地址  
  59.  ip address 192.168.1.1 255.255.255.0  
  60. !  
  61. interface FastEthernet0/0  
  62.  no ip address  
  63.  shutdown  
  64.  duplex auto  
  65.  speed auto  
  66. !  
  67. interface FastEthernet0/1  
  68.  no ip address  
  69.  shutdown  
  70.  duplex auto  
  71.  speed auto  
  72. !           
  73. interface Serial1/0         配置路由器的地址  
  74.  ip address 202.10.1.1 255.255.255.0  
  75.  serial restart-delay 0  
  76.  crypto map map1  
  77. !  
  78. interface Serial1/1  
  79.  no ip address   
  80.  shutdown  
  81.  serial restart-delay 0  
  82. !  
  83. interface Serial1/2  
  84.  no ip address  
  85.  shutdown  
  86.  serial restart-delay 0  
  87. !  
  88. interface Serial1/3  
  89.  no ip address  
  90.  shutdown  
  91.  serial restart-delay 0  
  92. !  
  93. ip http server  
  94. no ip http secure-server  
  95. ip classless  
  96. ip route 192.168.2.0 255.255.255.0 202.10.1.2    静态路由到公司分部  
  97. !  
  98. !  
  99. access-list 101 permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255  
  100. !设置要加密的数据流.这里是指从192.168.1.0到192.168.2.0的数据流  
  101. !  
  102. !  
  103. !  
  104. !  
  105. !  
  106. !  
  107. !  
  108. !  
  109. line con 0  
  110.  exec-timeout 0 0  
  111.  logging synchronous  
  112.  transport preferred all  
  113.  transport output all  
  114. line aux 0  
  115.  transport preferred all  
  116.  transport output all  
  117. line vty 0 4  
  118. !           
  119. end  
  120. R2上的配置差不多,就把IP地址改了.  
  121. r2#show run   
  122. Building configuration...  
  123. Current configuration : 1505 bytes  
  124. !  
  125. version 12.3  
  126. service timestamps debug datetime msec  
  127. service timestamps log datetime msec  
  128. no service password-encryption  
  129. !  
  130. hostname r2  
  131. !  
  132. boot-start-marker  
  133. boot-end-marker  
  134. !  
  135. !  
  136. no aaa new-model  
  137. ip subnet-zero  
  138. !  
  139. !  
  140. ip cef  
  141. no ip domain lookup  
  142. !  
  143. ip audit po max-events 100  
  144. no ftp-server write-enable  
  145. !           
  146. !  
  147. !  
  148. !  
  149. !  
  150. !  
  151. !  
  152. !  
  153. !  
  154. !  
  155. !  
  156. !  
  157. !  
  158. !   
  159. !  
  160. crypto isakmp policy 1  
  161.  hash md5  
  162.  authentication pre-share  
  163.  lifetime 64000  
  164. crypto isakmp key cisco address 202.10.1.1  
  165. !   
  166. !  
  167. crypto ipsec transform-set cisco ah-md5-hmac esp-des   
  168. !           
  169. crypto map map1 1 ipsec-isakmp   
  170.  set peer 202.10.1.1  
  171.  set transform-set cisco   
  172.  match address 101  
  173. !  
  174. !  
  175. !  
  176. !  
  177. interface Loopback0  
  178.  ip address 192.168.2.1 255.255.255.0  
  179. !  
  180. interface FastEthernet0/0  
  181.  no ip address  
  182.  shutdown  
  183.  duplex auto  
  184.  speed auto  
  185. !  
  186. interface FastEthernet0/1  
  187.  no ip address  
  188.  shutdown  
  189.  duplex auto  
  190.  speed auto  
  191. !           
  192. interface Serial1/0  
  193.  ip address 202.10.1.2 255.255.255.0  
  194.  serial restart-delay 0  
  195.  crypto map map1  
  196. !  
  197. interface Serial1/1  
  198.  no ip address  
  199.  shutdown  
  200.  serial restart-delay 0  
  201. !  
  202. interface Serial1/2  
  203.  no ip address   
  204.  shutdown  
  205.  serial restart-delay 0  
  206. !  
  207. interface Serial1/3  
  208.  no ip address  
  209.  shutdown  
  210.  serial restart-delay 0  
  211. !  
  212. ip http server  
  213. no ip http secure-server  
  214. ip classless  
  215. http://www.xiaoxiongboke.com   
  216. ip route 192.168.1.0 255.255.255.0 202.10.1.1  
  217. !  
  218. !  
  219. access-list 101 permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255  
  220. !  
  221. !  
  222. !  
  223. !  
  224. !  
  225. !  
  226. !  
  227. !  
  228. !  
  229. line con 0  
  230.  exec-timeout 0 0  
  231.  logging synchronous  
  232.  transport preferred all  
  233.  transport output all  
  234. line aux 0  
  235.  transport preferred all  
  236.  transport output all  
  237. line vty 0 4  
  238. !           
  239. end  
  240. r2#  

这命令还是要常敲啊,学完这个有段时间了,就差不多都忘了.

标签:

给我留言