IPsec 隧道流量配置
IPsec 隧道流量配置概述
流量配置定义了必须流经 IPsec 隧道的流量。您可以配置出站和入站防火墙过滤器,这些过滤器用于识别和引导要加密的流量,并确认解密的流量参数与为给定隧道定义的参数匹配。出站过滤器将应用于要从该 LAN 或 WAN 加密的传入流量的 LAN 或 WAN 接口。入站过滤器将应用于 ES PIC,以检查来自远程主机的流量传入策略。由于配置路由器以转发数据包比较复杂,因此不会进行自动检查以确保配置正确无误。请确保非常仔细地配置路由器。
IPsec 的有效防火墙过滤器语句包括 destination-port、 source-port、 protocol、 destination-address 和 source-address。
在 图 1 中,网关 A 保护网络 10.1.1.0/24,网关 B 保护网络 10.2.2.0/24。网关通过 IPsec 隧道连接。
的 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]结构级别的快速以太网接口。与快速以太网接口上配置的输入过滤器 (ipsec-encrypt-policy-filter) 上的 IPsec作术语 (term 1) 匹配的任何数据包都将被定向至层[edit interfaces es-0/1/0 unit 0 family inet]级的 ES PIC 接口。如果数据包从源地址 10.1.1.0/24 到达并发送到目标地址 10.2.2.0/24,则数据包转发引擎会将数据包定向到配置了 manual-sa1 SA 的 ES PIC 接口。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 term1accept 语句仅适用于此筛选器。与此筛选条件不匹配的流量将被默认防火墙作丢弃。通过在
[edit firewall family inet]层次结构级别发出show配置命令来确认候选防火墙配置[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) 路由器和客户边缘 (CE) 路由器上配置 ES 隧道接口。您还需要在 PE 和 CE 路由器上配置 IPsec。