基于数据包的转发
SRX 系列防火墙以两种不同的模式运行:数据包模式和流模式。在流模式下,SRX 通过分析流量的状态或会话来处理所有流量。这也称为流量的有状态处理。在数据包模式下,SRX 按数据包处理流量。这也称为流量的无状态处理。
了解基于数据包的处理
进出运行 Junos OS 的瞻博网络设备的数据包可以进行基于数据包的处理。基于数据包或无状态的数据包处理以离散方式处理数据包。每个包都单独评估治疗。基于数据包的无状态转发是逐个数据包执行的,不考虑流或状态信息。每个包都单独评估治疗。
图 1 显示了基于数据包的转发的流量。

当数据包进入设备时,会对其应用分类器、过滤器和监管器。接下来,通过路由查找确定数据包的出口接口。找到数据包的出口接口后,将应用过滤器,并将数据包发送到出口接口,在那里排队并计划传输。
基于数据包的转发不需要有关属于给定连接的先前或后续数据包的任何信息,并且允许或拒绝流量的任何决定都是特定于数据包的。此架构具有大规模扩展的优势,因为它转发数据包而不跟踪单个流量或状态。
从 Junos OS 版本 15.1X49-D100 开始,对于 SRX100、SRX110、SRX210、SRX220、SRX240、SRX300、SRX320、SRX340、SRX345、SRX380、SRX550M 和 SRX650,数据包捕获的最大捕获大小扩展到 1520 字节,允许捕获 1500 字节的数据和 12 字节的瞻博网络以太网报头。”
了解基于数据包的选择性无状态服务
选择性的基于数据包的无状态服务允许您在系统上同时使用基于流和基于数据包的转发。您可以使用无状态防火墙过滤器(也称为访问控制列表 (ACL))有选择地定向需要基于数据包的无状态转发的流量,以避免基于流的有状态转发。不以这种方式定向的流量遵循默认的基于流的转发路径。绕过基于流的转发对于您明确希望避免流会话扩展限制的流量非常有用。
默认情况下,运行 Junos OS 的瞻博网络安全设备使用基于流的转发。选择性的基于数据包的无状态服务允许您将设备配置为仅根据输入过滤器术语为所选流量提供基于数据包的处理。处理其他流量以进行基于流的转发。绕过基于流的转发对于希望避免会话扩展约束以及会话创建和维护成本的部署非常有用。
将设备配置为基于数据包的选择性无状态处理时,进入系统的数据包将根据某些条件得到不同的处理:
如果数据包满足输入过滤器术语中指定的匹配条件,则会将其标记为数据包模式,并对其应用所有已配置的数据包模式功能。不应用基于流的安全功能。它绕过了它们。
如果数据包未被标记为数据包模式,则会对其进行正常处理。除 MPLS 之外的所有服务都可以应用于此流量。
图 2 显示了使用选择性的基于数据包的无状态服务绕过基于流的处理的流量。

当数据包进入接口时,将应用接口上配置的输入数据包过滤器。
如果数据包与 防火墙过滤器中指定的条件匹配,则会为数据包设置操作
packet-mode
修饰符。数据包模式操作修饰符更新数据包密钥缓冲区中的位字段 — 此位字段用于确定是否需要绕过基于流的转发。因此,带有数据包模式操作修饰符的数据包会完全绕过基于流的转发。数据包的出口接口通过路由查找确定。找到数据包的出口接口后,将应用过滤器,并将数据包发送到出口接口,在那里排队并计划传输。如果数据包与此过滤器术语中指定的条件不匹配,则根据过滤器中配置的其他术语对其进行评估。如果在计算完所有项后,数据包与过滤器中的项不匹配,则会以静默方式丢弃该数据包。要防止数据包被丢弃,请在过滤器中配置一个术语,指定接受所有数据包的操作。
一组定义的无状态服务可用于选择性的基于数据包的无状态服务:
IPv4/IPv6 路由(单播和组播协议)
服务等级 (CoS)
链路分段和交错 (LFI)
通用路由封装 (GRE)
第 2 层交换
多协议标签交换 (MPLS)
无状态防火墙过滤器
压缩实时传输协议 (CRTP)
尽管需要在数据包模式下处理需要 MPLS 服务的流量,但在某些情况下,可能需要同时对此流量应用只能在流模式下提供的某些服务,例如状态检查、NAT 和 IPsec。要指示系统以流模式和数据包模式处理流量,您必须配置通过隧道接口连接的多个路由实例。必须将一个路由实例配置为在流模式下处理数据包,将另一个路由实例配置为在数据包模式下处理数据包。当您使用隧道接口连接路由实例时,这些路由实例之间的流量将再次注入转发路径,然后可以使用不同的转发方法对其进行重新处理。
选择性无状态基于数据包的服务配置概述
SRX300、SRX320、SRX340、SRX345、SRX380、SRX550M、SRX1500 和 vSRX 虚拟防火墙设备支持此功能。您可以使用无状态防火墙过滤器(也称为访问控制列表 (ACL))配置选择性的基于数据包的无状态服务。您可以通过在防火墙过滤器中指定匹配条件来对基于数据包的转发的流量进行分类,并配置 packet-mode
操作修饰符来指定操作。定义匹配条件和操作后,防火墙过滤器将应用于相关接口。
要配置防火墙过滤器:
当数据包进入接口时,将应用接口上配置的输入数据包过滤器。如果数据包符合指定条件且 packet-mode
配置了操作,则数据包将完全绕过基于流的转发。
配置过滤器时,请注意防火墙过滤器中术语的顺序。按照数据包在配置中的列出顺序针对每个术语测试数据包。找到第一个匹配条件后,将与该术语关联的操作应用于数据包,并且防火墙过滤器的评估结束,除非 next term
包含操作修饰符。 next term
如果包含该操作,则会根据防火墙过滤器中的下一个术语评估匹配的数据包;否则,不会根据防火墙过滤器中的后续术语评估匹配的数据包。
为选择性的基于数据包的无状态服务配置防火墙过滤器时:
准确识别需要绕过流量的流量,以避免不必要的丢包。
确保在基于数据包的流路径中涉及的所有接口上应用具有数据包模式操作的防火墙过滤器。
确保将主机绑定的 TCP 流量配置为使用基于流的转发 - 为包含操作修饰符的
packet-mode
防火墙过滤器术语指定匹配条件时,请排除此流量。配置为绕过流的任何主机绑定 TCP 流量都将被丢弃。选择性的基于数据包的无状态服务不支持异步流模式处理。使用操作修饰符配置
packet-mode
输入数据包过滤器(而非输出)。
选择性的基于数据包的无状态服务不支持嵌套防火墙过滤器(在另一个过滤器的期限内配置一个过滤器)。
您可以在其中配置选择性的基于数据包的无状态服务的一些典型部署方案如下:
专用 LAN 和 WAN 接口之间的流量,例如用于内联网流量,其中端到端转发是基于数据包的
专用 LAN 和不太安全的 WAN 接口之间的流量,其中流量分别使用基于数据包和基于流的转发来实现安全和不太安全的流量
专用 LAN 和 WAN 接口之间的流量,可在专用 WAN 链路中断时故障转移到基于流的 IPsec WAN。
从基于流的 LAN 到基于数据包的 MPLS WAN 的流量
示例:为端到端基于数据包的转发配置选择性的基于数据包的无状态服务
此示例说明如何为基于数据包的端到端转发配置选择性的基于数据包的无状态服务。SRX300、SRX320、SRX340、SRX345、SRX380、SRX550M、SRX1500 和 vSRX 虚拟防火墙设备支持此功能
要求
准备工作:
了解如何配置无状态防火墙过滤器。
建立基本连接。.
概述
在此示例中,您将为每个设备上的接口配置 IP 地址。对于 R0,它是 10.1.1.2/24 ;对于 R1,它们是 10.1.1.1/24、10.2.1.1/24 和 203.0.113.1/30;对于 R2,它是 203.0.113.2/30;对于 R3,它是 10.2.1.2/24。您可以按如下方式为设备创建静态路由并关联下一跃点地址:R0 为 10.1.1.2,R1 为 198.51.100.2,R2 为 203.0.113.1,R3 为 10.2.1.1。
然后在设备 R1 上配置一个名为不信任的区域,并将其分配给接口 ge-0/0/3。您还可以创建一个名为 trust 的区域,并为其分配接口 ge-0/0/1 和 ge-0/0/2。您可以配置信任和不信任区域,以允许所有受支持的应用程序服务作为入站服务。您允许来自任何源地址、目标地址和应用程序的流量在区域之间传递。
然后,创建防火墙过滤器旁路流过滤器,并定义术语旁路流术语 绕过流术语 1 和旁路流术语 2,它们与内部接口 ge-0/0/1 和 ge-0/0/2 之间的流量匹配,并包含数据包模式操作修饰符。您可以定义术语“接受-休息”以接受所有剩余流量。最后,将防火墙过滤器旁路流过滤器应用于内部接口 ge-0/0/1 和 ge-0/0/2(不在外部接口上)。因此,所有内部流量都会绕过基于流的转发,进出 Internet 的流量也不会绕过基于流的转发。
图 3 显示了此示例中使用的网络拓扑。

贵公司的分支机构通过专用 WAN 相互连接。对于此内部流量,需要数据包转发,因为安全性不是问题。因此,对于此流量,您决定配置选择性的基于数据包的无状态服务,以绕过基于流的转发。进出互联网的其余流量使用基于流的转发。
配置
程序
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI [edit]
中,然后从配置模式进入 commit
。
{device R0} [edit] set interfaces ge-0/0/1 description "Internal 1" unit 0 family inet address 10.1.1.2/24 set routing-options static route 0.0.0.0/0 next-hop 10.1.1.1
{device R1} set interfaces ge-0/0/1 description "Internal 1" unit 0 family inet address 10.1.1.1/24 set interfaces ge-0/0/2 description "Internal 2" unit 0 family inet address 10.2.1.1/24 set interfaces ge-0/0/3 description "Internet" unit 0 family inet address 203.0.113.1/30 set routing-options static route 0.0.0.0/0 next-hop 203.0.113.2 set security zones security-zone untrust interfaces ge-0/0/3 set security zones security-zone trust interfaces ge-0/0/1 set security zones security-zone trust interfaces ge-0/0/2 set security zones security-zone trust host-inbound-traffic system-services all set security zones security-zone untrust host-inbound-traffic system-services all set security policies from-zone trust to-zone untrust policy Internet-traffic match source-address any destination-address any application any set security policies from-zone trust to-zone untrust policy Internet-traffic then permit set security policies from-zone untrust to-zone trust policy Incoming-traffic match source-address any destination-address any application any set security policies from-zone untrust to-zone trust policy Incoming-traffic then permit set security policies from-zone trust to-zone trust policy Intrazone-traffic match source-address any destination-address any application any set security policies from-zone trust to-zone trust policy Intrazone-traffic then permit set firewall family inet filter bypass-flow-filter term bypass-flow-term-1 from source-address 10.1.1.0/24 set firewall family inet filter bypass-flow-filter term bypass-flow-term–1 from destination-address 10.2.1.0/24 set firewall family inet filter bypass-flow-filter term bypass-flow-term-1 then packet-mode set firewall family inet filter bypass-flow-filter term bypass-flow-term-2 from source-address 10.2.1.0/24 set firewall family inet filter bypass-flow-filter term bypass-flow-term-2 from destination-address 10.1.1.0/24 set firewall family inet filter bypass-flow-filter term bypass-flow-term-2 then packet-mode set firewall family inet filter bypass-flow-filter term accept-rest then accept set interfaces ge-0/0/1 description "Internal 1" unit 0 family inet filter input bypass-flow-filer set interfaces ge-0/0/2 description "Internal 2" unit 0 family inet filter input bypass-flow-filer
{device R2} set interfaces ge-0/0/3 description "Internet" unit 0 family inet address 10.1.1.2/30 set routing-options static route 0.0.0.0/0 next-hop 10.1.1.1
{device R3} [edit] set interfaces ge-0/0/2 description "Internal 2" unit 0 family inet address 10.2.1.2/24 set routing-options static route 0.0.0.0/0 next-hop 10.2.1.1
分步过程
以下示例要求您在配置层次结构中导航各个级别。有关如何执行此操作的说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要为基于数据包的端到端转发配置选择性的基于数据包的无状态服务,请执行以下操作:
配置设备 R0、R1、R2 和 R3 上接口的 IP 地址。
{device R0} [edit] user@host#
set interfaces ge-0/0/1 description "Internal 1" unit 0 family inet address 10.1.1.2/24
{device R1} [edit] user@host#
set interfaces ge-0/0/1 description "Internal 1" unit 0 family inet address 10.1.1.1/24
user@host#set interfaces ge-0/0/2 description "Internal 2" unit 0 family inet address 10.2.1.1/24
user@host#set interfaces ge-0/0/3 description "Internet" unit 0 family inet address 203.0.113.1/30
{device R2} [edit] user@host#
set interfaces ge-0/0/3 description "Internet" unit 0 family inet address 203.0.113.1/30
{device R3} [edit] user@host#
set interfaces ge-0/0/2 description "Internal 2" unit 0 family inet address 10.2.1.2/24
创建静态路由并为设备 R0、R1、R2 和 R3 关联相应的下一跃点地址。
{device R0} [edit] user@host#
set routing-options static route 0.0.0.0/0 next-hop 10.1.1.1
{device R1} [edit] user@host#
set routing-options static route 0.0.0.0/0 next-hop 203.0.113.1
{device R2} [edit] user@host#
set routing-options static route 0.0.0.0/0 next-hop 203.0.113.2
{device R3} [edit] user@host#
set routing-options static route 0.0.0.0/0 next-hop 10.2.1.1
配置安全区域并分配接口。
{device R1} [edit] user@host#
set security zones security-zone untrust interfaces ge-0/0/3
user@host#set security zones security-zone trust interfaces ge-0/0/1
user@host#set security zones security-zone trust interfaces ge-0/0/2
为区域配置应用程序服务。
{device R1} [edit] user@host#
set security zones security-zone trust host-inbound-traffic system-services all
user@host#set security zones security-zone untrust host-inbound-traffic system-services all
配置安全策略
{device R1} [edit] user@host#
set security policies from-zone trust to-zone untrust policy Internet-traffic match source-address any destination-address any application any
user@host#set security policies from-zone trust to-zone untrust policy Internet-traffic then permit
user@host#set security policies from-zone untrust to-zone trust policy Incoming-traffic match source-address any destination-address any application any
user@host#set security policies from-zone untrust to-zone trust policy Incoming-traffic then permit
user@host#set security policies from-zone trust to-zone trust policy Intrazone-traffic match source-address any destination-address any application any
user@host#set security policies from-zone trust to-zone trust policy Intrazone-traffic then permit
创建防火墙过滤器并定义所有基于数据包的转发流量的术语。
{device R1} [edit] user@host#
set firewall family inet filter bypass-flow-filter term bypass-flow-term-1 from source-address 10.1.1.0/24
user@host#set firewall family inet filter bypass-flow-filter term bypass-flow-term–1 from destination-address 10.2.1.0/24
user@host#set firewall family inet filter bypass-flow-filter term bypass-flow-term-1 then packet-mode
user@host#set firewall family inet filter bypass-flow-filter term bypass-flow-term-2 from source-address 10.2.1.0/24
user@host#set firewall family inet filter bypass-flow-filter term bypass-flow-term-2 from destination-address 10.1.1.0/24
user@host#set firewall family inet filter bypass-flow-filter term bypass-flow-term-2 then packet-mode
为剩余流量指定另一个术语。
{device R1} [edit] user@host#
set firewall family inet filter bypass-flow-filter term accept-rest then accept
将防火墙过滤器应用于相关接口。
{device R1} [edit] user@host#
set interfaces ge-0/0/1 description "Internal 1" unit 0 family inet filter input bypass-flow-filer
user@host#set interfaces ge-0/0/2 description "Internal 2" unit 0 family inet filter input bypass-flow-filer
结果
在配置模式下,输入 show interfaces
、 show routing-options
和 show firewall
命令确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明以进行更正。
{device R0} [edit] user@host# show interfaces ge-0/0/1 { description “Internal 1” unit 0 { family inet { address 10.1.1.2/24 } } }
{device R0} [edit] user@host# show routing-options static { route 0.0.0.0/0 next-hop 10.1.1.1; }
{device R2} [edit] user@host# show interfaces ge-0/0/3 { description “Internet” unit 0 { family inet { address 203.0.113.2/30; } } }
{device R2} [edit] user@host# show routing-options static { route 0.0.0.0/0 next-hop 203.0.113.1; }
{device R3} [edit] user@host# show interfaces ge-0/0/2 { description “Internal 2” unit 0 { family inet { address 10.2.1.2/24; } } }
{device R3} user@host# show routing-options static { route 0.0.0.0/0 next-hop 10.2.1.1; }
{device R1} [edit] user@host# show interfaces ge-0/0/1 { description “internal 1” unit 0 { family inet { filter { input bypass-flow-filter; } address 10.1.1.1/24; } } } ge-0/0/2 { description “Internal 2” unit 0 { family inet { filter { input bypass-flow-filter; } address 10.2.1.1/24; } } } ge-0/0/3 { description “Internet” unit 0 { family inet { address 203.0.113.1/30; } } } {device R1} [edit] user@host# show routing-options static { route 0.0.0.0/0 next-hop 203.0.113.1; } {device R1} [edit] user@host# show firewall family inet { filter bypass-flow-filter { term bypass-flow-term-1 { from { source-address { 10.1.1.0/24; } destination-address { 10.2.1.0/24; } } then packet-mode; } term bypass-flow-term-2 { from { source-address { 10.2.1.0/24; } destination-address { 10.1.1.0/24; } } then packet-mode; } term accept-rest { then accept; } } }
如果完成设备配置,请从配置模式输入 commit
。
验证
确认配置工作正常。
验证基于数据包的端到端配置
目的
验证是否配置了选择性的基于数据包的无状态服务。
行动
在配置模式下,输入 show interfaces
、 show routing-options
、 show security zones
show security policies
和 show firewall
命令。
验证输出是否显示了防火墙过滤器、接口和策略的预期配置。
验证术语是否按您希望测试数据包的顺序列出。您可以使用命令 insert
在防火墙过滤器内移动术语。
验证内网流量上的会话建立
目的
验证在将流量传输到 Intranet 中的接口时是否已建立会话。
行动
要验证是否已建立会话,请执行以下任务:
在 设备上
R1
,输入操作模式clear security flow session all
命令以清除所有现有的安全流会话。在 设备上
R0
,输入操作模式ping
命令以将流量传输到设备R3
。在 设备上
R1
,流量从设备R0
传输到R3
R1
,输入操作模式show security flow session
命令。Flow Sessions on FPC10 PIC1: Total sessions: 0 Flow Sessions on FPC10 PIC2: Total sessions: 0 Flow Sessions on FPC10 PIC3: Total sessions: 0
要验证已建立的会话,请确保在ping
命令发送和接收数据包时输入show security flow session
命令。
从 Junos OS 15.1X49-D30 版和 Junos OS 17.3R1 版开始,会话流摘要包括 CP 会话 ID。
{device R0} user@host> ping 203.0.113.6
PING 203.0.113.6 (203.0.113.6): 56 data bytes 64 bytes from 203.0.113.6: icmp_seq=0 ttl=63 time=2.326 ms 64 bytes from 203.0.113.6: icmp_seq=1 ttl=63 time=2.569 ms 64 bytes from 203.0.113.6: icmp_seq=2 ttl=63 time=2.565 ms 64 bytes from 203.0.113.6: icmp_seq=3 ttl=63 time=2.563 ms 64 bytes from 203.0.113.6: icmp_seq=4 ttl=63 time=2.306 ms 64 bytes from 203.0.113.6: icmp_seq=5 ttl=63 time=2.560 ms 64 bytes from 203.0.113.6: icmp_seq=6 ttl=63 time=4.130 ms 64 bytes from 203.0.113.6: icmp_seq=7 ttl=63 time=2.316 ms ...
{device R1} user@host> show security flow session
Flow Sessions on FPC10 PIC1: Total sessions: 0 Flow Sessions on FPC10 PIC2: Total sessions: 0 Flow Sessions on FPC10 PIC3: Total sessions: 0
输出显示从 到 R3
传输的R0
流量,但未建立会话。在此示例中,你对接口Internal 1
和Internal 2
公司的 Intranet 流量应用了 bypass-flow-filter
with packet-mode
操作修饰符。此输出验证两个接口之间的流量是否正确绕过了基于流的转发,因此未建立会话。
验证互联网流量上的会话建立
目的
验证在将流量传输到互联网时是否建立了会话。
行动
要验证到 Internet 的流量是否正在使用基于流的转发以及是否已建立会话,请执行以下操作:
在 设备上
R1
,输入操作模式clear security flow session all
命令以清除所有现有的安全流会话。在 设备上
R0
,输入操作模式ping
命令以将流量传输到设备R2
。R1
在 设备上,当流量从R0
到R2
到R1
传输时,输入操作模式show security flow session
命令。
要验证已建立的会话,请确保在ping
命令发送和接收数据包时输入show security flow session
命令。
{device R0} user@host> ping 10.2.1.2 -c 10
PING 10.2.1.2 (10.2.1.2) 56(84) bytes of data. 64 bytes from 10.2.1.2: icmp_seq=1 ttl=63 time=6.07 ms 64 bytes from 10.2.1.2: icmp_seq=2 ttl=63 time=4.24 ms 64 bytes from 10.2.1.2: icmp_seq=3 ttl=63 time=2.85 ms 64 bytes from 10.2.1.2: icmp_seq=4 ttl=63 time=6.14 ms ...
{device R1} user@host>show security flow session
Flow Sessions on FPC10 PIC1: Session ID: 410000077, Policy name: Internet-traffic/5, Timeout: 2, Valid In: 10.1.1.2/3 --> 10.2.1.2/32055;icmp, If: ge-0/0/1.0, Pkts: 1, Bytes: 84, CP Session ID: 410000198 Out: 10.2.1.2/32055 --> 10.1.1.2/3;icmp, If: ge-0/0/2.0, Pkts: 1, Bytes: 84, CP Session ID: 410000198 Total sessions: 1 Flow Sessions on FPC10 PIC2: Session ID: 420000079, Policy name: Internet-traffic/5, Timeout: 2, Valid In: 10.1.1.2/5 --> 10.2.1.2/32055;icmp, If: ge-0/0/1.0, Pkts: 1, Bytes: 84, CP Session ID: 420000163 Out: 10.2.1.2/32055 --> 10.1.1.2/5;icmp, If: ge-0/0/2.0, Pkts: 1, Bytes: 84, CP Session ID: 420000163 Total sessions: 1 Flow Sessions on FPC10 PIC3: Session ID: 430000090, Policy name: Internet-traffic/5, Timeout: 4, Valid In:10.1.1.2/7 --> 10.2.1.2/32055;icmp, If: ge-0/0/1.0, Pkts: 1, Bytes: 84, CP Session ID: 430000088 Out: 10.2.1.2/32055 --> 10.1.1.2/7;icmp, If: ge-0/0/2.0, Pkts: 1, Bytes: 84, CP Session ID: 430000088 Total sessions: 1
输出显示从设备R0
传输到R1
和已建立会话的流量。在此示例中,您没有对公司的 Internet 流量在接口Internet
上应用 bypass-flow-filter
with 操作packet-mode
修饰符。此输出验证到 Internet 的流量是否正确使用了基于流的转发,从而建立了会话。
将流量从设备R3
R2
传输到,并使用本节中的命令验证已建立的会话。
示例:为基于数据包到基于流的转发配置选择性的基于数据包的无状态服务
此示例说明如何为基于数据包到基于流的转发配置选择性的基于数据包的无状态服务。SRX300、SRX320、SRX340、SRX345、SRX380、SRX550M、SRX1500 和 vSRX 虚拟防火墙设备支持此功能。
要求
准备工作:
了解如何配置无状态防火墙过滤器。
建立基本连接。.
概述
在此示例中,您将为每个设备上的接口配置 IP 地址。对于设备 R0 为 198.51.100.9/24;对于 R1,分别为 198.51.100.10/24 和 203.0.113.5/24;对于 R2,它是 203.0.113.9/24。在设备 R1 上,您可以在路由实例之间设置内部服务接口 lt-0/0/0,并在两个虚拟设备之间配置对等关系。然后,创建两个安全区域(主 VR 区域和互联网 VR 区域),为其分配相关接口,并将它们配置为允许所有受支持的应用程序和协议。
然后,配置策略并指定允许所有数据包。您可以配置虚拟设备路由实例 Internet-VR,并为基于流的转发分配接口。您可以在设备 R0、R1 和 R2 上启用 OSPF。在设备 R2 上,您可以使用包含数据包模式操作修饰符的术语旁路流术语配置过滤器旁路流过滤器。由于您未指定任何匹配条件,因此此过滤器将应用于遍历应用该过滤器的接口的所有流量。
最后,在设备 R1 上,将防火墙过滤器旁路流过滤器应用于内部接口 ge-0/0/2.0 和 lt-0/0/0.0。您不要将过滤器应用于与 Internet-VR 路由实例关联的接口。因此,通过与主路由实例关联的 LAN 接口的所有流量都使用基于数据包的转发,而遍历 Internet-VR 路由实例的所有流量都使用基于流的转发。
图 4 显示了此示例中使用的网络拓扑。

面向专用 LAN 的接口不需要任何安全服务,但面向 WAN 的接口需要安全性。在此示例中,您决定通过配置两个路由实例(一个处理基于数据包的转发,另一个处理基于流的转发)来配置基于数据包和基于流的转发,以实现安全和不太安全的流量。
配置
程序
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI [edit]
中,然后从配置模式进入 commit
。
{device R0} set interfaces description “Connect to Primary VR” ge-0/0/2 unit 0 family inet address 198.51.100.9/24 set protocols ospf area 0.0.0.0 interface ge-0/0/2.0
{device R1} set interfaces description “Connect to R0” ge-0/0/2 unit 0 family inet address 198.51.100.10/24 set interfaces description “Connect to R2” ge-0/0/3 unit 0 family inet address 203.0.113.5/24 set interfaces lt-0/0/0 unit 0 encapsulation frame-relay dlci 100 peer-unit 1 family inet address 192.0.2.1/16 set interfaces lt-0/0/0 unit 1 encapsulation frame-relay dlci 100 peer-unit 0 family inet address 192.0.2.2/16 set security zones security-zone Primary-VR-zone host-inbound-traffic system-services all set security zones security-zone Primary-VR-zone host-inbound-traffic protocols all set security zones security-zone Primary-VR-zone interfaces ge-0/0/2.0 set security zones security-zone Primary-VR-zone interfaces lt-0/0/0.0 set security zones security-zone Internet-VR-zone host-inbound-traffic system-services all set security zones security-zone Internet-VR-zone host-inbound-traffic protocols all set security zones security-zone Internet-VR-zone interfaces ge-0/0/3.0 set security zones security-zone Internet-VR-zone interfaces lt-0/0/0.1 set security policies default-policy permit-all set routing-instances Internet-VR instance-type virtual-router interface lt-0/0/0.1 set routing-instances Internet-VR instance-type virtual-router interface ge-0/0/3.0 set protocols ospf area 0.0.0.0 interface ge-0/0/2.0 set protocols ospf area 0.0.0.0 interface lt-0/0/0.0 set routing-instances Internet-VR protocols ospf area 0.0.0.0 interface lt-0/0/0.1 set routing-instances Internet-VR protocols ospf area 0.0.0.0 interface ge-0/0/3.0 set firewall family inet filter bypass-flow-filter term bypass-flow-term then accept set firewall family inet filter bypass-flow-filter term bypass-flow-term then packet-mode set interfaces ge-0/0/2 unit 0 family inet filter input bypass-flow-filter set interfaces lt-0/0/0 unit 0 family inet filter input bypass-flow-filter
{device R2} set interfaces description “Connect to Internet-VR” ge-0/0/3 unit 0 family inet address 203.0.113.9/24 set protocols ospf area 0.0.0.0 interface ge-0/0/3
分步过程
以下示例要求您在配置层次结构中导航各个级别。有关如何执行此操作的说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要为基于数据包的端到端转发配置选择性的基于数据包的无状态服务,请执行以下操作:
配置接口的 IP 地址。
{device R0} [edit] user@host#
set interfaces description “Connect to Primary VR” ge-0/0/2 unit 0 family inet address 198.51.100.9/24
{device R1} [edit] user@host#
set interfaces description “Connect to R0” ge-0/0/2 unit 0 family inet address 198.51.100.10/24
user@host#set interfaces description “Connect to R2” ge-0/0/3 unit 0 family inet address 203.0.113.5/24
{device R2} [edit] user@host#
set interfaces description “Connect to Internet-VR” ge-0/0/3 unit 0 family inet address 203.0.113.9/24
在路由实例之间设置内部服务接口。
{device R1} [edit] user@host#
set interfaces lt-0/0/0 unit 0 encapsulation frame-relay dlci 100 peer-unit 1 family inet address 192.0.2.1/16
user@host#set interfaces lt-0/0/0 unit 1 encapsulation frame-relay dlci 100 peer-unit 0 family inet address 192.0.2.2/16
配置安全区域。
{device R1} [edit] user@host#
set security zones security-zone Primary-VR-zone host-inbound-traffic system-services all
user@host#set security zones security-zone Primary-VR-zone host-inbound-traffic protocols all
user@host#set security zones security-zone Primary-VR-zone interfaces ge-0/0/2.0
user@host#set security zones security-zone Primary-VR-zone interfaces lt-0/0/0.0
user@host#set security zones security-zone Internet-VR-zone host-inbound-traffic system-services all
user@host#set security zones security-zone Internet-VR-zone host-inbound-traffic protocols all
user@host#set security zones security-zone Internet-VR-zone interfaces ge-0/0/3.0
user@host#set security zones security-zone Internet-VR-zone interfaces lt-0/0/0.1
配置策略。
{device R1} [edit] user@host#
set security policies default-policy permit-all
配置虚拟设备路由实例。
{device R1} [edit] user@host#
set routing-instances Internet-VR instance-type virtual-router interface lt-0/0/0.1
user@host#set routing-instances Internet-VR instance-type virtual-router interface ge-0/0/3.0
在网络中的所有接口上启用 OSPF。
{device R0} [edit] user@host#
set protocols ospf area 0.0.0.0 interface ge-0/0/2.0
{device R1 for Primary-VR} [edit] user@host#
set protocols ospf area 0.0.0.0 interface ge-0/0/2.0
user@host#set protocols ospf area 0.0.0.0 interface lt-0/0/0.0
{device R1 for Internet-VR} [edit] user@host#
set routing-instances Internet-VR protocols ospf area 0.0.0.0 interface lt-0/0/0.1
user@host#set routing-instances Internet-VR protocols ospf area 0.0.0.0 interface ge-0/0/3.0
{device R2} [edit] user@host#
set protocols ospf area 0.0.0.0 interface ge-0/0/3
创建防火墙过滤器并为基于数据包的转发流量定义术语。
{device R1} [edit] user@host#
set firewall family inet filter bypass-flow-filter term bypass-flow-term then accept
user@host#set firewall family inet filter bypass-flow-filter term bypass-flow-term then packet-mode
将防火墙过滤器应用于相关接口。
{device R1} [edit] user@host#
set interfaces ge-0/0/2 unit 0 family inet filter input bypass-flow-filter
user@host#set interfaces lt-0/0/0 unit 0 family inet filter input bypass-flow-filter
结果
在配置模式下,输入 show interfaces
、 show protocols
、 show routing-instances
show security
和show firewall
命令来确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明以进行更正。
{device R0} [edit] user@host# show interfaces ge-0/0/2 { description “Connect to Primary-VR” unit 0 { family inet { address 198.51.100.9/24 } } }
{device R0} [edit] user@host# show protocols ospf { area 0.0.0.0/0 { interface ge-0/0/2.0; } }
{device R2} [edit] user@host# show interfaces ge-0/0/3 { description “Connect to Internet-VR” unit 0 { family inet { address 203.0.113.9/24; } } }
{device R2} [edit] user@host# show protocols ospf { area 0.0.0.0/0 { interface ge-0/0/3.0; } }
{device R1} [edit] user@host# show interfaces ge-0/0/2 { description “Connect to R0” unit 0 { family inet { filter { input bypass-flow-filter; } address 198.51.100.10/24; } } } lt-0/0/0 { unit 0 { encapsulation frame-relay; dlci 100; peer-unit 1; family inet { filter { input bypass-flow-filter } address 192.0.2.1/16; } } unit 1{ encapsulation frame-relay; dlci 100; peer-unit 0; family inet { address 192.0.2.2/16 ; } } } {device R1} [edit] user@host# show protocols ospf { area 0.0.0.0/0 { interface ge-0/0/2.0; interface lt-0/0/0.0; } } {device R1} [edit] user@host# show firewall filter bypass-flow-filter { term bypass-flow-term { then { packet-mode; accept; } } }
{device R1} [edit] user@host# show routing-instances Internet-VR { instance-type virtual-router; interface lt-0/0/0.1; interface ge-0/0/3.0; protocols { ospf { area 0.0.0.0 { interface ge-0/0/3.0; lt-0/0/0.1; } } } }
{device R1} [edit] user@host# show security security zone Primary-VR-zone { host-inbound-traffic { system-services { all; { protocols { all; { { intefaces { ge-0/0/2.0; lt-0/0/0.0; { { security zone Internet-VR-zone { host-inbound-traffic { system-services { all; { protocols { all; } } intefaces { ge-0/0/3.0; lt-0/0/0.1; { { policies { default-policy { permit-all; } }
如果完成设备配置,请从配置模式输入 commit
。
验证
确认配置工作正常。
验证基于数据包到基于流的配置
目的
验证是否为基于数据包到基于流的转发配置了选择性的基于数据包的无状态服务。
行动
在配置模式下,输入 show interfaces
、 show protocols
、 show security
show routing-instances
和 show firewall
命令。
验证输出是否显示了防火墙过滤器、路由实例、接口和策略的预期配置。
验证术语是否按您希望测试数据包的顺序列出。您可以使用命令 insert
在防火墙过滤器内移动术语。
验证 LAN 流量上的会话建立
目的
验证在 LAN 内的接口上传输流量时是否已建立会话。
行动
要验证是否已建立会话,请执行以下任务:
在 设备
R1
上,从操作模式输入命令以clear security flow session all
清除所有现有安全流会话。在 设备上
R0
,从操作模式输入命令以ping
将流量传输到设备Primary-VR
。在 设备上
R1
,对于从设备R0
R1
到 传输的流量,从操作模式输入show security flow session
命令。
要验证已建立的会话,请确保在命令发送和接收数据包时ping
输入show security flow session
命令。
{device R0} user@host> ping 192.0.2.1
PING 192.0.2.1 (192.0.2.1): 56 data bytes 64 bytes from 192.0.2.1: icmp_seq=0 ttl=63 time=2.208 ms 64 bytes from 192.0.2.1: icmp_seq=1 ttl=63 time=2.568 ms 64 bytes from 192.0.2.1: icmp_seq=2 ttl=63 time=2.573 ms 64 bytes from 192.0.2.1: icmp_seq=3 ttl=63 time=2.310 ms 64 bytes from 192.0.2.1: icmp_seq=4 ttl=63 time=1.566 ms 64 bytes from 192.0.2.1: icmp_seq=5 ttl=63 time=1.569 ms ...
{device R1} user@host> show security flow session
0 sessions displayed
输出显示从 到 Primary-VR
传输的R0
流量,但未建立会话。在此示例中,您对接口ge-0/0/0
和lt-0/0/0.0
公司的 LAN 流量应用了 bypass-flow-filter
with packet-mode
操作修饰符。此输出验证两个接口之间的流量是否正确绕过了基于流的转发,因此未建立会话。
验证互联网流量上的会话建立
目的
验证在将流量传输到互联网时是否建立了会话。
行动
要验证到 Internet 的流量是否正在使用基于流的转发以及是否已建立会话,请执行以下操作:
在 设备
R1
上,从操作模式输入命令以clear security flow session all
清除所有现有安全流会话。在 设备上
R0
,从操作模式输入命令以ping
将流量传输到设备R2
。在 设备上
R1
,流量从R0
到R2
到R1
,从操作模式输入show security flow session
命令。root@host> show security flow session Flow Sessions on FPC10 PIC1: Total sessions: 0 Flow Sessions on FPC10 PIC2: Total sessions: 0 Flow Sessions on FPC10 PIC3: Total sessions: 0
要验证已建立的会话,请确保在命令发送和接收数据包时ping
输入show security flow session
命令。
{device R0} user@host> ping 192.0.2.1 -c 10
PING 60.0.0.1 (60.0.0.1) 56(84) bytes of data. 64 bytes from 192.0.2.1: icmp_seq=1 ttl=64 time=1.98 ms 64 bytes from 192.0.2.1: icmp_seq=2 ttl=64 time=1.94 ms 64 bytes from 192.0.2.1: icmp_seq=3 ttl=64 time=1.92 ms 64 bytes from 192.0.2.1: icmp_seq=4 ttl=64 time=1.89 ms ...
{device R1} user@host> show security flow session
Session ID: 189900, Policy name: default-policy/2, Timeout: 2 In: 198.51.100.9/0 --> 192.0.2.1/5924;icmp, If: lt-0/0/0.1 Out: 192.0.2.1/5924 --> 198.51.100.9/0;icmp, If: ge-0/0/3.0 Session ID: 189901, Policy name: default-policy/2, Timeout: 2 In: 198.51.100.9/1 --> 192.0.2.1/5924;icmp, If: lt-0/0/0.1 Out: 192.0.2.1/5924 --> 198.51.100.9/1;icmp, If: ge-0/0/3.0 Session ID: 189902, Policy name: default-policy/2, Timeout: 4 In: 198.51.100.9/2 --> 192.0.2.1/5924;icmp, If: lt-0/0/0.1 Out: 192.0.2.1/5924 --> 198.51.100.9/2;icmp, If: ge-0/0/3.0 3 sessions displayed
输出显示从设备R0
传输到R2
和已建立会话的流量。在此示例中,您没有在路由实例Internet-VR
上对公司的 Internet 流量应用 bypass-flow-filter
with packet-mode
操作修饰符。此输出验证到 Internet 的流量是否正确使用了基于流的转发,从而建立了会话。
请注意,仅当流量在 和 ge-0/0/3
之间lt-0/0/0.1
流动时才会建立会话,而不是在 和 lt-0/0/0.0
之间ge-0/0/2
流动时建立会话。
更改历史记录表
功能支持由您使用的平台和版本决定。使用 功能资源管理器 确定您的平台是否支持某个功能。