CiscoASA实现IPSec虚拟专用网(内附故障排
传送门:Cisco 路由器配置实例: https://blog.51cto.com/14227204/2448319
其实,防火墙和路由器的配置非常相似,可以参考上方传送门,下方会介绍一个防火墙的配置实例
一、路由器的故障诊断排查
1、show crypto isakmp sa
创新互联建站是一家专注于网站制作、成都做网站与策划设计,盐都网站建设哪家好?创新互联建站做网站,专注于网站建设十载,网设计领域的专业建站公司;建站业务涵盖:盐都等地区。盐都做网站价格咨询:18982081108
R1:show crypto isakmp sa # 可以显示数据连接sa的细节信息
MM_NO_STATE :ISAKMP SA建立的初始状态;管理连接建立失败也会处于该状态
MM_SA_SETUP :对等体之间ISAKMP策略协商成功后处于该状态
MM_KEY_EXCH :对等体通过DH算法成功建立共享密钥,此时还没有进行设备验证
MM_KEY_AUTH :对等体成功进行设备验证,之后会过渡到QM_IDLE状态
QM_IDLE :管理连接成功建立,即将过渡到阶段2的数据连接建立过程
2、debug crypto isakmp
R1:debug crypto isakmp # 诊断和排查管理连接出现的问题
故障实例一:两端加密算法不匹配
ISAKMP:(0:0:N/A:0):Checking ISAKMP transform 1 against priority 1 policy
ISAKMP: default group 1
ISAKMP: encryption DES-CBC
ISAKMP: hash SHA
ISAKMP: auth pre-share
ISAKMP: life type in seconds
ISAKMP: life duration (VPI) of 0x0 0x1 0x51 0x80
ISAKMP:(0:0:N/A:0):Encryption algorithm offered does not match policy! # 加密算法不匹配
ISAKMP:(0:0:N/A:0):atts are not acceptable. Next payload is 0
…… # 策略不被接受
ISAKMP:(0:0:N/A:0):no offers accepted! # 没有匹配策略
……
received packet from 10.0.0.1 dport 500 sport 500 Global (R) MM_NO_STATE # 策略进入未成功状态
故障案例二:两端使用的预共享密钥不一致
ISAKMP:(0:0:N/A:0):Checking ISAKMP transform 1 against priority 1 policy
ISAKMP: default group 1
ISAKMP: encryption DES-CBC
ISAKMP: hash SHA
ISAKMP: auth pre-share
ISAKMP: life type in seconds
ISAKMP: life duration (VPI) of 0x0 0x1 0x51 0x80
ISAKMP:(0:0:N/A:0):atts are acceptable. Next payload is 0
…… # 算法已匹配,开始秘钥交换及身份验证
ISAKMP (0:134217729): received packet from 10.0.0.1 dport 500 sport 500 Global (R) MM_KEY_EXCH
ISAKMP: reserved not zero on ID payload!
%CRYPTO-4-IKMP_BAD_MESSAGE: IKE message from 10.0.0.1 failed its sanity check or is malformed
# 完整性验证失败,将停留在MM KEY EXCH 阶段
二、防火墙和路由器的区别:
IKE 协商:
路由默认开启
ASA 防火墙默认关闭,必须手动开启,如下:
ASA(config)# crypto isakmp enable outside
隧道组特性的引入:
防火墙从6.x版本升级到7.0版本引入的新特性
主要用于简化IPSec会话的配置和管理
三、开始配置
环境如下:
需求如下:
lan1区域和lan2区域互通
lan1区域和lan3区域互通
lan2区域和lan3区域互通(lan2→lan1→lan3)
所有区域能够访问中间ISP
配前须知(不好意思,我这里以路由器代替了pc机所以验证有点简略):
- 自行配置接口IP之类
- 这里我是使用了路由器充当PC机所以需要在路由器上配置个默认路由充当网关
- 防火墙往外配置一条默认路由
R1配置(R3、R4配置类似):
R1#conf t
R1(config)#int f 0/0
R1(config-if)#ip add 192.168.1.10 255.255.255.0 # 配置接口IP
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1 # 默认路由充当网关
R2配置如下(ISP不需要配置路由):
R2#conf t
R2(config)#int f 0/1
R2(config-if)#ip add 201.0.0.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#int f 0/1
R2(config-if)#ip add 202.0.0.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#int f 1/0
R2(config-if)#ip add 202.0.0.1 255.255.255.0
R2(config-if)#no shutdown
1、配置
ASA1(lan1→lan2)配置如下
ciscoasa> en
Password:
ciscoasa# conf t
ciscoasa(config)# int e 0/0
ciscoasa(config-if)# nameif inside # 配置为内接口
ciscoasa(config-if)# ip add 192.168.1.1
ciscoasa(config-if)# no shutdown
ciscoasa(config-if)# exit
ciscoasa(config)# int e 0/1
ciscoasa(config-if)# nameif outside # 配置为外接口
ciscoasa(config-if)# ip add 201.0.0.2
ciscoasa(config-if)# no shutdown
ciscoasa(config)# route outside 0 0 201.0.0.2 # 配置到外部的默认路由,这里的0相当于0.0.0.0
ciscoasa(config)# crypto isakmp enable outside # 开启IKE协商功能
ciscoasa(config)# crypto isakmp policy 1 # 配置管理连接
ciscoasa(config-isakmp-policy)# encryption aes # 加密为aes
ciscoasa(config-isakmp-policy)# hash md5 # 认证为 md5
ciscoasa(config-isakmp-policy)# group 2
ciscoasa(config-isakmp-policy)# authentication pre-share # 预先设置共享秘钥
ciscoasa(config-isakmp-policy)# lifetime 10000
ciscoasa(config-isakmp-policy)# exit
ciscoasa(config)# crypto isakmp key 123.com address 202.0.0.2 # 设置共享秘钥
# 防火墙中有两种配置,一会在ASA2中使用
ciscoasa(config)# access-list lan1_lan2 permit ip 192.168.1.0 255.255.255.0 192.168.2.0 255.255.255.0 # 编写1.0到2.0的ACL
ciscoasa(config)# crypto ipsec transform-set test-set esp-aes esp-md5-hmac # 此四条配置数据连接
ciscoasa(config)# crypto map test-map 1 match address lan1_lan2
ciscoasa(config)# crypto map test-map 1 set peer 202.0.0.1
ciscoasa(config)# crypto map test-map 1 set transform-set test-set
ciscoasa(config)# crypto map test-map interface outside # 应用到外部的逻辑接口上
ASA2配置如下
ciscoasa> en
Password:
ciscoasa# conf t
ciscoasa(config)# int e 0/0 # 这里我就不介绍配置含义了,和上面基本相似
ciscoasa(config-if)# nameif outside
ciscoasa(config-if)# ip add 202.0.0.2
ciscoasa(config-if)# no shutdown
ciscoasa(config-if)# exit
ciscoasa(config)# int e 0/1
ciscoasa(config-if)# nameif inside
ciscoasa(config-if)# ip add 192.168.2.1
ciscoasa(config-if)# no shutdown
ciscoasa(config-if)# exit
ciscoasa(config)# route outside 0 0 202.0.0.1
ciscoasa(config)# crypto isakmp enable outside
ciscoasa(config)# crypto isakmp policy 1
ciscoasa(config-isakmp-policy)# encryption aes
ciscoasa(config-isakmp-policy)# hash md5
ciscoasa(config-isakmp-policy)# group 2
ciscoasa(config-isakmp-policy)# authentication pre-share
ciscoasa(config-isakmp-policy)# lifetime 10000
ciscoasa(config)# tunnel-group 201.0.0.2 type ipsec-l2l # 另一种配置秘钥方式
ciscoasa(config)# tunnel-group 201.0.0.2 ipsec-attributes
ciscoasa(config-tunnel-ipsec)# pre-shared-key 123.com
ciscoasa(config-tunnel-ipsec)# exit
ciscoasa(config)# access-list lan2_lan1 permit ip 192.168.2.0 255.255.255.0 192.168.1.0 255.255.255.0
ciscoasa(config)# crypto ipsec transform-set test-set esp-aes esp-md5-hmac
ciscoasa(config)# crypto map test-map 1 match address lan2_lan1
ciscoasa(config)# crypto map test-map 1 set peer 201.0.0.2
ciscoasa(config)# crypto map test-map 1 set transform-set test-set
ciscoasa(config)# crypto map test-map interface outside
R1#ping 192.168.2.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.10, timeout is 2 seconds:
!!!!!
ASA1(lan1→lan3)配置如下
# 在ASA之前配置过到lan2区域,所以可以以上面为基础接着配置
ciscoasa(config)# tunnel-group 203.0.0.2 type ipsec-l2l
ciscoasa(config)# tunnel-group 203.0.0.2 ipsec-attributes
ciscoasa(config-tunnel-ipsec)# pre-shared-key 123.com
ciscoasa(config)# access-list lan1_lan3 permit ip 192.168.1.0 255.255.255.0 192.168.3.0 255.255.255.0
ciscoasa(config)# crypto map test-map 2 match address lan1_lan3
WARNING: The crypto map entry is incomplete! # 这里出现的警告是正常的
ciscoasa(config)# crypto map test-map 2 set peer 203.0.0.2
WARNING: The crypto map entry is incomplete!
ciscoasa(config)# crypto map test-map 2 set transform-set test-set
ASA3配置如下(和ASA2配置基本详细)
ciscoasa> en
Password:
ciscoasa# conf t
ciscoasa(config)# int e 0/0
ciscoasa(config-if)# nameif outside
ciscoasa(config-if)# ip add 203.0.0.2
ciscoasa(config-if)# no shutdown
ciscoasa(config-if)# exit
ciscoasa(config)# int e 0/1
ciscoasa(config-if)# nameif inside
ciscoasa(config-if)# ip add 192.168.3.1
ciscoasa(config-if)# no shutdown
ciscoasa(config)# route outside 0 0 203.0.0.1
ciscoasa(config)# crypto isakmp enable outside
ciscoasa(config)# crypto isakmp policy 1
ciscoasa(config-isakmp-policy)# authentication pre-share
ciscoasa(config-isakmp-policy)# encryption aes
ciscoasa(config-isakmp-policy)# hash md5
ciscoasa(config-isakmp-policy)# group 2
ciscoasa(config-isakmp-policy)# lifetime 10000
ciscoasa(config-isakmp-policy)# exit
ciscoasa(config)# crypto isakmp key 123.com address 201.0.0.2
ciscoasa(config)# access-list lan3_lan1 permit ip 192.168.3.0 255.255.255.0 192.168.1.0 255.255.255.0
ciscoasa(config)# crypto ipsec transform-set test-set esp-aes esp-md5-hmac
ciscoasa(config)# crypto map test-map 1 match address lan3_lan1
ciscoasa(config)# crypto map test-map 1 set peer 201.0.0.2
ciscoasa(config)# crypto map test-map 1 set transform-set test-set
ciscoasa(config)# crypto map test-map interface outside
R4#ping 192.168.1.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.10, timeout is 2 seconds:
!!!!!
2、实现lan2→lan3通信:
ASA1配置如下
ciscoasa(config)# same-security-traffic permit intra-interface # 允许流量进入和离开同一个接口
ciscoasa(config)# access-list lan1_lan2 permit ip 192.168.3.0 255.255.255.0 192.168.2.0 255.255.255.0
ciscoasa(config)# access-list lan1_lan3 permit ip 192.168.2.0 255.255.255.0 192.168.3.0 255.255.255.0
ASA2配置如下
ciscoasa(config)# access-list lan2_lan1 permit ip 192.168.2.0 255.255.255.0 192.168.3.0 255.255.255.0
ASA3配置如下
ciscoasa(config)# access-list lna3_lan1 permit ip 192.168.3.0 255.255.255.0 192.168.2.0 255.255.255.0
R3#ping 192.168.3.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.10, timeout is 2 seconds:
!!!!!
3、访问ISP
如果需要让内网能访问互联网,需要在ASA上做PAT,并启用nat控制,豁免***的流量
ASA1配置如下
ciscoasa(config)# nat-control # 启用nat控制
ciscoasa(config)# nat (inside) 1 0 0 # 配置pat
ciscoasa(config)# global (outside) 1 interface # 映射到接口
# 不使用原来的ACL条目,因为有lan1_lan2和lan1_lan3,无法同时豁免两个,所以重新定义ACL
ciscoasa(config)# access-list aaa permit ip 192.168.1.0 255.255.255.0 192.168.2.0 255.255.255.0
ciscoasa(config)# access-list aaa permit ip 192.168.1.0 255.255.255.0 192.168.3.0 255.255.255.0
ciscoasa(config)# nat (inside) 0 access-list aaa # 应用到接口
ASA2配置如下
ciscoasa(config)# nat (inside) 1 0 0
ciscoasa(config)# global (outside) 1 interface
ciscoasa(config)# nat (inside) 0 access-list lan2_lan1
ASA3配置如下
ciscoasa(config)# nat (inside) 1 0 0
ciscoasa(config)# global (outside) 1 interface
ciscoasa(config)# nat (inside) 0 access-list lan3_lan1
当前名称:CiscoASA实现IPSec虚拟专用网(内附故障排
链接URL:http://ybzwz.com/article/giegpi.html