閱讀英文

共用方式為

示例配置:Cisco ASA 设备(IKEv2/无 BGP)

本文提供了将 Cisco 自适应安全设备(ASA)设备连接到 Azure VPN 网关的示例配置。 该示例适用于在没有边界网关协议(BGP)的情况下运行 IKEv2 的 Cisco ASA 设备。

设备概览

  • 设备供应商: Cisco
  • 设备型号: ASA
  • 目标版本: 8.4 及更高版本
  • 测试的模型: ASA 5505
  • 测试的版本: 9.2
  • IKE 版本: IKEv2
  • BGP:
  • Azure VPN 网关类型: 基于路由的 VPN 网关

注意

示例配置将 Cisco ASA 设备连接到 基于 Azure 路由的 VPN 网关。 如本文所述,连接使用具有 UsePolicyBasedTrafficSelectors 选项的自定义 IPsec/IKE 策略。

此示例要求 ASA 设备使用具有基于访问列表的配置的 IKEv2 策略,而不是基于 VTI 的配置。 请查阅 VPN 设备供应商规范,验证本地 VPN 设备上是否支持 IKEv2 策略。

VPN 设备要求

Azure VPN 网关使用标准 IPsec/IKE 协议套件来建立站点到站点 (S2S) VPN 隧道。 有关 Azure VPN 网关的详细 IPsec/IKE 协议参数和默认加密算法,请参阅 “关于 VPN 设备”。

注意

可以选择为特定连接指定加密算法和密钥强度的确切组合,如 “关于加密要求”中所述。 如果指定算法和密钥强度的确切组合,请确保在 VPN 设备上使用相应的规范。

单个 VPN 隧道

此配置由 Azure VPN 网关和本地 VPN 设备之间的单个 S2S VPN 隧道组成。 可以选择跨 VPN 隧道配置 BGP。

单一 S2S VPN 隧道

有关生成 Azure 配置的分步说明,请参阅 单 VPN 隧道设置

虚拟网络和 VPN 网关信息

本部分列出了示例的参数。

参数
虚拟网络地址前缀 10.11.0.0/16
10.12.0.0/16
Azure VPN 网关 IP Azure_Gateway_Public_IP
本地地址前缀 10.51.0.0/16
10.52.0.0/16
本地 VPN 设备 IP OnPrem_Device_Public_IP
* 虚拟网络 BGP ASN 65010
* Azure BGP 对等 IP 10.12.255.30
* 本地 BGP ASN 65050
* 本地 BGP 对等 IP 10.52.255.254

* 仅适用于 BGP 的可选参数。

IPsec/IKE 策略和参数

下表列出了示例中使用的 IPsec/IKE 算法和参数。 请参阅 VPN 设备规范,验证 VPN 设备型号和固件版本支持的算法。

IPsec/IKEv2 价值
IKEv2 加密 AES256
IKEv2 完整性 SHA384
DH 组 DHGroup24
* IPsec 加密 AES256
* IPsec 完整性 SHA1
PFS 组 PFS24
QM SA 生命周期 7,200 秒
流量选择器 UsePolicyBasedTrafficSelectors $True
预共享密钥 PreSharedKey

* 在某些设备上,当 IPsec 加密算法为 AES-GCM 时,IPsec 完整性必须为 null 值。

ASA 设备支持

  • 支持 IKEv2 需要 ASA 版本 8.4 及更高版本。

  • DH 和超过 5 个组的 PFS 组支持需要 ASA 版本 9.x。

  • 支持 IPsec 加密(使用 AES-GCM)和 IPsec 完整性(使用 SHA-256、SHA-384 或 SHA-512)的功能需要 ASA 版本 9.x。 此支持要求适用于较新的 ASA 设备。 发布时,ASA 模型 5505、5510、5520、5540、5550 和 5580 不支持这些算法。 请参阅 VPN 设备规范,验证 VPN 设备型号和固件版本支持的算法。

示例设备配置

该脚本提供一个示例,该示例基于前面部分所述的配置和参数。 S2S VPN 隧道配置包含以下部分:

  1. 接口和路由
  2. 访问列表
  3. IKE 策略和参数(阶段 1 或主模式)
  4. IPsec 策略和参数(阶段 2 或快速模式)
  5. 其他参数(如 TCP MSS 钳位)

重要

使用示例脚本之前,请完成以下步骤。 将脚本中的占位符值替换为你置配的设备设置。

  • 指定内部和外部接口的接口配置。
  • 标识内部/专用和外部/公用网络的路由。
  • 确保所有名称和策略编号在设备上都是唯一的。
  • 确保设备上支持加密算法。
  • 将以下 占位符值 替换为配置的实际值:
    • 外部接口名称: 外部
    • Azure_Gateway_Public_IP
    • OnPrem_Device_Public_IP
    • IKE: Pre_Shared_Key
    • 虚拟网络和本地网络网关名称: VNetNameLNGName
    • 虚拟网络和本地网络地址 前缀
    • 正确的 网络掩码

示例脚本

! Sample ASA configuration for connecting to Azure VPN gateway
!
! Tested hardware: ASA 5505
! Tested version:  ASA version 9.2(4)
!
! Replace the following place holders with your actual values:
!   - Interface names - default are "outside" and "inside"
!   - <Azure_Gateway_Public_IP>
!   - <OnPrem_Device_Public_IP>
!   - <Pre_Shared_Key>
!   - <VNetName>*
!   - <LNGName>* ==> LocalNetworkGateway - the Azure resource that represents the
!     on-premises network, specifies network prefixes, device public IP, BGP info, etc.
!   - <PrivateIPAddress> ==> Replace it with a private IP address if applicable
!   - <Netmask> ==> Replace it with appropriate netmasks
!   - <Nexthop> ==> Replace it with the actual nexthop IP address
!
! (*) Must be unique names in the device configuration
!
! ==> Interface & route configurations
!
!     > <OnPrem_Device_Public_IP> address on the outside interface or vlan
!     > <PrivateIPAddress> on the inside interface or vlan; e.g., 10.51.0.1/24
!     > Route to connect to <Azure_Gateway_Public_IP> address
!
!     > Example:
!
!       interface Ethernet0/0
!        switchport access vlan 2
!       exit
!
!       interface vlan 1
!        nameif inside
!        security-level 100
!        ip address <PrivateIPAddress> <Netmask>
!       exit
!
!       interface vlan 2
!        nameif outside
!        security-level 0
!        ip address <OnPrem_Device_Public_IP> <Netmask>
!       exit
!
!       route outside 0.0.0.0 0.0.0.0 <NextHop IP> 1
!
! ==> Access lists
!
!     > Most firewall devices deny all traffic by default. Create access lists to
!       (1) Allow S2S VPN tunnels between the ASA and the Azure gateway public IP address
!       (2) Construct traffic selectors as part of IPsec policy or proposal
!
access-list outside_access_in extended permit ip host <Azure_Gateway_Public_IP> host <OnPrem_Device_Public_IP>
!
!     > Object group that consists of all VNet prefixes (e.g., 10.11.0.0/16 &
!       10.12.0.0/16)
!
object-group network Azure-<VNetName>
 description Azure virtual network <VNetName> prefixes
 network-object 10.11.0.0 255.255.0.0
 network-object 10.12.0.0 255.255.0.0
exit
!
!     > Object group that corresponding to the <LNGName> prefixes.
!       E.g., 10.51.0.0/16 and 10.52.0.0/16. Note that LNG = "local network gateway".
!       In Azure network resource, a local network gateway defines the on-premises
!       network properties (address prefixes, VPN device IP, BGP ASN, etc.)
!
object-group network <LNGName>
 description On-Premises network <LNGName> prefixes
 network-object 10.51.0.0 255.255.0.0
 network-object 10.52.0.0 255.255.0.0
exit
!
!     > Specify the access-list between the Azure VNet and your on-premises network.
!       This access list defines the IPsec SA traffic selectors.
!
access-list Azure-<VNetName>-acl extended permit ip object-group <LNGName> object-group Azure-<VNetName>
!
!     > No NAT required between the on-premises network and Azure VNet
!
nat (inside,outside) source static <LNGName> <LNGName> destination static Azure-<VNetName> Azure-<VNetName>
!
! ==> IKEv2 configuration
!
!     > General IKEv2 configuration - enable IKEv2 for VPN
!
group-policy DfltGrpPolicy attributes
 vpn-tunnel-protocol ikev1 ikev2
exit
!
crypto isakmp identity address
crypto ikev2 enable outside
!
!     > Define IKEv2 Phase 1/Main Mode policy
!       - Make sure the policy number is not used
!       - integrity and prf must be the same
!       - DH group 14 and above require ASA version 9.x.
!
crypto ikev2 policy 1
 encryption       aes-256
 integrity        sha384
 prf              sha384
 group            24
 lifetime seconds 86400
exit
!
!     > Set connection type and pre-shared key
!
tunnel-group <Azure_Gateway_Public_IP> type ipsec-l2l
tunnel-group <Azure_Gateway_Public_IP> ipsec-attributes
 ikev2 remote-authentication pre-shared-key <Pre_Shared_Key> 
 ikev2 local-authentication  pre-shared-key <Pre_Shared_Key> 
exit
!
! ==> IPsec configuration
!
!     > IKEv2 Phase 2/Quick Mode proposal
!       - AES-GCM and SHA-2 requires ASA version 9.x on newer ASA models. ASA
!         5505, 5510, 5520, 5540, 5550, 5580 are not supported.
!       - ESP integrity must be null if AES-GCM is configured as ESP encryption
!
crypto ipsec ikev2 ipsec-proposal AES-256
 protocol esp encryption aes-256
 protocol esp integrity  sha-1
exit
!
!     > Set access list & traffic selectors, PFS, IPsec proposal, SA lifetime
!       - This sample uses "Azure-<VNetName>-map" as the crypto map name
!       - ASA supports only one crypto map per interface, if you already have
!         an existing crypto map assigned to your outside interface, you must use
!         the same crypto map name, but with a different sequence number for
!         this policy
!       - "match address" policy uses the access-list "Azure-<VNetName>-acl" defined 
!         previously
!       - "ipsec-proposal" uses the proposal "AES-256" defined previously 
!       - PFS groups 14 and beyond requires ASA version 9.x.
!
crypto map Azure-<VNetName>-map 1 match address Azure-<VNetName>-acl
crypto map Azure-<VNetName>-map 1 set pfs group24
crypto map Azure-<VNetName>-map 1 set peer <Azure_Gateway_Public_IP>
crypto map Azure-<VNetName>-map 1 set ikev2 ipsec-proposal AES-256
crypto map Azure-<VNetName>-map 1 set security-association lifetime seconds 7200
crypto map Azure-<VNetName>-map interface outside
!
! ==> Set TCP MSS to 1350
!
sysopt connection tcpmss 1350
!

简单的调试命令

使用以下 ASA 命令进行调试:

  • 显示 IPsec 或 IKE 安全关联 (SA):

    show crypto ipsec sa
    show crypto ikev2 sa
    
  • 输入调试模式:

    debug crypto ikev2 platform <level>
    debug crypto ikev2 protocol <level>
    

    这些 debug 命令可以在控制台上生成大量输出。

  • 显示设备上的当前配置:

    show run
    

    使用 show 子命令列出设备配置的特定部分,例如:

    show run crypto
    show run access-list
    show run tunnel-group
    

后续步骤

若要配置主动-主动跨界和 VNet 到 VNet 连接,请参阅配置主动-主动 VPN 网关