IPsec 隧道流量配置
IPsec 隧道流量配置概述
流量配置定义必须流经 IPsec 隧道的流量。您可以配置出站和入站防火墙过滤器,用于识别和定向要加密的流量,并确认解密的流量参数与为给定隧道定义的流量参数匹配。出站过滤器将应用于要加密的 LAN 或 WAN 之外的传入流量的 LAN 或 WAN 接口。入站过滤器将应用于 ES PIC,以检查策略中是否有来自远程主机的流量。由于配置路由器以转发数据包的复杂性,因此不会执行自动检查以确保配置正确。确保非常仔细地配置路由器。
IPsec 的有效防火墙过滤器语句包括 目标端口、 源端口、 协议、 目标地址和 源地址。
在图 1 中,网关 A 保护网络 10.1.1.0/24,网关 B 保护网络 10.2.2.0/24。网关通过 IPsec 隧道连接。

网关 A 的 SA 和 ES 接口配置如下:
[edit security ipsec] security-association manual-sa1 { manual { direction bidirectional { protocol esp; spi 2312; authentication { algorithm hmac-md5-96; key ascii-text 1234123412341234; } encryption { algorithm 3des-cbc; key ascii-text 123456789009876543211234; } } } } [edit interfaces es-0/1/0] unit 0 { tunnel { source 10.5.5.5; destination 10.6.6.6; } family inet { ipsec-sa manual-sa1; address 10.1.1.8/32 { destination 10.1.1.9; } } }
网关 B 的 SA 和 ES 接口配置如下:
[edit security ipsec] security-association manual-sa1 { manual { direction bidirectional { protocol esp; spi 2312; authentication { algorithm hmac-md5-96; key ascii-text 1234123412341234; } encryption { algorithm 3des-cbc; key ascii-text 123456789009876543211234; } } } } [edit interfaces es-0/1/0] unit 0 { tunnel { source 10.6.6.6; destination 10.5.5.5; } family inet { ipsec-sa manual-sa1; address 10.1.1.9/32; { destination 10.1.1.8; } } }
参见
示例:配置出站流量过滤器
出站流量的防火墙过滤器将流量引导通过所需的 IPsec 隧道,并确保隧道流量流出相应的接口(请参阅 IPsec 隧道流量配置概述)。此处,将在安全网关 A 上创建出站防火墙过滤器;它标识要加密的流量,并将其添加到承载内部 VPN 流量的接口的输入端:
[edit firewall] filter ipsec-encrypt-policy-filter { term term1 { from { source-address { # local network 10.1.1.0/24; } destination-address { # remote network 10.2.2.0/24; } } then ipsec-sa manual-sa1; # apply SA name to packet term default { then accept; }
出站流量过滤器上的源地址、端口和协议必须与入站流量过滤器上的目标地址、端口和协议匹配。出站流量过滤器上的目标地址、端口和协议必须与入站流量过滤器上的源地址、端口和协议匹配。
参见
示例:应用出站流量过滤器
配置出站防火墙过滤器后,请应用它:
[edit interfaces] fe-0/0/1 { unit 0 { family inet { filter { input ipsec-encrypt-policy-filter; } address 10.1.1.254/24; } } }
出站过滤器应用于层次结构级别的快速以太网接口[edit interfaces fe-0/0/1 unit 0 family inet]
。在快速以太网接口上配置的输入过滤器 () 上与 IPsecipsec-encrypt-policy-filter
操作项 (term 1
) 匹配的任何数据包都将定向到层次结构级别的 ES PIC 接口[edit interfaces es-0/1/0 unit 0 family inet]
。如果数据包从源地址 10.1.1.0/24 到达并转到目标地址 10.2.2.0/24,数据包转发引擎会将数据包定向到 ES manual-sa1
PIC 接口,该接口配置了 SA。ES PIC 接收数据包,应用 manual-sa1
SA,然后通过隧道发送数据包。
路由器必须具有到隧道端点的路由;如有必要,添加静态路由。
参见
示例:为策略检查配置入站流量过滤器
要求
配置此示例之前,不需要除设备初始化之外的特殊配置。
概述
此处,将在安全网关 A 上创建一个入站防火墙过滤器,用于执行最终 IPsec 策略检查。此检查可确保仅接受与为此隧道配置的流量匹配的数据包。此过滤器通过层次结构级别的 CLI 接口 [edit firewall family inet]
进行配置。
配置
以下示例要求您在配置层次结构中导航各个级别。有关导航 CLI 的信息,请参阅 在配置模式下使用 CLI 编辑器。
要配置此示例,请执行以下操作:
CLI 快速配置
要快速配置此示例,请将以下配置命令复制到文本文件中,删除所有换行符,然后将命令粘贴到层次结构级别的 CLI [edit]
中。
[edit] set firewall family inet filter ipsec-decrypt-policy-filter term term1 from source-address 10.2.2.0/24 set firewall family inet filter ipsec-decrypt-policy-filter term term1 from destination-address 10.1.1.0/24 set firewall family inet filter ipsec-decrypt-policy-filter term term1 then accept commit
配置防火墙过滤器
分步过程
要配置防火墙过滤器,ipsec-decrypt-policy-filter
以捕获来自发往本地10.1.1.0/24
网络的远程10.2.2.0/24
网络的流量,请执行以下操作:
创建防火墙过滤器:
[edit] user@host# edit firewall family inet filter ipsec-decrypt-policy-filter
配置源地址和目标地址的匹配:
[edit firewall family inet filter ipsec-decrypt-policy-filter] user@host# set term term1 from source-address 10.2.2.0/24 user@host# set term term1 from destination-address 10.1.1.0/24
配置过滤器以接受匹配的流量:
[edit firewall family inet filter ipsec-decrypt-policy-filter] user@host# set term term1 then accept
注意:中的
term term1
accept 语句仅适用于此筛选器。与此过滤器术语不匹配的流量将被默认防火墙操作丢弃。通过在层次结构级别发出
show
配置命令[edit firewall family inet]
来确认候选防火墙配置[edit firewall family inet] user@host# show filter ipsec-decrypt-policy-filter { term term1 { # perform policy check from { source-address { # remote network 10.2.2.0/24; } destination-address { # local network 10.1.1.0/24; } } then accept; } }
如果命令输出未显示预期的配置,请重复此示例中的说明以更正配置。
如果完成设备配置,请提交候选配置。
[edit] user@host# commit
要实现此过滤器,请将其作为输入过滤器
es-0/1/0
应用于网关 A 的逻辑接口。有关详细信息,请参阅 示例:将入站流量过滤器应用于 ES PIC 以进行策略检查 。
示例:将入站流量过滤器应用于 ES PIC 以进行策略检查
创建入站防火墙过滤器后,将其应用于 ES PIC。在这里,入站防火墙过滤器 (ipsec-decrypt-policy-filter
) 应用于解密数据包以执行最终策略检查。IPsec manual-sa1
SA 在层次结构级别引用 [edit interfaces es-1/2/0 unit 0 family inet]
并解密传入数据包。
[edit interfaces] es-1/2/0 { unit 0 { tunnel { source 10.5.5.5; # tunnel source address destination 10.6.6.6; # tunnel destination address } family inet { filter { input ipsec-decrypt-policy-filter; } ipsec-sa manual-sa1; # SA name applied to packet address 10.1.1.8/32 { # local interface address inside local VPN destination 10.2.2.254; # destination address inside remote VPN } } }
数据包转发引擎将 IPsec 数据包定向到 ES PIC。它使用数据包的 SPI、协议和目标地址来查找在其中一个 ES 接口上配置的 SA。IPsec manual-sa1
SA 在层次结构级别引用 [edit interfaces es-1/2/0 unit 0 family inet]
,用于解密传入数据包。处理数据包(解密和/或身份验证)时,将对解密数据包应用输入防火墙过滤器 (ipsec-decrypt-policy-filter
) 以执行最终策略检查。Term1 定义解密(和验证)的流量并执行所需的策略检查。
入站流量过滤器在 ES PIC 处理数据包后应用,因此解密流量定义为远程网关加密并发送到此路由器的任何流量。IKE 使用此过滤器来确定隧道所需的策略。在与远程网关协商期间使用此策略来查找匹配的 SA 配置。
参见
第 3 层 VPN 的 ES 隧道接口配置
要为第 3 层 VPN 配置 ES 隧道接口,您需要在提供商边缘 (PE) 路由器和客户边缘 (客户边缘) 路由器上配置 ES 隧道接口。您还需要在 PE 和 客户边缘 路由器上配置 IPsec。