帮助我们改善您的体验。

让我们了解您的想法。

您是否能抽出两分钟的时间完成一份问卷调查?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
IPsec VPN 用户指南
Table of Contents Expand all
list Table of Contents

机器翻译对您有帮助吗?

starstarstarstarstar
Go to English page
免责声明:

我们将使用第三方机器翻译软件翻译本页面。瞻博网络虽已做出相当大的努力提供高质量译文,但无法保证其准确性。如果对译文信息的准确性有任何疑问,请参阅英文版本. 可下载的 PDF 仅提供英文版.

采用 NAT-T 的基于路由和基于策略的 VPN

date_range 18-Jan-25

网络地址转换遍历 (NAT-T) 是一种用于管理受 IPsec 保护的数据通过配置了 NAT 进行地址转换的设备时遇到的 IP 地址转换相关问题的方法。

了解 NAT-T

网络地址转换遍历 (NAT-T) 是一种解决受 IPsec 保护的数据通过 NAT 设备进行地址转换时遇到的 IP 地址转换问题的方法。对 IP 寻址(NAT 的功能)的任何更改都会导致 IKE 丢弃数据包。在第 1 阶段交换期间沿数据路径检测到一个或多个 NAT 设备后,NAT-T 会向 IPsec 数据包添加一层用户数据报协议 (UDP) 封装,以便在地址转换后不会丢弃这些设备。NAT-T 将 IKE 和 ESP 流量封装在 UDP 中,端口 4500 同时用作源端口和目标端口。由于 NAT 设备会老化过时的 UDP 转换,因此对等方之间需要保持连接消息。

默认情况下,NAT-T 处于启用状态,因此您必须在层次结构级别使用该[edit security ike gateway gateway-name语句来no-nat-traversal禁用 NAT-T。

NAT 分为两大类:

  • 静态 NAT,其中专用地址和公共地址之间存在一对一关系。静态 NAT 在入站和出站方向上都有效。

  • 动态 NAT,其中专用地址和公共地址之间存在多对一或多对多关系。动态 NAT 仅在出站方向上工作。

NAT 设备的位置可以是:

  • 只有 IKEv1 或 IKEv2 启动器位于 NAT 设备后面。多个启动器可以位于单独的 NAT 设备后面。发起方还可以通过多个 NAT 设备连接到响应方。

  • 只有 IKEv1 或 IKEv2 响应程序位于 NAT 设备后面。

  • IKEv1 或 IKEv2 发起方和响应方都位于 NAT 设备后面。

动态端点 VPN 涵盖发起方的 IKE 外部地址不固定,因此响应方不知道的情况。当发起方的地址由 ISP 动态分配时,或者当发起方的连接跨越从动态地址池分配地址的动态 NAT 设备时,可能会发生这种情况。

针对只有响应方位于 NAT 设备后面的拓扑以及发起方和响应方都在 NAT 设备后面的拓扑,提供了 NAT-T 的配置示例。发起方和响应方都支持 NAT-T 的站点到站点 IKE 网关配置。远程 IKE ID 用于在 IKE 隧道协商的第 1 阶段验证对等方的本地 IKE ID。发起方和响应方都需要 a local-identity 和 a remote-identity 设置。

在 SRX5400、SRX5600 和 SRX5800 设备上,IPsec NAT-T 隧道扩展和维持问题如下:

  • 对于给定的专用 IP 地址,NAT 设备应将 500 和 4500 个专用端口转换为相同的公共 IP 地址。

  • 来自给定公共转换 IP 的隧道总数不能超过 1000 个隧道。

从 Junos OS 19.2R1 版开始,只有配备 SRX5K-SPC3 服务处理卡 (SPC) 或 vSRX 虚拟防火墙的 SRX5400、SRX5600 和SRX5800设备才支持 NAT-T 的 PowerMode IPSec (PMI)。

示例:使用响应方 behind 和 NAT 设备配置 基于路由的 VPN

此示例说明如何在分支机构和公司办公室之间配置基于路由的 VPN,并在 NAT 设备 后面使用响应方。

要求

开始之前,请阅读 IPsec 概述

概述

在此示例中,您将配置基于路由的 VPN。Host1 将使用 VPN 通过 SRX2 连接到其公司总部。

图 1 显示了基于路由的 VPN 的拓扑示例,其中只有响应方位于 NAT 设备后面。

图 1: 基于路由的 VPN 拓扑,仅包含响应方 b和 NAT 设备基于路由的 VPN 拓扑,仅包含响应方 b和 NAT 设备

在此示例中,您将为 SRX1 中的发起方和 SRX2 中的响应方配置接口、IPsec 和安全策略。然后配置 IKE 第 1 阶段和 IPsec 第 2 阶段参数。

SRX1 发送目标地址为 172.1 6 的数据包。2 1.1 建立 VPN。 NAT 设备将目标地址转换为 10.1.31.1。

有关表 1示例中用于启动器的特定配置参数,请参阅。表 3

表 1: SRX1 的接口、路由选项和安全参数

功能

名称

配置参数

接口

ge-0/0/1

172.16.11.1/24

 

ge-0/0/0

10.1.11.1/24

 

st0. 0(隧道接口)

10.1.100.1/24

静态路由

10.1.2 1.0/24

下一跃点是 st0。0.

 

172.16.21.1/32

下一跃点为 172。16.11.2.

安全区域

untrust

  • IKE 和 ping 的系统服务。

  • ge-0/0/1.0 和 st0。 0 个接口绑定到此区域。

 

trust

  • 允许 ll 系统服务。

  • 允许 ll 协议。

  • ge-0/0/0.0 接口绑定到此区域。

安全策略

到 SRX2

允许来自 10.1.1 1 的流量。信任区域中的 0/24 为 10.1。2 1.在不受信任区域中为 0/24。

from-SRX2

允许来自 10.1 的流量。2 1.0/24 在不受信任区域中至 10.1.1 1.信任区域中为 0/24。

表 2: SRX1 的 IKE 第 1 阶段配置参数

功能

名称

配置参数

提议

ike_prop

  • 身份验证方法:预共享密钥

  • Diffie-Hellman 组:group2

  • 身份验证算法:sha1

  • 加密算法:3DES-CBC

策略

ike_pol

  • 模式:主

  • 提议参考:ike_prop

  • IKE 第 1 阶段策略身份验证方法:预共享密钥 ASCII 文本

网关

gw1

  • IKE 策略参考:ike_pol

  • 外部接口:ge-0/0/1.0

  • 网关地址:172.1 6.2 1.1

  • 本地对等方(发起方):branch_natt1@example.net

  • 远程对等方(响应方):responder_natt1@example.net

表 3: SRX1 的 IPsec 第 2 阶段配置参数

功能

名称

配置参数

提议

ipsec_prop

  • 协议:esp

  • 身份验证算法:HMAC-SHA1-96

  • 加密算法:3DES-CBC

策略

ipsec_pol

  • 提议参考:ipsec_prop

  • 完全向前保密 (PFS) 密钥:group2

VPN

vpn1

  • IKE 网关参考:gw1

  • IPsec 策略参考:ipsec_pol

  • 绑定到接口:st0.0

  • 立即建立隧道

有关示例中用于响应程序的特定配置参数,请参阅表 4表 6

表 4: SRX2 的接口、路由选项和安全参数

功能

名称

配置参数

接口

ge-0/0/1

10.1.31.1/24

 

ge-0/0/0

10.1.21.1/24

 

st0. 0(隧道接口)

10.1.100.2/24

静态路由

172.16.11.1/32

下一跃点为 1 0.1。3 1.2.

 

10.1.1 1.0/24

下一跃点是 st0。0.

安全区域

untrust

  • 允许 IKE 和 ping 系统服务。

  • ge-0/0/1.0 和 st0。 0 个接口绑定到此区域。

 

trust

  • 允许 ll 系统服务。

    允许 ll 协议。

  • ge-0/0/0.0 接口绑定到此区域。

安全策略

至 SRX1

允许来自 10.1 的流量。2 1.信任区域中的 0/24 为 10.1。1 1.在不受信任区域中为 0/24。

from-SRX1

允许来自 10.1 的流量。1 1.不信任区域中的 0/24 为 10.1。2 1.信任区域中为 0/24。

表 5: SRX2 的 IKE 第 1 阶段配置参数

功能

名称

配置参数

提议

ike_prop

  • 身份验证方法:预共享密钥

  • Diffie-Hellman 组:group2

  • 身份验证算法:sha1

  • 加密算法:3DES-CBC

策略

ike_pol

  • 模式:主

  • 提议参考:ike_prop

  • IKE 第 1 阶段策略身份验证方法:预共享密钥 ASCII 文本

网关

gw1

  • IKE 策略参考:ike_pol

  • 外部接口:ge-0/0/1.0

  • 网关地址:1 72.16.11.1

  • 本地对等方(响应方):responder_natt1@example.net

  • 远程对等方(发起方):branch_natt1@example.net

表 6: SRX2 的 IPsec 第 2 阶段配置参数

功能

名称

配置参数

提议

ipsec_prop

  • 协议:esp

  • 身份验证算法:HMAC-SHA1-96

  • 加密算法:3DES-CBC

策略

ipsec_pol

  • 提议参考:ipsec_prop

  • PFS 密钥:group2

VPN

vpn1

  • IKE 网关参考:gw1

  • IPsec 策略参考:ipsec_pol

  • 绑定到接口:st0.0

  • 立即建立隧道

配置

为 SRX1 配置接口、路由选项和安全参数

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security address-book book1 address Host1 10.1.11.0/24
set security address-book book1 attach zone trust
set security address-book book2 address Host2 10.1.21.0/24
set security address-book book2 attach zone untrust
set security policies from-zone trust to-zone untrust policy to-SRX2 match source-address Host1
set security policies from-zone trust to-zone untrust policy to-SRX2 match destination-address Host2
set security policies from-zone trust to-zone untrust policy to-SRX2 match application any
set security policies from-zone trust to-zone untrust policy to-SRX2 then permit
set security policies from-zone untrust to-zone trust policy from-SRX2 match source-address Host2
set security policies from-zone untrust to-zone trust policy from-SRX2 match destination-address Host1
set security policies from-zone untrust to-zone trust policy from-SRX2 match application any
set security policies from-zone untrust to-zone trust policy from-SRX2 then permit
set security zones security-zone untrust host-inbound-traffic system-services ike
set security zones security-zone untrust host-inbound-traffic system-services ping
set security zones security-zone untrust interfaces st0.0
set security zones security-zone untrust interfaces ge-0/0/1.0
set security zones security-zone trust host-inbound-traffic system-services all
set security zones security-zone trust host-inbound-traffic protocols all
set security zones security-zone trust interfaces ge-0/0/0.0
set interfaces ge-0/0/0 unit 0 family inet address 10.1.11.1/24
set interfaces ge-0/0/1 unit 0 family inet address 172.16.11.1/24
set interfaces st0 unit 0 family inet address 10.1.100.1/24
set routing-options static route 10.1.21.0/24 next-hop st0.0
set routing-options static route 172.16.21.1/32 next-hop 172.16.11.2
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置接口、静态路由和安全参数,请执行以下操作:

  1. 配置连接到互联网的接口、Host1 和用于 VPN 的接口。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set interfaces ge-0/0/0 unit 0 family inet address 10.1.11.1/24
    user@SRX1# set interfaces ge-0/0/1 unit 0 family inet address 172.16.11.1/24
    user@SRX1# set interfaces st0 unit 0 family inet address 10.1.100.1/24
  2. 为将使用 VPN 的流量配置静态路由,并为 SRX1 配置到达 NAT 设备的静态路由。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set routing-options static route 10.1.21.0/24 next-hop st0.0
    user@SRX1# set routing-options static route 172.16.21.1/32 next-hop 172.16.11.2
  3. 配置不信任安全区域。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set security zones security-zone untrust host-inbound-traffic system-services ike
    user@SRX1# set security zones security-zone untrust host-inbound-traffic system-services ping
    user@SRX1# set security zones security-zone untrust interfaces st0.0
    user@SRX1# set security zones security-zone untrust interfaces ge-0/0/1.0
  4. 配置信任安全区域。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set security zones security-zone trust host-inbound-traffic system-services all
    user@SRX1# set security zones security-zone trust host-inbound-traffic protocols all
    user@SRX1# set security zones security-zone trust interfaces ge-0/0/0.0
  5. 为安全策略中使用的网络配置地址簿 。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set security address-book book1 address Host1 10.1.11.0/24
    user@SRX1# set security address-book book1 attach zone trust
    user@SRX1# set security address-book book2 address Host2 10.1.21.0/24
    user@SRX1# set security address-book book2 attach zone untrust
  6. 创建安全策略 以允许主机之间的流量。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set security policies from-zone trust to-zone untrust policy to-SRX2 match source-address Host1
    user@SRX1# set security policies from-zone trust to-zone untrust policy to-SRX2 match destination-address Host2
    user@SRX1# set security policies from-zone trust to-zone untrust policy to-SRX2 match application any
    user@SRX1# set security policies from-zone trust to-zone untrust policy to-SRX2 then permit
    user@SRX1# set security policies from-zone untrust to-zone trust policy from-SRX2 match source-address Host2
    user@SRX1# set security policies from-zone untrust to-zone trust policy from-SRX2 match destination-address Host1
    user@SRX1# set security policies from-zone untrust to-zone trust policy from-SRX2 match application any
    user@SRX1# set security policies from-zone untrust to-zone trust policy from-SRX2 then permit
结果

在配置模式下,输入 show interfacesshow routing-optionsshow security 命令确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@SRX1# show interfaces
ge-0/0/0 {
    unit 0 {
        family inet {
            address 10.1.11.1/24;
        }
    }
}
ge-0/0/1 {
    unit 0 {
        family inet {
            address 172.16.11.1/24;
        }
    }
}
st0 {
    unit 0 {
        family inet {
            address 10.1.100.1/24;
        }
    }
}
content_copy zoom_out_map
[edit]
user@SRX1# show routing-options
static {
    route 10.1.21.0/24 next-hop st0.0;
    route 172.16.21.1/32 next-hop 172.16.11.2;
}
content_copy zoom_out_map
[edit]
user@SRX1# show security
address-book {
    book1 {
        address Host1 10.1.11.0/24;
        attach {
            zone trust;
        }
    }
    book2 {
        address Host2 10.1.21.0/24;
        attach {
            zone untrust;
        }
    }
}
policies {
    from-zone trust to-zone untrust {
        policy to-SRX2 {
            match {
                source-address Host1;
                destination-address Host2;
                application any;
            }
            then {
                permit;
            }
        }
    }
    from-zone untrust to-zone trust {
        policy from-SRX2 {
            match {
                source-address Host2;
                destination-address Host1;
                application any;
            }
            then {
                permit;
            }
        }
    }
}
zones {
    security-zone untrust {
        host-inbound-traffic {
            system-services {
                ike;
                ping;
            }
        }
        interfaces {
            st0.0;
            ge-0/0/1.0;
        }
    }
    security-zone trust {
        host-inbound-traffic {
            system-services {
                all;
            }
            protocols {
                all;
            }
        }
        interfaces {
            ge-0/0/0.0;
        }
    }
}

如果完成设备配置,请从配置模式输入 commit

为 SRX1 配置 IKE

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security ike proposal ike_prop authentication-method pre-shared-keys
set security ike proposal ike_prop dh-group group2
set security ike proposal ike_prop authentication-algorithm sha1
set security ike proposal ike_prop encryption-algorithm 3des-cbc
set security ike policy ike_pol mode main
set security ike policy ike_pol proposals ike_prop
set security ike policy ike_pol pre-shared-key ascii-text “$ABC123”
set security ike gateway gw1 ike-policy ike_pol
set security ike gateway gw1 address 172.16.21.1
set security ike gateway gw1 local-identity user-at-hostname "srx1@example.com"
set security ike gateway gw1 remote-identity user-at-hostname "srx2@example.com"
set security ike gateway gw1 external-interface ge-0/0/1.0
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置 IKE:

  1. 创建 IKE 第 1 阶段提议。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set security ike proposal ike_prop authentication-method pre-shared-keys
    user@SRX1# set security ike proposal ike_prop dh-group group2
    user@SRX1# set security ike proposal ike_prop authentication-algorithm sha1
    user@SRX1# set security ike proposal ike_prop encryption-algorithm 3des-cbc
  2. 创建 IKE 第 1 阶段策略。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set security ike policy ike_pol mode main
    user@SRX1# set security ike policy ike_pol proposals ike_prop
    user@SRX1# set security ike policy ike_pol pre-shared-key ascii-text “$ABC123”
  3. 配置 IKE 第 1 阶段网关参数。 网关地址应为 NAT 设备的 IP。

    content_copy zoom_out_map
    [edit security ike gateway gw1]
    user@SRX1# set security ike gateway gw1 ike-policy ike_pol
    user@SRX1# set security ike gateway gw1 address 172.16.21.1
    user@SRX1# set security ike gateway gw1 local-identity user-at-hostname "srx1@example.com"
    user@SRX1# set security ike gateway gw1 remote-identity user-at-hostname "srx2@example.com"
    user@SRX1# set security ike gateway gw1 external-interface ge-0/0/1.0
结果

在配置模式下,输入 show security ike 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@SRX1# show security ike
proposal ike_prop {
    authentication-method pre-shared-keys;
    dh-group group2;
    authentication-algorithm sha1;
    encryption-algorithm 3des-cbc;
}
policy ike_pol {
    mode main;
    proposals ike_prop;
    pre-shared-key ascii-text “$9$xPn7-VwsgaJUHqp01IcSs2g”; ## SECRET-DATA
}
gateway gw1 {
    ike-policy ike_pol;
    address 172.16.21.1;
    local-identity user-at-hostname "srx1@example.com";
    remote-identity user-at-hostname "srx2@example.com";
    external-interface ge-0/0/1.0;
}

如果完成设备配置,请从配置模式输入 commit

为 SRX1 配置 IPsec

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security ipsec proposal ipsec_prop protocol esp
set security ipsec proposal ipsec_prop authentication-algorithm hmac-sha1-96
set security ipsec proposal ipsec_prop encryption-algorithm 3des-cbc
set security ipsec policy ipsec_pol perfect-forward-secrecy keys group2
set security ipsec policy ipsec_pol proposals ipsec_prop
set security ipsec vpn vpn1 bind-interface st0.0
set security ipsec vpn vpn1 ike gateway gw1
set security ipsec vpn vpn1 ike ipsec-policy ipsec_pol
set security ipsec vpn vpn1 establish-tunnels immediately
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置 IPsec:

  1. 创建 IPsec 第 2 阶段提议。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set security ipsec proposal ipsec_prop protocol esp
    user@SRX1# set security ipsec proposal ipsec_prop authentication-algorithm hmac-sha1-96
    user@SRX1# set security ipsec proposal ipsec_prop encryption-algorithm 3des-cbc
  2. 创建 IPsec 第 2 阶段策略。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set security ipsec policy ipsec_pol perfect-forward-secrecy keys group2
    user@SRX1# set security ipsec policy ipsec_pol proposals ipsec_prop
  3. 配置 IPsec VPN 参数。

    content_copy zoom_out_map
    [edit]
    user@SRX1# set security ipsec vpn vpn1 bind-interface st0.0
    user@SRX1# set security ipsec vpn vpn1 ike gateway gw1
    user@SRX1# set security ipsec vpn vpn1 ike ipsec-policy ipsec_pol
    user@SRX1# set security ipsec vpn vpn1 establish-tunnels immediately
结果

在配置模式下,输入 show security ipsec 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@SRX1# show security ipsec
proposal ipsec_prop {
    protocol esp;
    authentication-algorithm hmac-sha1-96;
    encryption-algorithm 3des-cbc;
}
policy ipsec_pol {
    perfect-forward-secrecy {
        keys group2;
    }
    proposals ipsec_prop;
}
vpn vpn1 {
    bind-interface st0.0;
    ike {
        gateway gw1;
        ipsec-policy ipsec_pol;
    }
    establish-tunnels immediately;
}

如果完成设备配置,请从配置模式输入 commit

为 SRX2 配置接口、路由选项和安全 P流量计

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security address-book book1 address Host2 10.1.21.0/24
set security address-book book1 attach zone trust
set security address-book book2 address Host1 10.1.11.0/24
set security address-book book2 attach zone untrust
set security policies from-zone trust to-zone untrust policy to-SRX1 match source-address Host2
set security policies from-zone trust to-zone untrust policy to-SRX1 match destination-address Host1
set security policies from-zone trust to-zone untrust policy to-SRX1 match application any
set security policies from-zone trust to-zone untrust policy to-SRX1 then permit
set security policies from-zone untrust to-zone trust policy from-SRX1 match source-address Host1
set security policies from-zone untrust to-zone trust policy from-SRX1 match destination-address Host2
set security policies from-zone untrust to-zone trust policy from-SRX1 match application any
set security policies from-zone untrust to-zone trust policy from-SRX1 then permit
set security zones security-zone untrust host-inbound-traffic system-services ike
set security zones security-zone untrust host-inbound-traffic system-services ping
set security zones security-zone untrust interfaces ge-0/0/1.0
set security zones security-zone untrust interfaces st0.0
set security zones security-zone trust host-inbound-traffic system-services all
set security zones security-zone trust host-inbound-traffic protocols all
set security zones security-zone trust interfaces ge-0/0/0.0
set interfaces ge-0/0/0 unit 0 family inet address 10.1.21.1/24
set interfaces ge-0/0/1 unit 0 family inet address 10.1.31.1/24
set interfaces st0 unit 0 family inet address 10.1.100.2/24
set routing-options static route 172.16.11.1/32 next-hop 10.1.31.2
set routing-options static route 10.1.11.0/24 next-hop st0.0
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置接口、静态路由和安全参数,请执行以下操作:

  1. 配置连接到互联网的接口、Host2 和用于 VPN 的接口。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set interfaces ge-0/0/0 unit 0 family inet address 10.1.21.1/24
    user@SRX2# set interfaces ge-0/0/1 unit 0 family inet address 10.1.31.1/24
    user@SRX2# set interfaces st0 unit 0 family inet address 10.1.100.2/24
  2. 为将使用 VPN 的流量配置静态路由,并为 SRX2 配置到达 SRX1。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set routing-options static route 172.16.11.1/32 next-hop 10.1.31.2
    user@SRX2# set routing-options static route 10.1.11.0/24 next-hop st0.0
  3. 配置不信任安全区域。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security zones security-zone untrust host-inbound-traffic system-services ike
    user@SRX2# set security zones security-zone untrust host-inbound-traffic system-services ping
    user@SRX2# set security zones security-zone untrust interfaces ge-0/0/1.0
    user@SRX2# set security zones security-zone untrust interfaces st0.0
    
  4. 配置信任安全区域。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security zones security-zone trust host-inbound-traffic system-services all
    user@SRX2# set security zones security-zone trust host-inbound-traffic protocols all
    user@SRX2# set security zones security-zone trust interfaces ge-0/0/0.0
  5. 为安全策略中使用的网络配置地址簿。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security address-book book1 address Host2 10.1.21.0/24
    user@SRX2# set security address-book book1 attach zone trust
    user@SRX2# set security address-book book2 address Host1 10.1.11.0/24
    user@SRX2# set security address-book book2 attach zone untrust
  6. 创建安全策略以允许主机之间的流量。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security policies from-zone trust to-zone untrust policy to-SRX1 match source-address Host2
    user@SRX2# set security policies from-zone trust to-zone untrust policy to-SRX1 match destination-address Host1
    user@SRX2# set security policies from-zone trust to-zone untrust policy to-SRX1 match application any
    user@SRX2# set security policies from-zone trust to-zone untrust policy to-SRX1 then permit
    user@SRX2# set security policies from-zone untrust to-zone trust policy from-SRX1 match source-address Host1
    user@SRX2# set security policies from-zone untrust to-zone trust policy from-SRX1 match destination-address Host2
    user@SRX2# set security policies from-zone untrust to-zone trust policy from-SRX1 match application any
    user@SRX2# set security policies from-zone untrust to-zone trust policy from-SRX1 then permit
结果

在配置模式下,输入 show interfacesshow routing-optionsshow security命令确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@SRX2# show interfaces
ge-0/0/0 {
    unit 0 {
        family inet {
            address 10.1.21.1/24;
        }
    }
}
ge-0/0/1 {
    unit 0 {
        family inet {
            address 10.1.31.1/24;
        }
    }
}
st0 {
    unit 0 {
        family inet {
            address 10.1.100.2/24;
        }
    }
}
content_copy zoom_out_map
[edit]
user@SRX2# show routing-options
static {
    route 172.16.11.1/32 next-hop 10.1.31.2;
    route 10.1.11.0/24 next-hop st0.0;
}
content_copy zoom_out_map
[edit]
user@SRX2# show security
address-book {
    book1 {
        address Host2 10.1.21.0/24;
        attach {
            zone trust;
        }
    }
    book2 {
        address Host1 10.1.11.0/24;
        attach {
            zone untrust;
        }
    }
}
policies {
    from-zone trust to-zone untrust {
        policy to-SRX1 {
            match {
                source-address Host2;
                destination-address Host1;
                application any;
            }
            then {
                permit;
            }
        }
    }
    from-zone untrust to-zone trust {
        policy from-SRX1 {
            match {
                source-address Host1;
                destination-address Host2;
                application any;
            }
            then {
                permit;
            }
        }
    }
}
zones {
    security-zone untrust {
        host-inbound-traffic {
            system-services {
                ike;
                ping;
            }
        }
        interfaces {
            ge-0/0/1.0;
            st0.0;
        }
    }
    security-zone trust {
        host-inbound-traffic {
            system-services {
                all;
            }
            protocols {
                all;
            }
        }
        interfaces {
            ge-0/0/0.0;
        }
    }
}

如果完成设备配置,请从配置模式输入 commit

为 SRX2 配置 IKE

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security ike proposal ike_prop authentication-method pre-shared-keys
set security ike proposal ike_prop dh-group group2
set security ike proposal ike_prop authentication-algorithm sha1
set security ike proposal ike_prop encryption-algorithm 3des-cbc
set security ike policy ike_pol mode main
set security ike policy ike_pol proposals ike_prop
set security ike policy ike_pol pre-shared-key ascii-text “$ABC123”
set security ike gateway gw1 ike-policy ike_pol
set security ike gateway gw1 address 172.16.11.1
set security ike gateway gw1 local-identity user-at-hostname "srx2@example.com"
set security ike gateway gw1 remote-identity user-at-hostname "srx1@example.com"
set security ike gateway gw1 external-interface ge-0/0/1.0
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置 IKE:

  1. 创建 IKE 第 1 阶段提议。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security ike proposal ike_prop authentication-method pre-shared-keys
    user@SRX2# set security ike proposal ike_prop dh-group group2
    user@SRX2# set security ike proposal ike_prop authentication-algorithm sha1
    user@SRX2# set security ike proposal ike_prop encryption-algorithm 3des-cbc
  2. 创建 IKE 第 1 阶段策略。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security ike policy ike_pol mode main
    user@SRX2# set security ike policy ike_pol proposals ike_prop
    user@SRX2# set security ike policy ike_pol pre-shared-key ascii-text “$ABC123”
  3. 配置 IKE 第 1 阶段网关参数。网关地址应为 SRX1 的 IP。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security ike gateway gw1 ike-policy ike_pol
    user@SRX2# set security ike gateway gw1 address 172.16.11.1
    user@SRX2# set security ike gateway gw1 local-identity user-at-hostname "srx2@example.com"
    user@SRX2# set security ike gateway gw1 remote-identity user-at-hostname "srx1@example.com"
    user@SRX2# set security ike gateway gw1 external-interface ge-0/0/1.0
结果

在配置模式下,输入 show security ike 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@SRX2# show security ike
proposal ike_prop {
    authentication-method pre-shared-keys;
    dh-group group2;
    authentication-algorithm sha1;
    encryption-algorithm 3des-cbc;
}
policy ike_pol {
    mode main;
    proposals ike_prop;
    pre-shared-key ascii-text "$9$mP5QF3/At0IE-VsYoa36/"; ## SECRET-DATA
}
gateway gw1 {
    ike-policy ike_pol;
    address 172.16.11.1;
    local-identity user-at-hostname "srx2@example.com";
    remote-identity user-at-hostname "srx1@example.com";
    external-interface ge-0/0/1.0;
}

如果完成设备配置,请从配置模式输入 commit

为 SRX2 配置 IPsec

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security ipsec proposal ipsec_prop protocol esp
set security ipsec proposal ipsec_prop authentication-algorithm hmac-sha1-96
set security ipsec proposal ipsec_prop encryption-algorithm 3des-cbc
set security ipsec policy ipsec_pol perfect-forward-secrecy keys group2
set security ipsec policy ipsec_pol proposals ipsec_prop
set security ipsec vpn vpn1 bind-interface st0.0
set security ipsec vpn vpn1 ike gateway gw1
set security ipsec vpn vpn1 ike ipsec-policy ipsec_pol
set security ipsec vpn vpn1 establish-tunnels immediately
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置 IPsec:

  1. 创建 IPsec 第 2 阶段提议。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security ipsec proposal ipsec_prop protocol esp
    user@SRX2# set security ipsec proposal ipsec_prop authentication-algorithm hmac-sha1-96
    user@SRX2# set security ipsec proposal ipsec_prop encryption-algorithm 3des-cbc
  2. 创建 IPsec 第 2 阶段策略。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security ipsec policy ipsec_pol perfect-forward-secrecy keys group2
    user@SRX2# set security ipsec policy ipsec_pol proposals ipsec_prop
    
  3. 配置 IPsec VPN 参数。

    content_copy zoom_out_map
    [edit]
    user@SRX2# set security ipsec vpn vpn1 bind-interface st0.0
    user@SRX2# set security ipsec vpn vpn1 ike gateway gw1
    user@SRX2# set security ipsec vpn vpn1 ike ipsec-policy ipsec_pol
    user@SRX2# set security ipsec vpn vpn1 establish-tunnels immediately
结果

在配置模式下,输入 show security ipsec 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@SRX2# show security ipsec
proposal ipsec_prop {
    protocol esp;
    authentication-algorithm hmac-sha1-96;
    encryption-algorithm 3des-cbc;
}
policy ipsec_pol {
    perfect-forward-secrecy {
        keys group2;
    }
    proposals ipsec_prop;
}
vpn vpn1 {
    bind-interface st0.0;
    ike {
        gateway gw1;
        ipsec-policy ipsec_pol;
    }
    establish-tunnels immediately;
}

如果完成设备配置,请从配置模式输入 commit

NAT 设备的配置

CLI 快速配置

示例中使用了静态 NAT。静态 NAT 是双向的,这意味着从 10.1.31.1 到 172.16.11.1 的流量也将使用相同的 NAT 配置。

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security nat static rule-set rule1 from zone untrust
set security nat static rule-set rule1 rule ipsec match source-address 172.16.11.1/32
set security nat static rule-set rule1 rule ipsec match destination-address 172.16.21.1/32
set security nat static rule-set rule1 rule ipsec then static-nat prefix 10.1.31.1/32
set security policies from-zone trust to-zone untrust policy allow-out match source-address any
set security policies from-zone trust to-zone untrust policy allow-out match destination-address any
set security policies from-zone trust to-zone untrust policy allow-out match application any
set security policies from-zone trust to-zone untrust policy allow-out then permit
set security policies from-zone untrust to-zone trust policy allow-out-in match source-address any
set security policies from-zone untrust to-zone trust policy allow-out-in match destination-address any
set security policies from-zone untrust to-zone trust policy allow-out-in match application any
set security policies from-zone untrust to-zone trust policy allow-out-in then permit
set security zones security-zone trust host-inbound-traffic system-services ping
set security zones security-zone trust interfaces ge-0/0/1.0
set security zones security-zone untrust host-inbound-traffic system-services ping
set security zones security-zone untrust interfaces ge-0/0/0.0
set interfaces ge-0/0/0 unit 0 family inet address 172.16.21.1/24
set interfaces ge-0/0/1 unit 0 family inet address 10.1.31.2/24
set routing-options static route 172.16.11.0/24 next-hop 172.16.21.2

验证

要确认配置工作正常,请执行以下任务:

验证 SRX1 上的 IKE 第 1 阶段状态

目的

验证 IKE 第 1 阶段状态。

操作

在操作模式下,输入 show security ike security-associations 命令。有关更详细的输出,请使用 show security ike security-associations detail 命令。

content_copy zoom_out_map
user@SRX1> show security ike security-associations
Index   State  Initiator cookie  Responder cookie  Mode           Remote Address
302301  UP     84e8fc61d0750278  ea9a07ef032805b6  Main           172.16.21.1
content_copy zoom_out_map
user@SRX1> show security ike security-associations detail
IKE peer 172.16.21.1, Index 302301, Gateway Name: gw1
  Role: Initiator, State: UP
  Initiator cookie: 84e8fc61d0750278, Responder cookie: ea9a07ef032805b6
  Exchange type: Main, Authentication method: Pre-shared-keys
  Local: 172.16.11.1:4500, Remote: 172.16.21.1:4500
  Lifetime: Expires in 19657 seconds
  Reauth Lifetime: Disabled
  IKE Fragmentation: Disabled, Size: 0
  Remote Access Client Info: Unknown Client
  Peer ike-id: srx2@example.com
  AAA assigned IP: 0.0.0.0
  Algorithms:
   Authentication        : hmac-sha1-96 
   Encryption            : 3des-cbc
   Pseudo random function: hmac-sha1
   Diffie-Hellman group  : DH-group-2
  Traffic statistics:
   Input  bytes  :                 1780
   Output bytes  :                 2352
   Input  packets:                    7
   Output packets:                   14
   Input  fragmentated packets:       0
   Output fragmentated packets:       0
  IPSec security associations: 4 created, 0 deleted
  Phase 2 negotiations in progress: 1

    Negotiation type: Quick mode, Role: Initiator, Message ID: 0
    Local: 172.16.11.1:4500, Remote: 172.16.21.1:4500
    Local identity: srx1@example.com
    Remote identity: srx2@example.com
    Flags: IKE SA is created
意义

show security ike security-associations 命令会列出所有活动的 IKE 第 1 阶段 SA。如果未列出任何 SA,则第 1 阶段建立存在问题。检查配置中的 IKE 策略参数和外部接口设置。

如果列出了 SA,请查看以下信息:

  • 索引 - 此值对于每个 IKE SA 都是唯一的,您可以在命令中 show security ike security-associations index detail 使用它来获取有关 SA 的更多信息。

  • 远程地址 — 验证远程 IP 地址是否正确,以及端口 4500 是否用于对等通信。 请记住,NAT-T 使用端口 4500 将 IKE 和 ESP 流量封装在 UDP 中。

  • 角色启动器状态

    • Up — 建立第 1 阶段 SA。

    • 关闭 — 建立第 1 阶段 SA 时出现问题。

    • IPsec SA 对中的两个对等方都在使用端口 4500。

    • 对等 IKE ID — 验证远程地址是否正确。

    • 本地身份和远程身份 - 验证它们是否正确。

  • 模式 - 验证是否使用了正确的模式。

验证配置中的以下各项是否正确:

  • 外部接口(接口必须是接收 IKE 数据包的接口)

  • IKE 策略参数

  • 预共享密钥信息

  • 第 1 阶段提议参数(必须在两个对等方上匹配)

show security ike security-associations 命令将列出有关安全关联的其他信息:

  • 使用的身份验证和加密算法

  • 第 1 阶段生存期

  • 流量统计(可用于验证流量是否在两个方向上正常流动)

  • 角色信息

    最好使用响应方角色在对等方上执行故障排除。

  • 发起方和响应方信息

  • 创建的 IPsec SA 数

  • 正在进行的第 2 阶段协商数

验证 SRX1 上的 IPsec 安全关联

目的

验证 IPsec 状态。

操作

在操作模式下,输入 show security ipsec security-associations 命令。有关更详细的输出,请使用 show security ipsec security-associations detail 命令。

content_copy zoom_out_map
user@SRX1> show security ipsec security-associations
  Total active tunnels: 1     Total Ipsec sas: 1
  ID    Algorithm       SPI      Life:sec/kb  Mon lsys Port  Gateway
  <131073 ESP:3des/sha1   fc5dbac4 2160/ unlim  -   root 4500  172.16.21.1
  >131073 ESP:3des/sha1   45fed9d8 2160/ unlim  -   root 4500  172.16.21.1
content_copy zoom_out_map
user@SRX1> show security ipsec security-associations detail
ID: 131073 Virtual-system: root, VPN Name: vpn1
  Local Gateway: 172.16.11.1, Remote Gateway: 172.16.21.1
  Local Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Remote Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Version: IKEv1
  DF-bit: clear, Copy-Outer-DSCP Disabled, Bind-interface: st0.0
  Port: 4500, Nego#: 7, Fail#: 0, Def-Del#: 0 Flag: 0x600a29 
  Multi-sa, Configured SAs# 1, Negotiated SAs#: 1 
  Tunnel events: 
    Fri Jul 22 2022 11:07:40 -0700: IPSec SA rekey successfully completed (3 times)
    Fri Jul 22 2022 08:38:41 -0700: IPSec SA negotiation successfully completed (1 times)
    Fri Jul 22 2022 08:38:41 -0700: User cleared IPSec SA from CLI (1 times)
    Fri Jul 22 2022 08:38:41 -0700: IKE SA negotiation successfully completed (3 times)
    Fri Jul 22 2022 08:38:26 -0700: IPSec SA negotiation successfully completed (1 times)
    Fri Jul 22 2022 08:38:26 -0700: User cleared IPSec SA from CLI (1 times)
    Fri Jul 22 2022 08:38:25 -0700: IPSec SA negotiation successfully completed (1 times)
    Fri Jul 22 2022 08:38:24 -0700: User cleared IPSec SA from CLI (1 times)
    Fri Jul 22 2022 08:37:37 -0700: IPSec SA negotiation successfully completed (1 times)
  Direction: inbound, SPI: fc5dbac4, AUX-SPI: 0
                              , VPN Monitoring: -
    Hard lifetime: Expires in 2153 seconds
    Lifesize Remaining:  Unlimited
    Soft lifetime: Expires in 1532 seconds
    Mode: Tunnel(0 0), Type: dynamic, State: installed
    Protocol: ESP, Authentication: hmac-sha1-96, Encryption: 3des-cbc
    Anti-replay service: counter-based enabled, Replay window size: 64
  Direction: outbound, SPI: 45fed9d8, AUX-SPI: 0
                              , VPN Monitoring: -
    Hard lifetime: Expires in 2153 seconds
    Lifesize Remaining:  Unlimited
    Soft lifetime: Expires in 1532 seconds
    Mode: Tunnel(0 0), Type: dynamic, State: installed
    Protocol: ESP, Authentication: hmac-sha1-96, Encryption: 3des-cbc
    Anti-replay service: counter-based enabled, Replay window size: 64
意义

show security ipsec security-associations 命令输出列出以下信息:

  • 远程网关的n 地址为 172.1 6。2 1.1.

  • IPsec SA 对中的两个对等方都在使用端口 4500。

  • 两个方向都会显示 SPI、生存期(以秒为单位)和使用限制(或生存大小,以 KB 为单位)。2160/unlim 值表示第 2 阶段生存期将在 2160 秒后过期,并且未指定生存大小,表示它是无限的。第 2 阶段生存期可能与第 1 阶段生存期不同,因为在 VPN 启动后,第 2 阶段不依赖于第 1 阶段。

  • 如 Mon 列中的连字符所示,没有为此 SA 启用 VPN 监控。如果启用 VPN 监控,U 表示监控已开启,而 D 表示监控已关闭。

  • 虚拟系统 (vsys) 是根系统,始终列出 0。

验证 SRX2 上的 IKE 第 1 阶段状态

目的

验证 IKE 第 1 阶段状态。

操作

在操作模式下,输入 show security ike security-associations 命令。有关更详细的输出,请使用 show security ike security-associations detail 命令。

content_copy zoom_out_map
user@SRX2> show security ike security-associations
Index   State  Initiator cookie  Responder cookie  Mode           Remote Address   
5567091 UP     84e8fc61d0750278  ea9a07ef032805b6  Main           172.16.11.1
content_copy zoom_out_map
user@SRX2> show security ike security-associations detail
IKE peer 172.16.11.1, Index 5567091, Gateway Name: gw1
  Role: Responder, State: UP
  Initiator cookie: 84e8fc61d0750278, Responder cookie: ea9a07ef032805b6
  Exchange type: Main, Authentication method: Pre-shared-keys
  Local: 10.1.31.1:4500, Remote: 172.16.11.1:4500
  Lifetime: Expires in 18028 seconds
  Reauth Lifetime: Disabled
  IKE Fragmentation: Disabled, Size: 0
  Remote Access Client Info: Unknown Client
  Peer ike-id: srx1@example.com
  AAA assigned IP: 0.0.0.0
  Algorithms:
   Authentication        : hmac-sha1-96 
   Encryption            : 3des-cbc
   Pseudo random function: hmac-sha1
   Diffie-Hellman group  : DH-group-2
  Traffic statistics:
   Input  bytes  :                 2352
   Output bytes  :                 1780
   Input  packets:                   14
   Output packets:                    7
   Input  fragmentated packets:       0
   Output fragmentated packets:       0
  IPSec security associations: 4 created, 3 deleted
  Phase 2 negotiations in progress: 1

    Negotiation type: Quick mode, Role: Responder, Message ID: 0
    Local: 10.1.31.1:4500, Remote: 172.16.11.1:4500
    Local identity: srx2@example.com
    Remote identity: srx1@example.com
    Flags: IKE SA is created
意义

show security ike security-associations 命令会列出所有活动的 IKE 第 1 阶段 SA。如果未列出任何 SA,则第 1 阶段建立存在问题。检查配置中的 IKE 策略参数和外部接口设置。

如果列出了 SA,请查看以下信息:

  • 索引 - 此值对于每个 IKE SA 都是唯一的,您可以在命令中 show security ike security-associations detail 使用它来获取有关 SA 的更多信息。

  • 远程地址 — 验证远程 IP 地址是否正确,以及端口 4500 是否用于对等通信。

  • 角色响应程序状态

    • Up — 第 1 阶段 SA 已建立。

    • 关闭 — 建立第 1 阶段 SA 时出现问题。

    • 对等 IKE ID — 验证地址是否正确。

    • 本地身份和远程身份 - 验证这些地址是否正确。

  • 模式 - 验证是否使用了正确的模式。

验证配置中的以下各项是否正确:

  • 外部接口(接口必须是接收 IKE 数据包的接口)

  • IKE 策略参数

  • 预共享密钥信息

  • 第 1 阶段提议参数(必须在两个对等方上匹配)

show security ike security-associations 命令将列出有关安全关联的其他信息:

  • 使用的身份验证和加密算法

  • 第 1 阶段生存期

  • 流量统计(可用于验证流量是否在两个方向上正常流动)

  • 角色信息

    最好使用响应方角色在对等方上执行故障排除。

  • 发起方和响应方信息

  • 创建的 IPsec SA 数

  • 正在进行的第 2 阶段协商数

验证 SRX2 上的 IPsec 安全关联

目的

验证 IPsec 状态。

操作

在操作模式下,输入 show security ipsec security-associations 命令。有关更详细的输出,请使用 show security ipsec security-associations detail 命令。

content_copy zoom_out_map
user@SRX2> show security ipsec security-associations
  Total active tunnels: 1     Total Ipsec sas: 1
  ID    Algorithm       SPI      Life:sec/kb  Mon lsys Port  Gateway
  <131073 ESP:3des/sha1   45fed9d8 1526/ unlim  -   root 4500  172.16.11.1
  >131073 ESP:3des/sha1   fc5dbac4 1526/ unlim  -   root 4500  172.16.11.1
content_copy zoom_out_map
user@SRX2> show security ipsec security-associations detail
ID: 131073 Virtual-system: root, VPN Name: vpn1
  Local Gateway: 10.1.31.1, Remote Gateway: 172.16.11.1
  Local Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Remote Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Version: IKEv1
  DF-bit: clear, Copy-Outer-DSCP Disabled, Bind-interface: st0.0
  Port: 4500, Nego#: 25, Fail#: 0, Def-Del#: 0 Flag: 0x600a29 
  Multi-sa, Configured SAs# 1, Negotiated SAs#: 1 
  Tunnel events: 
    Fri Jul 22 2022 11:07:40 -0700: IPSec SA negotiation successfully completed (4 times)
    Fri Jul 22 2022 08:38:41 -0700: Initial-Contact received from peer. Stale IKE/IPSec SAs cleared (1 times)
    Fri Jul 22 2022 08:38:41 -0700: IKE SA negotiation successfully completed (5 times)
    Fri Jul 22 2022 08:38:26 -0700: IPSec SA negotiation successfully completed (1 times)
    Fri Jul 22 2022 08:38:26 -0700: IPSec SA delete payload received from peer, corresponding IPSec SAs cleared (1 times)
    Fri Jul 22 2022 08:38:25 -0700: IPSec SA negotiation successfully completed (1 times)
    Fri Jul 22 2022 08:38:25 -0700: Initial-Contact received from peer. Stale IKE/IPSec SAs cleared (1 times)
    Fri Jul 22 2022 08:37:37 -0700: IPSec SA negotiation successfully completed (1 times)
    Fri Jul 22 2022 08:37:37 -0700: IPSec SA delete payload received from peer, corresponding IPSec SAs cleared (1 times)
    Thu Jul 21 2022 17:57:09 -0700: Peer's IKE-ID validation failed during negotiation (1 times)
    Thu Jul 21 2022 17:49:30 -0700: IKE SA negotiation successfully completed (4 times)
  Direction: inbound, SPI: 45fed9d8, AUX-SPI: 0
                              , VPN Monitoring: -
    Hard lifetime: Expires in 1461 seconds
    Lifesize Remaining:  Unlimited
    Soft lifetime: Expires in 885 seconds
    Mode: Tunnel(0 0), Type: dynamic, State: installed
    Protocol: ESP, Authentication: hmac-sha1-96, Encryption: 3des-cbc
    Anti-replay service: counter-based enabled, Replay window size: 64
  Direction: outbound, SPI: fc5dbac4, AUX-SPI: 0
                              , VPN Monitoring: -
    Hard lifetime: Expires in 1461 seconds
    Lifesize Remaining:  Unlimited
    Soft lifetime: Expires in 885 seconds
    Mode: Tunnel(0 0), Type: dynamic, State: installed
    Protocol: ESP, Authentication: hmac-sha1-96, Encryption: 3des-cbc
    Anti-replay service: counter-based enabled, Replay window size: 64
意义

show security ipsec security-associations 命令输出列出以下信息:

  • 远程网关的 IP 地址为 172。16.11.1.

  • IPsec SA 对中的两个对等方都在使用端口 4500。

  • 两个方向都会显示 SPI、生存期(以秒为单位)和使用限制(或生存大小,以 KB 为单位)。1562/unlim 值表示第 2 阶段生存期将在 1562 秒后过期,并且未指定生存大小,表示它是无限的。第 2 阶段生存期可能与第 1 阶段生存期不同,因为在 VPN 启动后,第 2 阶段不依赖于第 1 阶段。

  • 如 Mon 列中的连字符所示,没有为此 SA 启用 VPN 监控。如果启用 VPN 监控,U 表示监控已开启,而 D 表示监控已关闭。

  • 虚拟系统 (vsys) 是根系统,始终列出 0。

show security ipsec security-associations index index_iddetail 命令输出列出以下信息:

  • 本地身份和远程身份组成 SA 的代理 ID。

    代理 ID 不匹配是第 2 阶段故障的最常见原因之一。如果未列出 IPsec SA,请确认第 2 阶段提议(包括代理 ID 设置)对于两个对等方都是正确的。对于基于路由的 VPN,默认代理 ID 为本地 = 0.0.0.0/0,远程 = 0.0.0.0/0,服务 = any。来自相同对等方 IP 的多个基于路由的 VPN 可能会出现问题。在这种情况下,必须为每个 IPsec SA 指定唯一的代理 ID。对于某些第三方供应商,必须手动输入代理 ID 以进行匹配。

  • 第 2 阶段失败的另一个常见原因是未指定 ST 接口绑定。如果 IPsec 无法完成,请检查 kmd 日志或设置追踪选项。

验证主机到主机的可访问性

目的

验证主机 1 是否可以到达主机 2。

操作

从主机 1 ping 主机 2。要验证流量是否正在使用 VPN,请在 SRX1 上使用命令 show security ipsec statistics 。在运行 ping 命令之前,使用命令 clear security ipsec statistics 清除统计信息。

content_copy zoom_out_map
user@Host1> ping 10.1.21.2 count 10 rapid
PING 10.1.21.2 (10.1.21.2): 56 data bytes
!!!!!!!!!!
--- 10.1.21.2 ping statistics ---
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max/stddev = 3.437/4.270/7.637/1.158 ms
content_copy zoom_out_map
user@SRX1> show security ipsec statistics
ESP Statistics:
  Encrypted bytes:             1360
  Decrypted bytes:              840
  Encrypted packets:             10
  Decrypted packets:             10
AH Statistics:
  Input bytes:                    0
  Output bytes:                   0
  Input packets:                  0
  Output packets:                 0
Errors:
  AH authentication failures: 0, Replay errors: 0
  ESP authentication failures: 0, ESP decryption failures: 0
  Bad headers: 0, Bad trailers: 0
意义

输出显示 Host1 可以 ping Host2,并且流量正在使用 VPN。

示例:配置基于策略的 VPN,并在 NAT 设备后面同时包含发起方和响应方

此示例说明如何在 NAT 设备后面配置基于策略的 VPN,并在 NAT 设备后面同时包含发起方和响应方,以允许在分支机构和公司办公室之间安全地传输数据。

要求

开始之前,请阅读 IPsec 概述

概述

在此示例中,您为伊利诺伊州芝加哥的分支机构配置基于策略的 VPN,因为您希望节省隧道资源,但仍会对 VPN 流量进行精细限制。分支机构的用户将使用 VPN 连接到位于加利福尼亚州桑尼维尔的公司总部。

在此示例中,您将为发起方和响应方配置接口、路由选项、安全区域和安全策略。

图 2 显示了静态 NAT 设备后面同时包含发起方和响应方的 VPN 拓扑示例。

图 2: 基于策略的 VPN 拓扑,NAT 设备后面既有发起方又有响应方基于策略的 VPN 拓扑,NAT 设备后面既有发起方又有响应方

在此示例中,您将配置接口、IPv4 默认路由和安全区域。然后配置 IKE 阶段 1,包括本地和远程对等方、IPsec 阶段 2 和安全策略。请注意,在上面的示例中,响应方的私有 IP 地址 13.168.11.1 被静态 NAT 设备隐藏,并映射到公共 IP 地址 1.1.100.1。

有关表 7示例中用于启动器的特定配置参数,请参阅。表 10

表 7: 启动器的接口、路由选项和安全区域

功能

名称

配置参数

接口

ge-0/0/0

12.168.99.100/24

 

ge-0/0/1

10.1.99.1/24

静态路由

10.2.99.0/24(默认路由)

下一跃点是 12.168.99.100。

 

1.1.100.0/24

12.168.99.100

安全区域

trust

  • 允许所有系统服务。

  • 允许所有协议。

  • ge-0/0/1.0 接口绑定到此区域。

 

untrust

  • ge-0/0/0.0 接口绑定到此区域。

表 8: 启动器的 IKE 第 1 阶段配置参数

功能

名称

配置参数

提议

ike_prop

  • 身份验证方法:预共享密钥

  • Diffie-Hellman 组:group2

  • 身份验证算法:MD5

  • 加密算法:3DES-CBC

策略

ike_pol

  • 模式:主

  • 提议参考:ike_prop

  • IKE 第 1 阶段策略身份验证方法:预共享密钥 ASCII 文本

网关

  • IKE 策略参考:ike_pol

  • 外部接口:ge-0/0/1.0

  • 网关地址:1.1.100.23

  • 本地对等方是主机名芝加哥

  • 远程对等方是主机名 Sunnyvale

表 9: 启动器的 IPsec 第 2 阶段配置参数

功能

名称

配置参数

提议

ipsec_prop

  • 协议:esp

  • 身份验证算法:HMAC-MD5-96

  • 加密算法:3DES-CBC

策略

ipsec_pol

  • 提议参考:ipsec_prop

  • 完全向前保密 (PFS):group1

VPN

first_vpn

  • IKE 网关参考:门

  • IPsec 策略参考:ipsec_pol

表 10: 启动器的安全策略配置参数

目的

名称

配置参数

安全策略允许从信任区域到不信任区域的隧道流量。

pol1

  • 匹配标准:

    • 源-地址 任意

    • 目标地址

    • application any

  • 操作:允许隧道 IPsec-VPN first_vpn

安全策略允许从不信任区域到信任区域的隧道流量。

pol1

  • 匹配标准:

    • application any

  • 操作:允许隧道 IPsec-VPN first_vpn

有关示例中用于响应程序的特定配置参数,请参阅表 11表 14

表 11: 响应方的接口、路由选项和安全区域

功能

名称

配置参数

接口

ge-0/0/0

13.168.11.100/24

 

ge-0/0/1

10.2.99.1/24

静态路由

10.1.99.0/24(默认路由)

下一跃点是 13.168.11.100

 

1.1.100.0/24

13.168.11.100

安全区域

trust

  • 允许所有系统服务。

  • 允许所有协议。

  • ge-0/0/1.0 接口绑定到此区域。

 

untrust

  • ge-0/0/0.0 接口绑定到此区域。

表 12: 响应方的 IKE 第 1 阶段配置参数

功能

名称

配置参数

提议

ike_prop

  • 身份验证方法:预共享密钥

  • Diffie-Hellman 组:group2

  • 身份验证算法:MD5

  • 加密算法:3DES-CBC

策略

ike_pol

  • 模式:主

  • 提议参考:ike_prop

  • IKE 第 1 阶段策略身份验证方法:预共享密钥 ASCII 文本

网关

  • IKE 策略参考:ike_pol

  • 外部接口:ge-0/0/1.0

  • 网关地址:1.1.100.22

  • 始终发送失效对等体检测

  • 本地对等方是主机名森尼维尔

  • 远程对等方是主机名芝加哥

表 13: 响应程序的 IPsec 第 2 阶段配置参数

功能

名称

配置参数

提议

ipsec_prop

  • 协议:esp

  • 身份验证算法:HMAC-MD5-96

  • 加密算法:3DES-CBC

策略

ipsec_pol

  • 提议参考:ipsec_prop

  • 完全向前保密 (PFS):group1

VPN

first_vpn

  • IKE 网关参考:门

  • IPsec 策略参考:ipsec_pol

表 14: 响应程序的安全策略配置参数

目的

名称

配置参数

安全策略允许从信任区域到不信任区域的隧道流量。

pol1

  • 匹配标准:

    • 源-地址 任意

    • 目标地址

    • application any

  • 操作:允许隧道 IPsec-VPN first_vpn

安全策略允许从不信任区域到信任区域的隧道流量。

pol1

  • 匹配标准:

    • application any

  • 操作:允许隧道 IPsec-VPN first_vpn

配置

为启动器配置接口、路由选项和安全区域

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
[edit]
set interfaces ge-0/0/0 unit 0 family inet address 12.168.99.100/24
set interfaces ge-0/0/1 unit 0 family inet address 10.1.99.1/24
set routing-options static route 10.2.99.0/24 next-hop 12.168.99.1
set routing-options static route 1.1.100.0/24 next-hop 12.168.99.1
set security zones security-zone trust host-inbound-traffic system-services all
set security zones security-zone trust host-inbound-traffic protocols all
set security zones security-zone trust interfaces ge-0/0/1.0
set security zones security-zone untrust interfaces ge-0/0/0.0
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置接口、静态路由和安全区域,请执行以下操作:

  1. 配置以太网接口信息。

    content_copy zoom_out_map
    [edit]
    user@host# set interfaces ge-0/0/0 unit 0 family inet address 12.168.99.100/24
    user@host# set interfaces ge-0/0/1 unit 0 family inet address 10.1.99.1/24
    
  2. 配置静态路由信息。

    content_copy zoom_out_map
    [edit]
    user@host# set routing-options static route 10.2.99.0/24 next-hop 12.168.99.1
    user@host# set routing-options static route 1.1.100.0/24 next-hop 12.168.99.1
    
  3. 配置信任安全区域。

    content_copy zoom_out_map
    [edit ]
    user@host# set security zones security-zone trust host-inbound-traffic protocols all
    
  4. 为信任安全区域分配接口。

    content_copy zoom_out_map
    [edit security zones security-zone trust]
    user@host# set interfaces ge-0/0/1.0
    
  5. 为信任安全区域指定系统服务。

    content_copy zoom_out_map
    [edit security zones security-zone trust]
    user@host# set host-inbound-traffic system-services all
    
  6. 为不信任安全区域分配接口。

    content_copy zoom_out_map
    [edit security zones security-zone untrust]
    user@host# set interfaces ge-0/0/0.0
    
结果

在配置模式下,通过输入 show interfacesshow routing-optionsshow security zones 命令来确认您的配置 如果输出未显示预期的配置,请重复此示例中的说明以更正配置。

content_copy zoom_out_map
[edit]
user@host# show interfaces
    ge-0/0/0 {
        unit 0 {
            family inet {
                address 12.168.99.100/24;
            }
        }
    }
    ge-0/0/1 {
        unit 0 {
            family inet {
                address 10.1.99.1/24;
            }
        }
    }
content_copy zoom_out_map
[edit]
user@host# show routing-options
    static {
        route 10.2.99.0/24 next-hop 12.168.99.1;
        route 1.1.100.0/24 next-hop 12.168.99.1;
    }
content_copy zoom_out_map
[edit]
user@host# show security zones
    security-zone trust {
        host-inbound-traffic {
            system-services {
                all;
            }
            protocols {
                all;
            }
        }
        interfaces {
            ge-0/0/1.0;
        }
    }
    security-zone untrust {
        host-inbound-traffic {
        }
        interfaces {
            ge-0/0/0.0;
        }
    }

如果完成设备配置,请从配置模式输入 commit

为启动器配置 IKE

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security ike proposal ike_prop authentication-method pre-shared-keys
set security ike proposal ike_prop dh-group group2
set security ike proposal ike_prop authentication-algorithm md5
set security ike proposal ike_prop encryption-algorithm 3des-cbc
set security ike policy ike_pol mode aggressive
set security ike policy ike_pol proposals ike_prop
set security ike policy ike_pol pre-shared-key ascii-text "$ABC123”
set security ike gateway gate ike-policy ike_pol
set security ike gateway gate address 13.168.11.100
set security ike gateway gate external-interface ge-0/0/0.0
set security ike gateway gate local-identity hostname chicago
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置 IKE:

  1. 创建 IKE 第 1 阶段提议。

    content_copy zoom_out_map
    [edit security ike]
    user@host# edit proposal ike_prop
    
  2. 定义 IKE 提议身份验证方法。

    content_copy zoom_out_map
    [edit security ike proposal ike_prop]
    user@host# set authentication-method pre-shared-keys
    
  3. 定义 IKE 提议 Diffie-Hellman 组。

    content_copy zoom_out_map
    [edit security ike proposal ike_prop]
    user@host# set dh-group group2
    
  4. 定义 IKE 提议身份验证算法。

    content_copy zoom_out_map
    [edit security ike proposal ike_prop]
    user@host# set authentication-algorithm md5
    
  5. 定义 IKE 提议加密算法。

    content_copy zoom_out_map
    [edit security ike proposal ike_prop]
    user@host# set encryption-algorithm 3des-cbc
    
  6. 创建 IKE 第 1 阶段策略。

    content_copy zoom_out_map
    [edit security ike policy ]
    user@host# edit policy ike_pol
    
  7. 设置 IKE 第 1 阶段策略模式。

    content_copy zoom_out_map
    [edit security ike policy ike_pol]
    user@host# set mode aggressive
    
  8. 指定对 IKE 提议的参考。

    content_copy zoom_out_map
    [edit security ike policy ike_pol]
    user@host# set proposals ike_prop
    
  9. 定义 IKE 第 1 阶段策略身份验证方法。

    content_copy zoom_out_map
    [edit security ike policy ike_pol pre-shared-key]
    user@host# set ascii-text "$ABC123”
    
  10. 创建 IKE 第 1 阶段网关并定义其外部接口。

    content_copy zoom_out_map
    [edit security ike ]
    user@host# set gateway gate external-interface ge-0/0/0.0
    
  11. 创建 IKE 第 1 阶段网关地址。

    content_copy zoom_out_map
    [edit security ike gateway gate]
    set address 13.168.11.100
    
  12. 定义 IKE 第 1 阶段策略参考。

    content_copy zoom_out_map
    [edit security ike gateway gate]
    set ike-policy ike_pol
    
  13. 为本地对等方设置 local-identity

    content_copy zoom_out_map
    [edit security ike gateway gate]
    user@host# set local-identity hostname chicago
    
结果

在配置模式下,输入 show security ike 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show security ike
    proposal ike_prop {
        authentication-method pre-shared-keys;
        dh-group group2;
        authentication-algorithm md5;
        encryption-algorithm 3des-cbc;
    }
    policy ike_pol {
        mode aggressive;
        proposals ike_prop;
        pre-shared-key ascii-text "$ABC123”
    }
    gateway gate {
        ike-policy ike_pol;
        address 13.168.11.100;
        local-identity hostname chicago;
        external-interface ge-0/0/0.0;
    }

如果完成设备配置,请从配置模式输入 commit

为启动器配置 IPsec

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security ipsec proposal ipsec_prop protocol esp
set security ipsec proposal ipsec_prop authentication-algorithm hmac-md5-96
set security ipsec proposal ipsec_prop encryption-algorithm 3des-cbc
set security ipsec policy ipsec_pol perfect-forward-secrecy keys group1
set security ipsec policy ipsec_pol proposals ipsec_prop
set security ipsec vpn first_vpn ike gateway gate
set security ipsec vpn first_vpn ike ipsec-policy ipsec_pol
set security ipsec vpn first_vpn establish-tunnels immediately
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置 IPsec:

  1. 创建 IPsec 第 2 阶段提议。

    content_copy zoom_out_map
    [edit]
    user@host# edit security ipsec proposal ipsec_prop
    
  2. 指定 IPsec 第 2 阶段提议协议。

    content_copy zoom_out_map
    [edit security ipsec proposal ipsec_prop]
    user@host# set protocol esp
    
  3. 指定 IPsec 第 2 阶段提议身份验证算法。

    content_copy zoom_out_map
    [edit security ipsec proposal ipsec_prop]
    user@host# set authentication-algorithm hmac-md5-96
    
  4. 指定 IPsec 第 2 阶段提议加密算法。

    content_copy zoom_out_map
    [edit security ipsec proposal ipsec_prop]
    user@host# set encryption-algorithm 3des-cbc
    
  5. 指定 IPsec 第 2 阶段提议参考。

    content_copy zoom_out_map
    [edit security ipsec policy ipsec_pol]
    user@host# set proposals ipsec_prop
    
  6. 指定 IPsec 阶段 2 以使用完全向前保密 (PFS) 组 1。

    content_copy zoom_out_map
    [edit security ipsec policy ipsec_pol ]
    user@host# set perfect-forward-secrecy keys group1
    
  7. 指定 IKE 网关。

    content_copy zoom_out_map
    [edit security ipsec]
    user@host# set vpn first_vpn ike gateway gate
    
  8. 指定 IPsec 第 2 阶段策略。

    content_copy zoom_out_map
    [edit security ipsec]
    user@host# set vpn first_vpn ike ipsec-policy ipsec_pol
    
结果

在配置模式下,输入 show security ipsec 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show security ipsec
    proposal ipsec_prop {
        protocol esp;
        authentication-algorithm hmac-md5-96;
        encryption-algorithm 3des-cbc;
    }
    policy ipsec_pol {
        perfect-forward-secrecy {
            keys group1;
        }
        proposals ipsec_prop;
    }
    vpn first_vpn {
        ike {
            gateway gate;
            ipsec-policy ipsec_pol;
        }
        establish-tunnels immediately;
    }

如果完成设备配置,请从配置模式输入 commit

为启动器配置安全策略

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security policies from-zone trust to-zone untrust policy pol1 match source-address any
set security policies from-zone trust to-zone untrust policy pol1 match destination-address any
set security policies from-zone trust to-zone untrust policy pol1 match application any
set security policies from-zone trust to-zone untrust policy pol1 then permit tunnel ipsec-vpn first_vpn
set security policies from-zone untrust to-zone trust policy pol1 match application any
set security policies from-zone untrust to-zone trust policy pol1 then permit tunnel ipsec-vpn first_vpn
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置安全策略:

  1. 创建安全策略以允许从信任区域到不信任区域的流量。

    content_copy zoom_out_map
    [edit security policies from-zone trust to-zone untrust]
    user@host# set policy pol1 match source-address any
    user@host# set policy pol1 match destination-address any
    user@host# set policy pol1 match application any
    user@host# set policy pol1 then permit tunnel ipsec-vpn first_vpn
    
  2. 创建安全策略以允许从不信任区域到信任区域的流量。

    content_copy zoom_out_map
    [edit security policies from-zone untrust to-zone trust]
    user@host# set policy pol1 match application any
    user@host# set policy pol1 then permit tunnel ipsec-vpn first_vpn
    
结果

在配置模式下,输入 show security policies 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show security policies
    from-zone trust to-zone untrust {
        policy pol1 {
            match {
                source-address any;
                destination-address any;
                application any;
            }
            then {
                permit {
                    tunnel {
                        ipsec-vpn first_vpn;
                    }
                }
            }
        }
    }
    from-zone untrust to-zone trust {
        policy pol1 {
            match {
                application any;
            }
            then {
                permit {
                    tunnel {
                        ipsec-vpn first_vpn;
                    }
                }
            }
        }
    }

如果完成设备配置,请从配置模式输入 commit

为启动器配置 NAT

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security nat source rule-set ipsec from zone trust
set security nat source rule-set ipsec to zone untrust
set security nat source rule-set ipsec rule 1 match source-address 0.0.0.0/0
set security nat source rule-set ipsec rule 1 then source-nat interface
set security policies from-zone trust to-zone untrust policy allow-all match source-address any
set security policies from-zone trust to-zone untrust policy allow-all match destination-address any
set security policies from-zone trust to-zone untrust policy allow-all match application any
set security policies from-zone trust to-zone untrust policy allow-all then permit
set security policies from-zone untrust to-zone trust policy allow-all match application any
set security policies from-zone untrust to-zone trust policy allow-all then permit
set security zones security-zone trust host-inbound-traffic system-services all
set security zones security-zone trust host-inbound-traffic protocols all
set security zones security-zone trust interfaces ge-0/0/0.0
set security zones security-zone untrust interfaces ge-0/0/1.0
set interfaces ge-0/0/0 unit 0 family inet address 12.168.99.1/24
set interfaces ge-0/0/1 unit 0 family inet address 1.1.100.23/24
set routing-options static route 0.0.0.0/0 next-hop 1.1.100.22
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置提供 NAT 的启动器,请执行以下操作:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@host# set ge-0/0/0 unit 0 family inet address 12.168.99.1/24
    user@host# set ge-0/0/1 unit 0 family inet address 1.1.100.23/24
    
  2. 配置区域。

    content_copy zoom_out_map
    [edit security zones security-zone trust]
    user@host# set host-inbound-traffic system-services all
    user@host# set host-inbound-traffic protocols all
    user@host# set interfaces ge-0/0/0.0
    
    content_copy zoom_out_map
    [edit security zones security-zone untrust]
    user@host# set interfaces ge-0/0/1.0
    
  3. 配置 NAT。

    content_copy zoom_out_map
    [edit security nat source rule-set ipsec]
    user@host# set from zone trust
    user@host# set to zone untrust
    user@host# set rule 1 match source-address 0.0.0.0/0
    user@host# set rule 1 then source-nat interface
    
  4. 配置默认安全策略。

    content_copy zoom_out_map
    [edit security policies]
    user@host# set from-zone trust to-zone untrust policy allow-all match source-address any
    user@host# set from-zone trust to-zone untrust policy allow-all match destination-address any
    user@host# set from-zone trust to-zone untrust policy allow-all match application any
    user@host# set from-zone trust to-zone untrust policy allow-all then permit
    user@host# set from-zone untrust to-zone trust policy allow-all match application any
    user@host# set from-zone untrust to-zone trust policy allow-all then permit
    
  5. 配置路由选项。

    content_copy zoom_out_map
    [edit routing-options
    user@host# set static route 0.0.0.0/0 next-hop 1.1.100.22
    
结果

在配置模式下,输入 show security nat 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show security nat
        source {
            rule-set ipsec {
                from zone trust;
                to zone untrust;
                rule 1 {
                    match {
                        source-address 0.0.0.0/0;
                    }
                    then {
                        source-nat {
                            interface;
                        }
                    }
                }
            }
        }
    }
    policies {
        from-zone trust to-zone untrust {
            policy allow-all {
                match {
                    source-address any;
                    destination-address any;
                    application any;
                }
                then {
                    permit;
                }
            }
        }
        from-zone untrust to-zone trust {
            policy allow-all {
                match {
                    application any;
                }
                then {
                    permit;
                }
            }
        }
    }
    zones {
        security-zone trust {
            host-inbound-traffic {
                system-services {
                    all;
                }
                protocols {
                    all;
                }
            }
            interfaces {
                ge-0/0/0.0;
            }
        }
        security-zone untrust {
            host-inbound-traffic {
            }
            interfaces {
                ge-0/0/1.0;
            }
        }
    }
}
interfaces {
    ge-0/0/0 {
        unit 0 {
            family inet {
                address 12.168.99.1/24;
            }
        }
    }
    ge-0/0/1 {
        unit 0 {
            family inet {
                address 1.1.100.23/24;
            }
        }
    }
}
routing-options {
    static {
        route 0.0.0.0/0 next-hop 1.1.100.22;
    }

如果完成设备配置,请从配置模式输入 commit

为响应方配置接口、路由选项和安全区域

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set interfaces ge-0/0/0 unit 0 family inet address 13.168.11.100/24
set interfaces ge-0/0/1 unit 0 family inet address 10.2.99.1/24
set routing-options static route 10.1.99.0/24 next-hop 13.168.11.1
set routing-options static route 1.1.100.0/24 next-hop 13.168.11.1
set security zones security-zone untrust interfaces ge-0/0/0.0
set security zones security-zone trust host-inbound-traffic system-services all
set security zones security-zone trust host-inbound-traffic protocols all
set security zones security-zone trust interfaces ge-0/0/1.0
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置接口、静态路由、安全区域和安全策略,请执行以下操作:

  1. 配置以太网接口信息。

    content_copy zoom_out_map
    [edit]
    user@host# set interfaces ge-0/0/0 unit 0 family inet address 13.168.11.100/24
    user@host# set interfaces ge-0/0/1 unit 0 family inet address 10.2.99.1/24
    
  2. 配置静态路由信息。

    content_copy zoom_out_map
    [edit]
    user@host# set routing-options static route 10.1.99.0/24 next-hop 13.168.11.1
    user@host# set routing-options static route 1.1.100.0/24 next-hop 13.168.11.1
    
  3. 为不信任安全区域分配接口。

    content_copy zoom_out_map
    [edit security zones security-zone untrust]
    user@host# set interfaces ge-0/0/0.0
    
  4. 配置信任安全区域。

    content_copy zoom_out_map
    [edit]
    user@host# set security zones security-zone trust host-inbound-traffic protocols all
    
  5. 为信任安全区域分配接口。

    content_copy zoom_out_map
    [edit security zones security-zone trust]
    user@host# set interfaces ge-0/0/1.0
    
  6. 为信任安全区域指定允许的系统服务。

    content_copy zoom_out_map
    [edit security zones security-zone trust]
    user@host# set host-inbound-traffic system-services all
    
结果

在配置模式下,输入 show interfacesshow routing-optionsshow security zones 命令确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show interfaces
    ge-0/0/0 {
        unit 0 {
            family inet {
                address 13.168.11.100/24;
            }
        }
    }
    ge-0/0/1 {
        unit 0 {
            family inet {
                address 10.2.99.1/24;
            }
        }
    }
content_copy zoom_out_map
[edit]
user@host# show routing-options
    static {
        route 10.1.99.0/24 next-hop 13.168.11.1;
        route 1.1.100.0/24 next-hop 13.168.11.1;
    }
content_copy zoom_out_map
[edit]
user@host# show security zones
    security-zone untrust {
        host-inbound-traffic {
        }
        interfaces {
            ge-0/0/0.0;
        }
    }
    security-zone trust {
        host-inbound-traffic {
            system-services {
                all;
            }
            protocols {
                all;
            }
        }
        interfaces {
            ge-0/0/1.0;
        }
    }

如果完成设备配置,请从配置模式输入 commit

为响应方配置 IKE

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security ike proposal ike_prop authentication-method pre-shared-keys
set security ike proposal ike_prop dh-group group2
set security ike proposal ike_prop authentication-algorithm md5
set security ike proposal ike_prop encryption-algorithm 3des-cbc
set security ike policy ike_pol mode aggressive
set security ike policy ike_pol proposals ike_prop
set security ike policy ike_pol pre-shared-key ascii-text "$ABC123"
set security ike gateway gate ike-policy ike_pol
set security ike gateway gate dynamic hostname chicago
set security ike gateway gate external-interface ge-0/0/0.0
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置 IKE:

  1. 定义 IKE 提议身份验证方法。

    content_copy zoom_out_map
    [edit security ike proposal ike_prop]
    user@host# set authentication-method pre-shared-key
    
  2. 定义 IKE 提议 Diffie-Hellman 组。

    content_copy zoom_out_map
    [edit security ike proposal ike_prop]
    user@host# set dh-group group2
    
  3. 定义 IKE 提议身份验证算法。

    content_copy zoom_out_map
    [edit security ike proposal ike_prop]
    user@host# set authentication-algorithm md5
    
  4. 定义 IKE 提议加密算法。

    content_copy zoom_out_map
    [edit security ike proposal ike_prop]
    user@host# set encryption-algorithm 3des-cbc
    
  5. 创建 IKE 第 1 阶段策略。

    content_copy zoom_out_map
    [edit security ike]
    user@host# edit policy ike_pol
    
  6. 设置 IKE 第 1 阶段策略模式。

    content_copy zoom_out_map
    [edit security ike policy ike_pol]
    user@host# set mode aggressive
    
  7. 指定对 IKE 提议的参考。

    content_copy zoom_out_map
    [edit security ike policy ike_pol]
    user@host# set proposals ike_prop
    
  8. 定义 IKE 第 1 阶段策略身份验证方法。

    content_copy zoom_out_map
    [edit security ike policy ike_pol]
    user@host# set pre-shared-key ascii-text "$ABC123"
    
  9. 创建 IKE 第 1 阶段网关并定义其动态主机名。

    content_copy zoom_out_map
    [edit security ike gateway gate]
    user@host# set dynamic hostname chicago
    
  10. 创建 IKE 第 1 阶段网关并定义其外部接口。

    content_copy zoom_out_map
    [edit security ike gateway gate]
    user@host# set external-interface ge-0/0/0.0
    
  11. 定义 IKE 第 1 阶段策略参考。

    content_copy zoom_out_map
    [edit security ike gateway gate]
    user@host# set ike-policy ike_pol
    
结果

在配置模式下,输入 show security ike 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show security ike
    proposal ike_prop {
        authentication-method pre-shared-keys;
        dh-group group2;
        authentication-algorithm md5;
        encryption-algorithm 3des-cbc;
    }
    policy ike_pol {
        mode aggressive;
        proposals ike_prop;
        pre-shared-key ascii-text "$ABC123";
    }
    gateway gate {
        ike-policy ike_pol;
        dynamic hostname chicago;
        external-interface ge-0/0/0.0;
    }

如果完成设备配置,请从配置模式输入 commit

为响应方配置 IPsec

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security ipsec proposal ipsec_prop protocol esp
set security ipsec proposal ipsec_prop authentication-algorithm hmac-md5-96
set security ipsec proposal ipsec_prop encryption-algorithm 3des-cbc
set security ipsec policy ipsec_pol perfect-forward-secrecy keys group1
set security ipsec policy ipsec_pol proposals ipsec_prop
set security ipsec vpn first_vpn ike gateway gate
set security ipsec vpn first_vpn ike ipsec-policy ipsec_pol
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置 IPsec:

  1. 创建 IPsec 第 2 阶段提议。

    content_copy zoom_out_map
    [edit]
    user@host# edit security ipsec proposal ipsec_prop
    
  2. 指定 IPsec 第 2 阶段提议协议。

    content_copy zoom_out_map
    [edit security security ipsec proposal ipsec_prop]
    user@host# set protocol esp
    
  3. 指定 IPsec 第 2 阶段提议身份验证算法。

    content_copy zoom_out_map
    [edit security ipsec proposal ipsec_prop]
    user@host# set authentication-algorithm hmac-md5-96
    
  4. 指定 IPsec 第 2 阶段提议加密算法。

    content_copy zoom_out_map
    [edit security ipsec proposal ipsec_prop]
    user@host# set encryption-algorithm 3des-cbc
    
  5. 创建 IPsec 第 2 阶段策略。

    content_copy zoom_out_map
    [edit security ipsec]
    user@host# edit policy ipsec_pol
    
  6. 将 IPsec 阶段 2 设置为使用完全向前保密 (PFS) 组 1。

    content_copy zoom_out_map
    [edit security ipsec policy ipsec_pol]
    user@host# set perfect-forward-secrecy keys group1
    
  7. 指定 IPsec 第 2 阶段提议参考。

    content_copy zoom_out_map
    [edit security ipsec policy ipsec_pol]
    user@host# set proposals ipsec_prop
    
  8. 指定 IKE 网关。

    content_copy zoom_out_map
    [edit security ipsec]
    user@host# set vpn first_vpn ike gateway gate
    
  9. 指定 IPsec 第 2 阶段策略。

    content_copy zoom_out_map
    [edit security ipsec]
    user@host# set vpn first_vpn ike ipsec-policy ipsec_pol
    
结果

在配置模式下,输入 show security ipsec 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show security ipsec
    proposal ipsec_prop {
        protocol esp;
        authentication-algorithm hmac-md5-96;
        encryption-algorithm 3des-cbc;
    }
    policy ipsec_pol {
        perfect-forward-secrecy {
            keys group1;
        }
        proposals ipsec_prop;
    }
    vpn first_vpn {
        ike {
            gateway gate;
            ipsec-policy ipsec_pol;
        }
    }

如果完成设备配置,请从配置模式输入 commit

为响应方配置安全策略

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security policies from-zone trust to-zone untrust policy pol1 match source-address any
set security policies from-zone trust to-zone untrust policy pol1 match destination-address any
set security policies from-zone trust to-zone untrust policy pol1 match application any
set security policies from-zone trust to-zone untrust policy pol1 then permit tunnel ipsec-vpn first_vpn
set security policies from-zone untrust to-zone trust policy pol1 match application any
set security policies from-zone untrust to-zone trust policy pol1 then permit tunnel ipsec-vpn first_vpn
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置安全策略:

  1. 创建安全策略以允许从信任区域到不信任区域的流量。

    content_copy zoom_out_map
    [edit security policies from-zone trust to-zone untrust]
    user@host# set policy pol1 match source-address any
    user@host# set policy pol1 match destination-address any
    user@host# set policy pol1 match application any
    user@host# set policy pol1 then permit tunnel ipsec-vpn first_vpn
    
  2. 创建安全策略以允许从不信任区域到信任区域的流量。

    content_copy zoom_out_map
    [edit security policies from-zone untrust to-zone trust]
    user@host# set policy pol1 match application any
    user@host# set policy pol1 then permit tunnel ipsec-vpn first_vpn
    
结果

在配置模式下,输入 show security policies 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show security policies
    from-zone trust to-zone untrust {
        policy pol1 {
            match {
                source-address any;
                destination-address any;
                application any;
            }
            then {
                permit {
                    tunnel {
                        ipsec-vpn first_vpn;
                    }
                }
            }
        }
    }
    from-zone untrust to-zone trust {
        policy pol1 {
            match {
                application any;
            }
            then {
                permit {
                    tunnel {
                        ipsec-vpn first_vpn;
                    }
                }
            }
        }
    }

如果完成设备配置,请从配置模式输入 commit

为响应方配置 NAT

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set security nat source rule-set ipsec from zone trust
set security nat source rule-set ipsec to zone untrust
set security nat source rule-set ipsec rule 1 match source-address 0.0.0.0/0
set security nat source rule-set ipsec rule 1 then source-nat interface
set security policies from-zone trust to-zone untrust policy allow-all match source-address any
set security policies from-zone trust to-zone untrust policy allow-all match destination-address any
set security policies from-zone trust to-zone untrust policy allow-all match application any
set security policies from-zone trust to-zone untrust policy allow-all then permit
set security policies from-zone untrust to-zone trust policy allow-all match application any
set security policies from-zone untrust to-zone trust policy allow-all then permit
set security zones security-zone trust host-inbound-traffic system-services all
set security zones security-zone trust host-inbound-traffic protocols all
set security zones security-zone trust interfaces ge-0/0/0.0
set security zones security-zone untrust interfaces ge-0/0/1.0
set interfaces ge-0/0/0 unit 0 family inet address 13.168.11.1/24
set interfaces ge-0/0/1 unit 0 family inet address 1.1.100.22/24
set routing-options static route 0.0.0.0/0 next-hop 1.1.100.23
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置提供 NAT 的响应方,请执行以下操作:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@host# set ge-0/0/0 unit 0 family inet address 13.168.11.1/24
    user@host# set ge-0/0/1 unit 0 family inet address 1.1.100.22/24
    
  2. 配置区域。

    content_copy zoom_out_map
    [edit security zones security-zone trust]
    user@host# set host-inbound-traffic system-services all
    user@host# set host-inbound-traffic protocols all
    user@host# set interfaces ge-0/0/0.0
    
    content_copy zoom_out_map
    [edit security zones security-zone untrust]
    user@host# set interfaces ge-0/0/1.0
    
  3. 配置 NAT。

    content_copy zoom_out_map
    [edit security nat source rule-set ipsec]
    user@host# set from zone trust
    user@host# set to zone untrust
    user@host# set rule 1 match source-address 0.0.0.0/0
    user@host# set rule 1 then source-nat interface
    
  4. 配置默认安全策略。

    content_copy zoom_out_map
    [edit security policies]
    user@host# set from-zone trust to-zone untrust policy allow-all match source-address any
    user@host# set from-zone trust to-zone untrust policy allow-all match destination-address any
    user@host# set from-zone trust to-zone untrust policy allow-all match application any
    user@host# set from-zone trust to-zone untrust policy allow-all then permit
    user@host# set from-zone untrust to-zone trust policy allow-all match application any
    user@host# set from-zone untrust to-zone trust policy allow-all then permit
    
  5. 配置路由选项。

    content_copy zoom_out_map
    [edit routing-options
    user@host# set static route 0.0.0.0/0 next-hop 1.1.100.23
    
结果

在配置模式下,输入 show security nat 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show security nat
    nat {
        source {
            rule-set ipsec {
                from zone trust;
                to zone untrust;
                rule 1 {
                    match {
                        source-address 0.0.0.0/0;
                    }
                    then {
                        source-nat {
                            interface;
                        }
                    }
                }
            }
        }
    }
    policies {
        from-zone trust to-zone untrust {
            policy allow-all {
                match {
                    source-address any;
                    destination-address any;
                    application any;
                }
                then {
                    permit;
                }
            }
        }
        from-zone untrust to-zone trust {
            policy allow-all {
                match {
                    application any;
                }
                then {
                    permit;
                }
            }
        }
    }
    zones {
        security-zone trust {
            host-inbound-traffic {
                system-services {
                    all;
                }
                protocols {
                    all;
                }
            }
            interfaces {
                ge-0/0/0.0;
            }
        }
        security-zone untrust {
            host-inbound-traffic {
            }
            interfaces {
                ge-0/0/1.0;
            }
        }
    }
}
interfaces {
    ge-0/0/0 {
        unit 0 {
            family inet {
                address 13.168.11.1/24;
            }
        }
    }
    ge-0/0/1 {
        unit 0 {
            family inet {
                address 1.1.100.22/24;
            }
        }
    }
}
routing-options {
    static {
        route 0.0.0.0/0 next-hop 1.1.100.23;
    }

如果完成设备配置,请从配置模式输入 commit

验证

要确认配置工作正常,请执行以下任务:

验证启动器的 IKE 第 1 阶段状态

目的

验证 IKE 第 1 阶段状态。

操作

在开始验证过程之前,必须将流量从 10.1.99.0 网络中的主机发送到 10.2.99.0 网络中的主机。对于基于路由的 VPN,流量可由 SRX 系列防火墙通过隧道启动。建议在测试 IPsec 隧道时,将测试流量从 VPN 一端的单独设备发送到 VPN 另一端的另一台设备。例如,启动从 10.1.99.2 到 10.2.99.2 的 ping 操作。

在操作模式下,输入 show security ike security-associations 命令。从命令获取索引号之后,请使用 show security ike security-associations index index_number detail 命令。

content_copy zoom_out_map
user@host> show security ike security-associations
Index   State  Initiator cookie  Responder cookie  Mode           Remote Address   
5649304 UP     c3193077d38e426f  011f0ef28d928f4c  Aggressive     13.168.11.
content_copy zoom_out_map
user@host> show security ike security-associations index 5649304 detail
IKE peer 13.168.11.100, Index 5649304, Gateway Name: gate
  Role: Initiator, State: UP
  Initiator cookie: c3193077d38e426f, Responder cookie: 011f0ef28d928f4c
  Exchange type: Aggressive, Authentication method: Pre-shared-keys
  Local: 12.168.99.100:4500, Remote: 13.168.11.100:4500
  Lifetime: Expires in 26359 seconds
  Reauth Lifetime: Disabled
  IKE Fragmentation: Disabled, Size: 0
  Remote Access Client Info: Unknown Client
  Peer ike-id: 13.168.11.100
  AAA assigned IP: 0.0.0.0
  Algorithms:
   Authentication        : hmac-md5-96 
   Encryption            : 3des-cbc
   Pseudo random function: hmac-md5
   Diffie-Hellman group  : DH-group-2
  Traffic statistics:
   Input  bytes  :                 1140
   Output bytes  :                 1203
   Input  packets:                    6
   Output packets:                    6
   Input  fragmentated packets:       0
   Output fragmentated packets:       0 
  IPSec security associations: 2 created, 3 deleted
  Phase 2 negotiations in progress: 1

    Negotiation type: Quick mode, Role: Initiator, Message ID: 0
    Local: 12.168.99.100:4500, Remote: 13.168.11.100:4500
    Local identity: chicago
    Remote identity: 13.168.11.100
    Flags: IKE SA is created
意义

show security ike security-associations 命令会列出所有活动的 IKE 第 1 阶段 SA。如果未列出任何 SA,则第 1 阶段建立存在问题。检查配置中的 IKE 策略参数和外部接口设置。

如果列出了 SA,请查看以下信息:

  • 索引 - 此值对于每个 IKE SA 都是唯一的,您可以在命令中 show security ike security-associations index detail 使用它来获取有关 SA 的更多信息。

  • 远程地址 — 验证远程 IP 地址是否正确,以及端口 4500 是否用于对等通信。

  • 角色启动器状态

    • Up — 第 1 阶段 SA 已建立。

    • 关闭 — 建立第 1 阶段 SA 时出现问题。

    • IPsec SA 对中的两个对等方都在使用端口 4500,这表示已实施 NAT-T。(NAT-T 使用端口 4500 或其他随机高编号端口。)

    • 对等 IKE ID — 验证远程(响应方)ID 是否正确。在此示例中,主机名为 sunnyvale。

    • 本地身份和远程身份 - 验证它们是否正确。

  • 模式 - 验证是否使用了正确的模式。

验证配置中的以下各项是否正确:

  • 外部接口(接口必须是接收 IKE 数据包的接口)

  • IKE 策略参数

  • 预共享密钥信息

  • 第 1 阶段提议参数(必须在两个对等方上匹配)

show security ike security-associations 命令将列出有关安全关联的其他信息:

  • 使用的身份验证和加密算法

  • 第 1 阶段生存期

  • 流量统计(可用于验证流量是否在两个方向上正常流动)

  • 角色信息

    最好使用响应方角色在对等方上执行故障排除。

  • 发起方和响应方信息

  • 创建的 IPsec SA 数

  • 正在进行的第 2 阶段协商数

验证启动器的 IPsec 安全关联

目的

验证 IPsec 状态。

操作

在操作模式下,输入 show security ipsec security-associations 命令。从命令获取索引号之后,请使用 show security ipsec security-associations index index_number detail 命令。

content_copy zoom_out_map
user@host> show security ipsec security-associations

Total active tunnels: 1     Total Ipsec sas: 1
  ID    Algorithm       SPI      Life:sec/kb  Mon lsys Port  Gateway   
  <2      ESP:3des/md5    aff3ac30 1103/ unlim  -   root 4500  13.168.11.100   
  >2      ESP:3des/md5    40539d12 1103/ unlim  -   root 4500  13.168.11.100   


content_copy zoom_out_map
user@host> show security ipsec security-associations detail

ID: 2 Virtual-system: root, VPN Name: first_vpn
  Local Gateway: 12.168.99.100, Remote Gateway: 13.168.11.100
  Local Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Remote Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Version: IKEv1
  DF-bit: clear, Copy-Outer-DSCP Disabled                             , Policy-name: pol1
  Port: 4500, Nego#: 7, Fail#: 0, Def-Del#: 0 Flag: 0x600829 
  Multi-sa, Configured SAs# 1, Negotiated SAs#: 1 
  Tunnel events: 
    Wed Apr 08 2020 19:13:53: IPSec SA negotiation successfully completed (1 times)
    Wed Apr 08 2020
    : IPSec SA delete payload received from peer, corresponding IPSec SAs cleared (1 times)
    Wed Apr 08 2020 19:13:09: IPSec SA negotiation successfully completed (1 times)
    Wed Apr 08 2020 19:13:09: User cleared IPSec SA from CLI (1 times)
    Wed Apr 08 2020 19:13:09: IKE SA negotiation successfully completed (5 times)
    Wed Apr 08 2020 19:12:18: IPSec SA negotiation successfully completed (1 times)
    Wed Apr 08 2020 19:12:18: User cleared IPSec SA from CLI (1 times)
    Wed Apr 08 2020 19:12:12: IPSec SA negotiation successfully completed (1 times)
    Wed Apr 08 2020 19:12:12: User cleared IPSec SA from CLI (1 times)
    Wed Apr 08 2020 19:06:52: Peer's IKE-ID validation failed during negotiation (2 times)
    Wed Apr 08 2020
    : Negotiation failed  with error code NO_PROPOSAL_CHOSEN received from peer (2 times)
    Wed Apr 08 2020 19:05:26: Peer's IKE-ID validation failed during negotiation (1 times)
    Wed Apr 08 2020
    : Negotiation failed  with error code NO_PROPOSAL_CHOSEN received from peer (1 times)
    Wed Apr 08 2020 19:04:26: Peer's IKE-ID validation failed during negotiation (1 times)
    Wed Apr 08 2020
    : Negotiation failed  with error code NO_PROPOSAL_CHOSEN received from peer (1 times)
    Wed Apr 08 2020 19:03:26: Peer's IKE-ID validation failed during negotiation (1 times)
  Direction: inbound, SPI: aff3ac30, AUX-SPI: 0
                              , VPN Monitoring: -
    Hard lifetime: Expires in 1093 seconds
    Lifesize Remaining:  Unlimited
    Soft lifetime: Expires in 453 seconds
    Mode: Tunnel(0 0), Type: dynamic, State: installed
    Protocol: ESP, Authentication: hmac-md5-96, Encryption: 3des-cbc
    Anti-replay service: counter-based enabled, Replay window size: 64
  Direction: outbound, SPI: 40539d12, AUX-SPI: 0
                              , VPN Monitoring: -
    Hard lifetime: Expires in 1093 seconds
    Lifesize Remaining:  Unlimited
    Soft lifetime: Expires in 453 seconds
    Mode: Tunnel(0 0), Type: dynamic, State: installed
    Protocol: ESP, Authentication: hmac-md5-96, Encryption: 3des-cbc
    Anti-replay service: counter-based enabled, Replay window size: 64
意义

show security ipsec security-associations 命令输出列出以下信息:

  • 远程网关的 NAT 地址为 13.168.11.100。

  • IPsec SA 对中的两个对等方都在使用端口 4500,这表示已实施 NAT-T。(NAT-T 使用端口 4500 或其他随机高编号端口。

  • 两个方向都会显示 SPI、生存期(以秒为单位)和使用限制(或生存大小,以 KB 为单位)。3390/无限值表示第 2 阶段生存期将在 3390 秒后过期,并且未指定生存大小,表示它是无限的。第 2 阶段生存期可能与第 1 阶段生存期不同,因为在 VPN 启动后,第 2 阶段不依赖于第 1 阶段。

  • 如 Mon 列中的连字符所示,没有为此 SA 启用 VPN 监控。如果启用 VPN 监控,U 表示监控已开启,而 D 表示监控已关闭。

  • 虚拟系统 (vsys) 是根系统,始终列出 0。

验证响应方的 IKE 第 1 阶段状态

目的

验证 IKE 第 1 阶段状态。

操作

在操作模式下,输入 show security ike security-associations 命令。从命令获取索引号之后,请使用 show security ike security-associations index index_number detail 命令。

content_copy zoom_out_map
user@host> show security ike security-associations

Index   State  Initiator cookie  Responder cookie  Mode           Remote Address   
2914355 UP     c3193077d38e426f  011f0ef28d928f4c  Aggressive     1.1.100.23      
content_copy zoom_out_map
user@host> show security ike security-associations index 2914355 detail

  IKE peer 1.1.100.23, Index 2914355, Gateway Name: gate
  Role: Responder, State: UP
  Initiator cookie: c3193077d38e426f, Responder cookie: 011f0ef28d928f4c
  Exchange type: Aggressive, Authentication method: Pre-shared-keys
  Local: 13.168.11.100:4500, Remote: 1.1.100.23:23434
  Lifetime: Expires in 26137 seconds
  Reauth Lifetime: Disabled
  IKE Fragmentation: Disabled, Size: 0
  Remote Access Client Info: Unknown Client
  Peer ike-id: chicago
  AAA assigned IP: 0.0.0.0
  Algorithms:
   Authentication        : hmac-md5-96 
   Encryption            : 3des-cbc
   Pseudo random function: hmac-md5
   Diffie-Hellman group  : DH-group-2
  Traffic statistics:
   Input  bytes  :                 1203
   Output bytes  :                 1140
   Input  packets:                    6
   Output packets:                    6
   Input  fragmentated packets:       0
   Output fragmentated packets:       0 
  IPSec security associations: 2 created, 0 deleted
  Phase 2 negotiations in progress: 1

    Negotiation type: Quick mode, Role: Responder, Message ID: 0
    Local: 13.168.11.100:4500, Remote: 1.1.100.23:23434
    Local identity: 13.168.11.100
    Remote identity: chicago
    Flags: IKE SA is created
意义

show security ike security-associations 命令会列出所有活动的 IKE 第 1 阶段 SA。如果未列出任何 SA,则第 1 阶段建立存在问题。检查配置中的 IKE 策略参数和外部接口设置。

如果列出了 SA,请查看以下信息:

  • 索引 - 此值对于每个 IKE SA 都是唯一的,您可以在命令中 show security ike security-associations index detail 使用它来获取有关 SA 的更多信息。

  • 远程地址 — 验证远程 IP 地址是否正确,以及端口 4500 是否用于对等通信。

  • 角色响应程序状态

    • Up — 第 1 阶段 SA 已建立。

    • 关闭 — 建立第 1 阶段 SA 时出现问题。

    • 对等 IKE ID — 验证对等方的本地 ID 是否正确。在此示例中,主机名为芝加哥。

    • 本地身份和远程身份 - 验证它们是否正确。

  • 模式 - 验证是否使用了正确的模式。

验证配置中的以下各项是否正确:

  • 外部接口(接口必须是接收 IKE 数据包的接口)

  • IKE 策略参数

  • 预共享密钥信息

  • 第 1 阶段提议参数(必须在两个对等方上匹配)

show security ike security-associations 命令将列出有关安全关联的其他信息:

  • 使用的身份验证和加密算法

  • 第 1 阶段生存期

  • 流量统计(可用于验证流量是否在两个方向上正常流动)

  • 角色信息

    最好使用响应方角色在对等方上执行故障排除。

  • 发起方和响应方信息

  • 创建的 IPsec SA 数

  • 正在进行的第 2 阶段协商数

验证响应方的 IPsec 安全关联

目的

验证 IPsec 状态。

操作

在操作模式下,输入 show security ipsec security-associations 命令。从命令获取索引号之后,请使用 show security ipsec security-associations index index_number detail 命令。

content_copy zoom_out_map
user@host> show security ipsec security-associations

Total active tunnels: 1     Total Ipsec sas: 1
  ID    Algorithm       SPI      Life:sec/kb  Mon lsys Port  Gateway   
  <67108878 ESP:3des/md5  40539d12 939/ unlim   -   root 23434 1.1.100.23      
  >67108878 ESP:3des/md5  aff3ac30 939/ unlim   -   root 23434 1.1.100.23      
content_copy zoom_out_map
user@host> show security ipsec security-associations detail

  ID: 67108878 Virtual-system: root, VPN Name: first_vpn
  Local Gateway: 13.168.11.100, Remote Gateway: 1.1.100.23
  Local Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Remote Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Version: IKEv1
  DF-bit: clear, Copy-Outer-DSCP Disabled                             , Policy-name: pol1
  Port: 23434, Nego#: 8, Fail#: 0, Def-Del#: 0 Flag: 0x608829 
  Multi-sa, Configured SAs# 1, Negotiated SAs#: 1 
  Tunnel events: 
    Wed Apr 08 2020 19:14:22: IPSec SA negotiation successfully completed (1 times)
    Wed Apr 08 2020 19:14:15: User cleared IPSec SA from CLI (1 times)
    Wed Apr 08 2020 19:13:39: IPSec SA negotiation successfully completed (3 times)
    Wed Apr 08 2020 19:13:39: IKE SA negotiation successfully completed (4 times)
    Wed Apr 08 2020
    : IPSec SA delete payload received from peer, corresponding IPSec SAs cleared (1 times)
    Wed Apr 08 2020 19:10:39: IPSec SA negotiation successfully completed (1 times)
    Wed Apr 08 2020 19:10:20: User cleared IPSec SA from CLI (1 times)
    Wed Apr 08 2020 19:10:08: IPSec SA negotiation successfully completed (1 times)
    Wed Apr 08 2020
    : Tunnel is ready. Waiting for trigger event or peer to trigger negotiation (1 times)
  Direction: inbound, SPI: 40539d12, AUX-SPI: 0
                              , VPN Monitoring: -
    Hard lifetime: Expires in 930 seconds
    Lifesize Remaining:  Unlimited
    Soft lifetime: Expires in 335 seconds
    Mode: Tunnel(0 0), Type: dynamic, State: installed
    Protocol: ESP, Authentication: hmac-md5-96, Encryption: 3des-cbc
    Anti-replay service: counter-based enabled, Replay window size: 64
  Direction: outbound, SPI: aff3ac30, AUX-SPI: 0
                              , VPN Monitoring: -
    Hard lifetime: Expires in 930 seconds
    Lifesize Remaining:  Unlimited
    Soft lifetime: Expires in 335 seconds
    Mode: Tunnel(0 0), Type: dynamic, State: installed
    Protocol: ESP, Authentication: hmac-md5-96, Encryption: 3des-cbc
    Anti-replay service: counter-based enabled, Replay window size: 64
意义

show security ipsec security-associations 命令输出列出以下信息:

  • 远程网关的 NAT 地址为 1.1.100.23。

  • IPsec SA 对中的两个对等方都在使用端口 4500,这表示已实施 NAT-T。(NAT-T 使用端口 4500 或其他随机高编号端口。)

  • 两个方向都会显示 SPI、生存期(以秒为单位)和使用限制(或生存大小,以 KB 为单位)。3571/unlim 值表示第 2 阶段生存期将在 3571 秒后过期,并且未指定生存大小,表示它是无限的。第 2 阶段生存期可能与第 1 阶段生存期不同,因为在 VPN 启动后,第 2 阶段不依赖于第 1 阶段。

  • 如 Mon 列中的连字符所示,没有为此 SA 启用 VPN 监控。如果启用 VPN 监控,U 表示监控已开启,而 D 表示监控已关闭。

  • 虚拟系统 (vsys) 是根系统,始终列出 0。

示例:使用动态端点 VPN 配置 NAT-T

此示例说明如何配置基于路由的 VPN,其中 IKEv2 发起方是 NAT 设备后面的动态端点。

要求

此示例使用以下硬件和软件组件:

  • 机箱群集中配置的两个 SRX 系列防火墙

  • 一个提供 NAT 的 SRX 系列防火墙

  • 一个 SRX 系列防火墙提供分支机构网络访问

  • Junos OS 版本 12.1X46-D10 或更高版本,支持 IKEv2 NAT-T

概述

在此示例中,在分支机构(IKEv2 发起程序)和总部(IKEv2 响应程序)之间配置 IPsec VPN,以保护两个位置之间的网络流量。分支机构位于 NAT 设备后面。分支机构地址是动态分配的,响应方不知道。使用响应方的远程身份配置发起方以进行隧道协商。此配置在 NAT 设备上的对等方之间建立动态端点 VPN。

图 3 显示了具有 NAT 遍历 (NAT-T) 和动态端点 VPN 的拓扑示例。

图 3: 具有动态端点 VPN 的 NAT-T具有动态端点 VPN 的 NAT-T

在此示例中,已动态分配给设备的发起方 IP 地址 192.179.100.50 被 NAT 设备隐藏并转换为 100.10.1.253。

以下示例中应用以下配置选项:

  • 在发起方上配置的本地身份必须与响应方上配置的远程网关身份匹配。

  • 发起方和响应方之间的第 1 阶段和第 2 阶段选项必须匹配。

在此示例中,允许所有流量的默认安全策略用于所有设备。应为生产环境配置更严格的安全策略。请参阅 安全策略概述

从 Junos OS 版本 12.1X46-D10 和 Junos OS 版本 17.3R1 开始,在层次结构级别配置[edit security ike gateway gateway-name]的选项的nat-keepalive默认值已从 5 秒更改为 20 秒。

在 SRX1400、SRX3400、SRX3600、SRX5600 和 SRX5800 设备中 ,如果 IKE 对等方位于将在协商期间更改 IKE 数据包的源 IP 地址的 NAT 设备后面,则涉及 NAT 遍历的 IKE 协商将不起作用。例如,如果 NAT 设备配置了 DIP,则会更改源 IP,因为 IKE 协议会将 UDP 端口从 500 切换到 4500。(平台是否支持取决于设备安装的 Junos OS 版本。)

配置

配置分支机构设备(IKEv2 启动器)

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set interfaces ge-0/0/1 unit 0 family inet address 192.179.100.50/24
set interfaces ge-0/0/2 unit 0 family inet address 192.179.2.20/24
set interfaces st0 unit 0 family inet address 172.168.100.1/16
set routing-options static route 192.179.1.0/24 next-hop st0.0
set security zones security-zone trust host-inbound-traffic system-services all
set security zones security-zone trust host-inbound-traffic protocols all
set security zones security-zone trust interfaces ge-0/0/2.0
set security zones security-zone untrust host-inbound-traffic system-services all
set security zones security-zone untrust host-inbound-traffic protocols all
set security zones security-zone untrust interfaces ge-0/0/1.0
set security zones security-zone untrust interfaces st0.0
set security ike proposal IKE_PROP authentication-method pre-shared-keys
set security ike proposal IKE_PROP dh-group group5
set security ike proposal IKE_PROP authentication-algorithm sha1
set security ike proposal IKE_PROP encryption-algorithm aes-256-cbc
set security ike policy IKE_POL proposals IKE_PROP
set security ike policy IKE_POL pre-shared-key ascii-text "$ABC123"
set security ike gateway HQ_GW ike-policy IKE_POL
set security ike gateway HQ_GW address 100.10.1.50
set security ike gateway HQ_GW local-identity hostname branch.example.net
set security ike gateway HQ_GW external-interface ge-0/0/1.0
set security ike gateway HQ_GW version v2-only
set security ipsec proposal IPSEC_PROP protocol esp
set security ipsec proposal IPSEC_PROP authentication-algorithm hmac-sha1-96
set security ipsec proposal IPSEC_PROP encryption-algorithm aes-256-cbc
set security ipsec policy IPSEC_POL perfect-forward-secrecy keys group5
set security ipsec policy IPSEC_POL proposals IPSEC_PROP
set security ipsec vpn HQ_VPN bind-interface st0.0
set security ipsec vpn HQ_VPN ike gateway HQ_GW
set security ipsec vpn HQ_VPN ike ipsec-policy IPSEC_POL
set security ipsec vpn HQ_VPN establish-tunnels immediately
set security policies default-policy permit-all
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置分支机构设备:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@host# set ge-0/0/1 unit 0 family inet address 192.179.100.50/24
    user@host# set ge-0/0/2 unit 0 family inet address 192.179.2.20/24
    user@host# set st0 unit 0 family inet address 172.168.100.1/16
    
  2. 配置路由选项。

    content_copy zoom_out_map
    [edit routing-options]
    user@host# set static route 192.179.1.0/24 next-hop st0.0
    
  3. 配置区域。

    content_copy zoom_out_map
    [edit security zones security-zones trust]
    user@host# set host-inbound-traffic system-services all
    user@host# set host-inbound-traffic protocols all
    user@host# set interfaces ge-0/0/2.0
    [edit security zones security-zones untrust]
    user@host# set host-inbound-traffic system-services all
    user@host# set host-inbound-traffic protocols all
    user@host# set interfaces ge-0/0/1.0
    user@host#set interfaces st0.0
    
  4. 配置第 1 阶段选项。

    content_copy zoom_out_map
    [edit security ike proposal IKE_PROP]
    user@host# set authentication-method pre-shared-keys
    user@host# set dh-group group5
    user@host# set authentication-algorithm sha1
    user@host# set encryption-algorithm aes-256-cbc
    [edit security ike policy IKE_POL]
    user@host# set proposals IKE_PROP
    user@host# set pre-shared-key ascii-text "$ABC123"
     [edit security ike gateway HQ_GW]
    user@host# set ike-policy IKE_POL
    user@host# set address 100.10.1.50
    user@host# set local-identity hostname branch.example.net
    user@host# set external-interface ge-0/0/1.0
    user@host# set version v2-only
    
  5. 配置第 2 阶段选项。

    content_copy zoom_out_map
    [edit security ipsec proposal IPSEC_PROP]
    user@host# set protocol esp
    user@host# set authentication-algorithm hmac-sha1-96
    user@host# set encryption-algorithm aes-256-cbc
    [edit security ipsec policy IPSEC_POL]
    user@host# set proposals IPSEC_PROP
    user@host# set perfect-forward-secrecy keys group5
    [edit security ipsec vpn HQ_VPN]
    user@host# set bind-interface st0.0
    user@host# set ike gateway HQ_GW
    user@host# set ike ipsec-policy IPSEC_POL
    user@host# set establish-tunnels immediately
    
  6. 配置安全策略。

    content_copy zoom_out_map
    [edit security policies]
    user@host# set default-policy permit-all
    
结果

在配置模式下,输入 show interfacesshow routing-optionsshow security ipsecshow security zonesshow security ike、 和show security policies命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show interfaces
ge-0/0/1 {
    unit 0 {
        family inet {
            address 192.179.100.50/24;
        }
    }
}
ge-0/0/2 {
    unit 0 {
        family inet {
            address 192.179.2.20/24;
        }
    }
}
st0 {
    unit 0 {
        family inet {
            address 172.168.100.1/16;
        }
    }
}
[edit]
user@host# show routing-options
static {
    route 192.179.1.0/24 next-hop st0.0;
}
[edit]
user@host# show security zones
security-zone trust {
    host-inbound-traffic {
        system-services {
            all;
        }
        protocols {
            all;
        }
    }
    interfaces {
        ge-0/0/2.0;
    }
}
security-zone untrust {
    host-inbound-traffic {
        system-services {
            all;
        }
        protocols {
            all;
        }
    }
    interfaces {
        ge-0/0/1.0;
        st0.0;
    }
}
[edit]
user@host# show security ike
proposal IKE_PROP {
    authentication-method pre-shared-keys;
    dh-group group5;
    authentication-algorithm sha1;
    encryption-algorithm aes-256-cbc;
}
policy IKE_POL {
    proposals IKE_PROP;
    pre-shared-key ascii-text "$ABC123”
}
gateway HQ_GW{
    ike-policy IKE_POL;
    address 100.10.1.50;
    local-identity hostname branch.example.net;
    external-interface ge-0/0/1.0;
    version v2-only;
}
[edit]
user@host# show security ipsec
proposal IPSEC_PROP {
    protocol esp;
    authentication-algorithm hmac-sha1-96;
    encryption-algorithm aes-256-cbc;
}
policy IPSEC_POL {
    perfect-forward-secrecy {
        keys group5;
    }
    proposals IPSEC_PROP;
}
vpn HQ_VPN {
    bind-interface st0.0;
    ike {
        gateway HQ_GW;
        ipsec-policy IPSEC_POL;
    }
    establish-tunnels immediately;
}
[edit]
user@host# show security policies
default-policy {
    permit-all;
}

如果完成设备配置,请从配置模式输入 commit

配置 NAT 设备

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set interfaces ge-0/0/1 unit 0 family inet address 100.10.1.253/24
set interfaces fe-0/0/2 unit 0 family inet address 192.179.100.253/24
set security zones security-zone untrust host-inbound-traffic system-services all
set security zones security-zone untrust host-inbound-traffic protocols all
set security zones security-zone untrust interfaces ge-0/0/1.0
set security zones security-zone trust host-inbound-traffic system-services all
set security zones security-zone trust host-inbound-traffic protocols all
set security zones security-zone trust interfaces fe-0/0/2.0
set security nat source rule-set DYNAMIC from zone trust
set security nat source rule-set DYNAMIC to zone untrust
set security nat source rule-set DYNAMIC rule R2R3 match source-address 0.0.0.0/0
set security nat source rule-set DYNAMIC rule R2R3 then source-nat interface
set security policies default-policy permit-all
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置提供 NAT 的中间路由器,请执行以下操作:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@host# set ge-0/0/1 unit 0 family inet address 100.10.1.253/24
    user@host# set fe-0/0/2 unit 0 family inet address 192.179.100.253/24
    
  2. 配置区域。

    content_copy zoom_out_map
    [edit security zones security-zone untrust]
    user@host# set host-inbound-traffic system-services all
    user@host# set host-inbound-traffic protocols all
    user@host# set interfaces ge-0/0/1.0
    [edit security zones security-zone trust]
    user@host# set host-inbound-traffic system-services all
    user@host# set host-inbound-traffic protocols all
    user@host# set interfaces fe-0/0/2.0
    
  3. 配置 NAT。

    content_copy zoom_out_map
    [edit security nat source rule-set DYNAMIC]
    user@host# set from zone trust
    user@host# set to zone untrust
    user@host# set rule R2R3 match source-address 0.0.0.0/0
    user@host# set rule R2R3 then source-nat interface
    
  4. 配置默认安全策略。

    content_copy zoom_out_map
    [edit security policies]
    user@host# set default-policy permit-all
    
结果

在配置模式下,输入 show interfacesshow security zonesshow security nat sourceshow security policies 命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show interfaces
ge-0/0/1 {
    unit 0 {
        family inet {
            address 100.10.1.253/24;
        }
    }
}
fe-0/0/2 {
    unit 0 {
        family inet {
            address 192.179.100.253/24;
        }
    }
}
[edit]
user@host# show security zones
security-zone trust {
    host-inbound-traffic {
        system-services {
            all;
        }
        protocols {
            all;
        }
    }
    interfaces {
        ge-0/0/1.0;
    }
}
security-zone untrust {
    host-inbound-traffic {
        system-services {
            all;
        }
        protocols {
            all;
        }
    }
    interfaces {
        fe-0/0/2.0;
    }
}
[edit]
user@host# show security nat source
rule-set DYNAMIC {
    from zone untrust;
    to zone trust;
    rule R2R3 {
        match {
            source-address 0.0.0.0/0;
        }
        then {
            source-nat {
                interface;
            }
        }
    }
}
[edit]
user@host# show security policies
default-policy {
    permit-all;
}

如果完成设备配置,请从配置模式输入 commit

配置总部设备(IKEv2 响应程序)

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层级的 CLI 中,然后从配置模式进入 commit

content_copy zoom_out_map
set chassis cluster reth-count 5
set chassis cluster redundancy-group 1 node 0 priority 220
set chassis cluster redundancy-group 1 node 1 priority 149 
set chassis cluster redundancy-group 1 interface-monitor ge-0/0/1 weight 255
set chassis cluster redundancy-group 1 interface-monitor ge-8/0/1 weight 255
set chassis cluster redundancy-group 1 interface-monitor ge-0/0/2 weight 255
set chassis cluster redundancy-group 1 interface-monitor ge-8/0/2 weight 255
set interfaces ge-0/0/1 gigether-options redundant-parent reth0  
set interfaces ge-0/0/2 gigether-options redundant-parent reth1
set interfaces ge-8/0/1 gigether-options redundant-parent reth0
set interfaces ge-8/0/2 gigether-options redundant-parent reth1
set interfaces reth0 redundant-ether-options redundancy-group 1
set interfaces reth0 unit 0 family inet address 192.179.1.10/24
set interfaces reth1 redundant-ether-options redundancy-group 1
set interfaces reth1 unit 0 family inet address 100.10.1.50/24
set interfaces st0 unit 0 family inet address 172.168.100.2/16
set routing-options static route 192.179.2.0/24 next-hop st0.0
set routing-options static route 192.179.100.0/24 next-hop 100.10.1.253
set security zones security-zone untrust host-inbound-traffic system-services all 
set security zones security-zone untrust host-inbound-traffic protocols all
set security zones security-zone untrust interfaces st0.0
set security zones security-zone untrust interfaces reth1.0
set security zones security-zone trust host-inbound-traffic system-services all
set security zones security-zone trust host-inbound-traffic protocols all
set security zones security-zone trust interfaces reth0.0
set security ike proposal IKE_PROP authentication-method pre-shared-keys 
set security ike proposal IKE_PROP dh-group group5
set security ike proposal IKE_PROP authentication-algorithm sha1
set security ike proposal IKE_PROP encryption-algorithm aes-256-cbc
set security ike policy IKE_POL proposals IKE_PROP 
set security ike policy IKE_POL pre-shared-key ascii-text "$ABC123" 
set security ike gateway Branch_GW ike-policy IKE_POL 
set security ike gateway Branch_GW dynamic hostname branch.example.net 
set security ike gateway Branch_GW dead-peer-detection optimized 
set security ike gateway Branch_GW external-interface reth1.0
set security ike gateway Branch_GW version v2-only
set security ipsec proposal IPSEC_PROP protocol esp 
set security ipsec proposal IPSEC_PROP authentication-algorithm hmac-sha1-96
set security ipsec proposal IPSEC_PROP encryption-algorithm aes-256-cbc 
set security ipsec policy IPSEC_POL perfect-forward-secrecy keys group5 
set security ipsec policy IPSEC_POL proposals IPSEC_PROP
set security ipsec vpn Branch_VPN bind-interface st0.0 
set security ipsec vpn Branch_VPN ike gateway Branch_GW 
set security ipsec vpn Branch_VPN ike ipsec-policy IPSEC_POL
set security policies default-policy permit-all
分步过程

下面的示例要求您在各个配置层级中进行导航。有关操作说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

  1. 将两个节点配置为机箱群集。

    content_copy zoom_out_map
    [edit chassis cluster]
    user@host# set reth-count 5
    user@host# set redundancy-group 1 node 0 priority 220 
    user@host# set redundancy-group 1 node 1 priority 149 
    user@host# set redundancy-group 1 interface-monitor ge-0/0/1 weight 255
    user@host# set redundancy-group 1 interface-monitor ge-8/0/1 weight 255
    user@host# set redundancy-group 1 interface-monitor ge-0/0/2 weight 255
    user@host# set redundancy-group 1 interface-monitor ge-8/0/2 weight 255
    
  2. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@host# set ge-0/0/1 gigether-options redundant-parent reth0
    user@host# set ge-0/0/2 gigether-options redundant-parent reth1
    user@host# set ge-8/0/1 gigether-options redundant-parent reth0
    user@host# set ge-8/0/2 gigether-options redundant-parent reth1
    user@host# set reth0 redundant-ether-options redundancy-group 1
    user@host# set reth0 unit 0 family inet address 192.179.1.10/24
    user@host# set reth1 redundant-ether-options redundancy-group 1
    user@host# set reth1 unit 0 family inet address 100.10.1.50/24
    user@host# set st0 unit 0 family inet address 172.168.100.2/16
    
  3. 配置路由选项。

    content_copy zoom_out_map
    [edit routing-options]
    user@host# set static route 192.179.2.0/24 next-hop st0.0
    user@host# set static route 192.179.100.0/24 next-hop 100.10.1.253
    
  4. 配置区域。

    content_copy zoom_out_map
    [edit security zones security-zone untrust]
    user@host# set host-inbound-traffic protocols all
    user@host# set host-inbound-traffic system-services all 
    user@host# set interfaces st0.0
    user@host# set interfaces reth1.0
    [edit security zones security-zone trust]
    user@host# set host-inbound-traffic system-services all
    user@host# set host-inbound-traffic protocols all
    user@host# set interfaces reth0.0
    
  5. 配置第 1 阶段选项。

    content_copy zoom_out_map
    [edit security ike proposal IKE_PROP]
    user@host# set authentication-method pre-shared-keys 
    user@host# set dh-group group5
    user@host# set authentication-algorithm sha1
    user@host# set encryption-algorithm aes-256-cbc
    [edit security ike policy IKE_POL]
    user@host# set proposals IKE_PROP 
    user@host# set pre-shared-key ascii-text "$ABC123" 
    [edit security ike gateway Branch_GW]
    user@host# set ike-policy IKE_POL 
    user@host# set dynamic hostname branch.example.net 
    user@host# set dead-peer-detection optimized 
    user@host# set external-interface reth1.0
    user@host# set version v2-only
    
  6. 配置第 2 阶段选项。

    content_copy zoom_out_map
    [edit security ipsec proposal IPSEC_PROP]
    user@host# set protocol esp 
    user@host# set authentication-algorithm hmac-sha1-96
    user@host# set encryption-algorithm aes-256-cbc 
    [edit security ipsec policy IPSEC_POL]
    user@host# set perfect-forward-secrecy keys group5 
    user@host# set proposals IPSEC_PROP
    [edit security ipsec vpn Branch_VPN]
    user@host# set bind-interface st0.0 
    user@host# set ike gateway Branch_GW 
    user@host# set ike ipsec-policy IPSEC_POL
    
  7. 配置默认安全策略。

    content_copy zoom_out_map
    [edit security policies]
    user@host# set default-policy permit-all
    
结果

在配置模式下,输入 show chassis clustershow interfacesshow security ikeshow security ipsecshow routing-optionsshow security zonesshow security policies 命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明,以便进行更正。

content_copy zoom_out_map
[edit]
user@host# show chassis cluster
reth-count 5;
redundancy-group 1 {
    node 0 priority 220;
    node 1 priority 149;
    interface-monitor {
        ge-0/0/1 weight 255;
        ge-8/0/1 weight 255;
        ge-0/0/2 weight 255;
        ge-8/0/2 weight 255;
    }
}
[edit]
user@host# show interfaces
ge-0/0/1 {
    gigether-options {
        redundant-parent reth0;
    }
}
ge-0/0/2 {
    gigether-options {
        redundant-parent reth1;
    }
}
ge-8/0/1 {
    gigether-options {
        redundant-parent reth0;
    }
}
ge-8/0/2 {
    gigether-options {
        redundant-parent reth1;
    }
}
reth0 {
    redundant-ether-options {
        redundancy-group 1;
    }
    unit 0 {
        family inet {
            address 192.179.1.10/24;
        }
    }
}
reth1 {
    redundant-ether-options {
        redundancy-group 1;
    }
    unit 0 {
        family inet {
            address 100.10.1.50/24;
        }
    }
}
st0 {
    unit 0{
        family inet {
            address 172.168.100.2/16;
        }
    }
}
[edit]
user@host# show routing-options
static {
    route 192.179.2.0/24 next-hop st0.0;
    route 192.179.100.0/24 next-hop 100.10.1.253;
}
[edit]
user@host# show security zones
security-zone trust {
    host-inbound-traffic {
        system-services {
            all;
        }
        protocols {
            all;
        }
    }
    interfaces {
        reth0.0;
    }
}
security-zone untrust {
    host-inbound-traffic {
        system-services {
            all;
        }
        protocols {
            all;
        }
    }
    interfaces {
        st0.0;
        reth1.0;
    }
}
[edit]
user@host# show security ike
proposal IKE_PROP {
    authentication-method pre-shared-keys;
    dh-group group5;
    authentication-algorithm sha1;
    encryption-algorithm aes-256-cbc;
}
policy IKE_POL {
    proposals IKE_PROP;
    pre-shared-key ascii-text “$ABC123” 
}
gateway Branch_GW {
    ike-policy IKE_POL;
    
    dynamic hostname branch.example.net;
    dead-peer-detection optimized;
    external-interface reth1.0;
    version v2-only;
}
[edit]
user@host# show security ipsec
proposal IPSEC_PROP {
    protocol esp;
    authentication-algorithm hmac-sha1-96;
    encryption-algorithm aes-256-cbc;
}
policy IPSEC_POL {
    perfect-forward-secrecy {
        keys group5;
    }
    proposals IPSEC_PROP;
}
vpn Branch_VPN {
    bind-interface st0.0;
    ike {
        gateway Branch_GW;
        ipsec-policy IPSEC_POL;
    }
}
[edit]
user@host# show security policies
default-policy {
    permit-all;
}

验证

确认配置工作正常。

验证响应方的 IKE 第 1 阶段状态

目的

验证 IKE 第 1 阶段状态。

操作

在节点 0 上的操作模式下,输入 show security ike security-associations 命令。从命令获取索引号之后,请使用 show security ike security-associations detail 命令。

content_copy zoom_out_map
user@host# show security ike security-associations
node0:
Index      State  Initiator cookie   Responder cookie  Mode    Remote Address   
1367024684 UP     f82c54347e2f3fb1   020e28e1e4cae003  IKEv2    100.10.1.253

content_copy zoom_out_map
user@host# show security ike security-associations detail
node0:
IKE peer 100.10.1.253, Index 1367024684, Gateway Name: Branch_GW
  Location: FPC 5, PIC 0, KMD-Instance 2
  Role: Responder, State: UP
  Initiator cookie: f82c54347e2f3fb1, Responder cookie: 020e28e1e4cae003
  Exchange type: IKEv2, Authentication method: Pre-shared-keys
  Local: 100.10.1.50:4500, Remote: 100.10.1.253:2541
  Lifetime: Expires in 3593 seconds
  Peer ike-id: branch.example.net
  Xauth assigned IP: 0.0.0.0
  Algorithms:
   Authentication        : hmac-sha1-96 
   Encryption            : aes256-cbc
   Pseudo random function: hmac-sha1
   Diffie-Hellman group  : DH-group-5
  Traffic statistics:
   Input  bytes  :                  683
   Output bytes  :                  400
   Input  packets:                    2
   Output packets:                    1
  IPSec security associations: 0 created, 0 deleted
  Phase 2 negotiations in progress: 1
意义

show security ike security-associations 命令会列出所有活动的 IKE 第 1 阶段 SA。如果未列出任何 SA,则第 1 阶段建立存在问题。检查配置中的 IKE 策略参数和外部接口设置。

如果列出了 SA,请查看以下信息:

  • 索引 - 此值对于每个 IKE SA 都是唯一的,您可以在命令中 show security ike security-associations index index_id detail 使用它来获取有关 SA 的更多信息。

  • 远程地址 — 验证本地 IP 地址是否正确,以及端口 4500 是否用于对等通信。

  • 角色响应程序状态

    • Up — 第 1 阶段 SA 已建立。

    • 关闭 — 建立第 1 阶段 SA 时出现问题。

    • 对等 IKE ID — 验证地址是否正确。

    • 本地身份和远程身份 - 验证这些地址是否正确。

  • 模式 - 验证是否使用了正确的模式。

验证配置中的以下各项是否正确:

  • 外部接口(接口必须是发送 IKE 数据包的接口)

  • IKE 策略参数

  • 预共享密钥信息

  • 第 1 阶段提议参数(必须在两个对等方上匹配)

show security ike security-associations 命令将列出有关安全关联的其他信息:

  • 使用的身份验证和加密算法

  • 第 1 阶段生存期

  • 流量统计(可用于验证流量是否在两个方向上正常流动)

  • 角色信息

    最好使用响应方角色在对等方上执行故障排除。

  • 发起方和响应方信息

  • 创建的 IPsec SA 数

  • 正在进行的第 2 阶段协商数

验证响应方的 IPsec 安全关联

目的

验证 IPsec 状态。

操作

在节点 0 上的操作模式下,输入 show security ipsec security-associations 命令。从命令获取索引号之后,请使用 show security ipsec security-associations detail 命令。

content_copy zoom_out_map
user@host# show security ipsec security-associations
node0
  Total active tunnels: 1
  ID        Algorithm            SPI      Life:sec/kb  Mon lsys Port Gateway   
  <77856771 ESP:aes-cbc-256/sha1 4ad5af40 7186/unlim   - root   2541 100.10.1.253    
  >77856771 ESP:aes-cbc-256/sha1 5bb0a5ee 7186/unlim   - root   2541 100.10.1.253
content_copy zoom_out_map
user@host# show security ipsec security-associations detail
node0
  ID: 77856771 Virtual-system: root, VPN Name: Branch_VPN
  Local Gateway: 100.10.1.50, Remote Gateway: 100.10.1.253
  Local Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Remote Identity: ipv4_subnet(any:0,[0..7]=0.0.0.0/0)
  Version: IKEv2
    DF-bit: clear
    Bind-interface: st0.0

  Port: 2541, Nego#: 0, Fail#: 0, Def-Del#: 0 Flag: 608a29 
  Tunnel Down Reason: SA not initiated
    Location: FPC 5, PIC 0, KMD-Instance 2
    Direction: inbound, SPI: 4ad5af40, AUX-SPI: 0
                              , VPN Monitoring: -
    Hard lifetime: Expires in 7182 seconds
    Lifesize Remaining:  Unlimited
    Soft lifetime: Expires in 6587 seconds
    Mode: Tunnel(0 0), Type: dynamic, State: installed
    Protocol: ESP, Authentication: hmac-sha1-96, Encryption: aes-cbc (256 bits)
    Anti-replay service: counter-based enabled, Replay window size: 64
意义

show security ipsec security-associations 命令输出列出以下信息:

  • 远程网关的 IP 地址为 100.10.1.253。

  • 两个方向都会显示 SPI、生存期(以秒为单位)和使用限制(或生存大小,以 KB 为单位)。生存期值指示第 2 阶段生存期将在 7186 秒后过期,并且未指定生存大小,这表示它是无限的。第 2 阶段生存期可能与第 1 阶段生存期不同,因为在 VPN 启动后,第 2 阶段不依赖于第 1 阶段。

  • 虚拟系统 (vsys) 是根系统,始终列出 0。

show security ipsec security-associations index index_id detail 命令输出列出以下信息:

  • 本地身份和远程身份组成 SA 的代理 ID。

    代理 ID 不匹配是第 2 阶段故障的最常见原因之一。如果未列出 IPsec SA,请确认第 2 阶段提议(包括代理 ID 设置)与两个对等方匹配。对于基于路由的 VPN,默认代理 ID 为本地 = 0.0.0.0/0,远程 = 0.0.0.0/0,服务 = any。来自相同对等方 IP 的多个基于路由的 VPN 可能会出现问题。在这种情况下,必须为每个 IPsec SA 指定唯一的代理 ID。对于某些第三方供应商,必须手动输入代理 ID 以进行匹配。

  • 第 2 阶段失败的另一个常见原因是未指定 ST 接口绑定。如果 IPsec 无法完成,请检查 kmd 日志或设置追踪选项。

变更历史表

是否支持某项功能取决于您使用的平台和版本。 使用 Feature Explorer 查看您使用的平台是否支持某项功能。

版本
说明
12.1X46-D10
从 Junos OS 版本 12.1X46-D10 和 Junos OS 版本 17.3R1 开始,在层次结构级别配置[edit security ike gateway gateway-name]的选项的nat-keepalive默认值已从 5 秒更改为 20 秒。
footer-navigation