在开始前先讲一讲ASA的初始配置, IOS比较简单就不说了。

ASA有5505, 5510 5520 5530 等型号,5505比较特殊,它有一个内置小switch。初始ip配置:

config terminal

interface vlan 1

ip address 192.168.1.1 255.255.255.0

nameif inside

然后还要定义一个 interface vlan 2, 配置IP地址,nameif outside,securitylevel -等。然后分配一个接口给vlan 2

interface ethernet 0/1

no shutdown

switch port access vlan 2

对于5510 及以上,这些配置是直接在interface ethernet 0/0 等上面配的

enable password ×××××××

http server enable      

http 192.168.1.0 255.255.255.0 inside   允许内部用户打开http管理界面

允许ssh连接到ASA

ssh 192.168.1.0 255.255.255.0 inside

ssh version 2    默认是版本 1 和 2 都可以用

 

思科设备上, IOS设置IPsec ×××总是以下几个步骤

1 定义 IPsec 要封装的数据流

2 定义isakmp 策略。(isakmp是ike的一个实现,ike是一个框架,这两个概念可以互用。)

3 定义IPsec 策略

4 创建crypto map,把以上两个绑定在一起

5 在接口上应用crypto map

 在ASA或PIX上,与此基本类似

1 定义IPsec封装的流量

2 定义isakmp策略

3 定义tunnel group类型

4 定义tunnel group属性 这个在 IOS里面 一般只是针对某个对端 IP 定义share key

5 定义 IPsec 策略

6 建立crypto map将上述东西绑定在一起

 

在IOS上:

步骤1 : 允许本地子网访问远端子网

access-list 101 permit ip192.168.5.0 0.0.0.255 192.168.6.0 0.0.0.255

步骤2 :isakmp策略

crypto isakmp policy 10   (10是优先级,从1到10000, 1最高)

authentication pre-share

encryption 3des

hash md5

group 5

定义pre-shared key

crypto isakmp key Th3key*** address 100.11.3.6      (远端的路由器ip)

步骤3: 定义IPsec策略

crypto ipsec transform-set A_To_B esp esp-3des esp-sha-mac    (esp和ah是有区别的,这里用esp, 前面一个是加密方式,后面是hash方式)

步骤4: 创建crypto map

crypto map ×××Map 10 ipsec-isakmp  (这里的10是序号,一个map可能有多个组,序号小的优先级高)

 set peer 100.11.3.6

 set transform-set A_To_B

 match address 101

步骤5 应用到接口上

在internet facing interface上下文: crypto map ×××Map

如果有多个连接internet的接口,相互之间可以做热备。 那么在发起IPsec连接的时候,就可能要用虚拟接口 loopback0的地址。

这时需要加一句,全局命令:

crypto map ×××Map local-address loolback0

 

在ASA或PIX上

 Step 1. ACL

access-list extended ***_acl permit ip 192.168.5.0 255.255.255.0 192.168.6.0 255.255.255.0  好像ASA上面的掩码和IOS上不一样。

Step 2. isakmp

crypto isakmp policy 10

 authentication pre-share

 encryption aes-256

 hash sha

 group 2

 lifetime 86400

 

Step 3. tunnel type

tunnel-group 195.30.1.50 type ipsec-l2l  用对方的ip作为名称

Step 4. tunnel attributes

tunnel-group 195.30.1.50 ipse-attributes

 pre-shared-key theSecrectKey

Step 5. IPsec 属性

crypto ipsec transform-set ***Set esp-aes-256 esp-sha-hmac

Step 6. crypto map

crypto map IPsec_map 10 match address ***_acl

crypto map IPsec_map 10 set peer 195.30.1.50

crypto map IPsec_map 10 set transform-set ***Set

crypto map IPsec_map 10 set pft group5  如果要更高的安全性可以加这一句,默认是不启用pfs的。

crypto map IPsec_map interface outside ; IOS 是要在interface里面应用map,ASA里map里指定接口。

然后还要在接口上enable isakmp,

crypto map isakmp enable outside

 

如果你需要设置多个×××连接多个局域网,就要用到crypto map的多个组了,所以才会有序号, 你可以用序号定义多个组,分别设置不同的peer,match不同的access list,应用相同或不同的transform set。

一般这个时候都用静态的路由方式,把你要路由的子网指向对端的公网ip

 

关于ASA上面加密参数的设定,有这样一些,这是从https://learningnetwork.cisco.com/docs/DOC-8696转贴的

Possible values of phase 1 attributes :

ISAKMP Attributes:

 

Attribute

Possible Values

Default Value

Encryption

DES 56-bit

3DES 168-bit

AES 128-bit

AES 192-bit

AES 256-bit

3DES 168-bit or

DES 56-bit, if 3DES feature is not active

Hashing

MD5 or SHA

SHA

Authentication method

Preshared keys

RSA signature

DSA signature

Preshared keys

DH group

Group 1 768-bit field

Group 2 1024-bit field

Group 5 1536-bit field

Group 7 ECC 163-bit field

Group 2 1024-bit field

Lifetime

120–2,147,483,647 seconds

86,400 seconds

 

 

Possible values of phase 2 attributes:

IPSec Attributes:


 

 

 

Attribute

Possible Values

Default Values

Encryption

None

DES 56-bit

3DES 168-bit

AES 128-bit

AES 192-bit

AES 256-bit

3DES 168-bit or

DES 56-bit, if 3DES feature is not active

Hashing

MD5, SHA or None

None

Identity information

Network protocol and/or port number

No default parameter

Lifetime

120–2,147,483,647 seconds

10–2,147,483,647 KB

28800 seconds

4,608,000 KB

Mode

Tunnel or transport

Tunnel

PFS group

None

Group 1 768-bit DH prime modulus

Group 2 1024-bit DH prime modulus

Group 5 1536-bit DH prime modulus

Group 7 ECC 163-bit field

None

 

 

Values that can be used in a transform set:

 

Type

Available Options

Default Option

Encryption

esp-3des

esp-aes

esp-aes-192

esp-aes-256

esp-des

esp-null

esp-3DES, or esp-des if 3DES, feature is not active

Hashing

esp-md5-hmac

esp-sha-hmac

esp-none

esp-none

 

 

 还有,通常你会设置NAT, 为了×××能工作需要设置exempt rule,也就是不然它NAT

ASA上面是:

nat (inside) 0 access-list ***_acl

这个nat_id是0. 就表示exempt, 正常的nat_id从1 开始。

在IOS 上面,可以在NAT的ACL的前面加一句,比如用102号

access-list 102 deny ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255

access-list 102  permit ip 192.168.1.0 0.0.0.255 any

然后在NAT上面应用这个ACL就好了。  另外也可以用route map


在新版的ASA上面,配置命令又有一些变化:

crypto ikev1 policy 10

  authentication pre-share

  encryption aes

  hash sha

  group 2

  lifetime 86400

接口上enable

crypto ikev1 enable outside

配置 tunnel group

tunnel-group 172.17.1.1 type ipsec-l2l       
tunnel-group 172.17.1.1 ipsec-attributes
  ikev1 pre-shared-key cisco123

配置 ACL和NAT exemption

object-group network local-network
 network-object 10.10.10.0 255.255.255.0
object-group network remote-network
 network-object 10.20.10.0 255.255.255.0

    配置 access list

 access-list asa-router-*** extended permit ip object-group local-network  object-group remote-network

NAT exemption

nat (inside,outside) source static local-network local-network destination static remote-network remote-network no-proxy-arp route-lookup

注: 上面这个命令是在全局上下文是打的,和在network object模式下的 nat 命令不同,这个全局nat 命令叫做 twice nat

它是在源地址访问目标地址时对两个地址同时做转换,但是命令中实际情况是不转换,就是不变,即实际不做NAT


配置 transform set

crypto ipsec ikev1 transform-set ESP-AES-SHA esp-aes esp-sha-hmac

配置 crypto map

crypto map outside_map 10 match address asa-router-***
crypto map outside_map 10 set peer 172.17.1.1
crypto map outside_map 10 set ikev1 transform-set ESP-AES-SHA

把map 应用到一个接口上

crypto map outside_map interface outside


参考思科的文档 Configure a site-to-site IPsec IKEv1 Tunnel between ASA and Cisco IOS router

https://www.cisco.com/c/en/us/support/docs/security-***/ipsec-negotiation-ike-protocols/119425-configure-ipsec-00.html