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]
快速以太网接口上应用。在快速以太网接口上配置的输入过滤器 () 上与 IPsec 操作术语 (term 1
ipsec-encrypt-policy-filter
) 匹配的任何数据包都定向到层级的 ES PIC 接口[edit interfaces es-0/1/0 unit 0 family inet]
。如果数据包从源地址 10.1.1.0/24 到达目标地址 10.2.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
netowrk 捕获流量:
创建防火墙过滤器:
[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
仅适用于此过滤器。默认防火墙操作会丢弃与此过滤器术语不符的流量。在层次结构级别发出配置命令
[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
),以执行最终策略检查。在层次结构级别引用 [edit interfaces es-1/2/0 unit 0 family inet]
IPsec manual-sa1
SA 并解密传入数据包。
[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
),以便执行最终策略检查。术语 1 定义解密(且已验证)流量并执行所需的策略检查。
在 ES PIC 处理完数据包之后,将应用入站信息流过滤器,因此解密的信息流定义为远程网关加密并发送至此路由器的任何信息流。IKE 使用此过滤器确定隧道所需的策略。在与远程网关协商期间,会使用此策略来查找匹配的 SA 配置。
另请参阅
3 层 VPN 的 ES 隧道接口配置
要为第 3 层 VPN 配置 ES 隧道接口,您需要在提供商边缘 (PE) 路由器和客户边缘 (CE) 路由器上配置 ES 隧道接口。您还需要在 PE 和 CE 路由器上配置 IPsec。