了解 MPLS 流量的基于 IP 的过滤和选择性端口镜像
在 MPLS 数据包中,IP 报头紧跟在 MPLS 报头之后。基于 IP 的过滤功能提供了一种深度检测机制,其中最多可以检测内部有效负载的 8 个 MPLS 标签,以启用基于 IP 参数的 MPLS 流量过滤。过滤后的 MPLS 流量还可以通过端口镜像到监控设备,以便在核心 MPLS 网络中提供基于网络的服务。
基于 IP 的 MPLS 流量过滤
在 Junos OS 18.4R1 版之前,MPLS 系列过滤器不支持基于 IP 参数进行过滤。引入基于 IP 的过滤功能后,您可以根据源地址和目标地址、第 4 层协议类型以及源和目标端口等 IP 参数,对带有 MPLS 标记的 IPv4 和 IPv6 数据包应用入站和出站过滤器。
基于 IP 的过滤功能使您能够在接口入口处过滤 MPLS 数据包,其中过滤是使用 MPLS 数据包内部有效负载上的匹配条件完成的。然后,可以使用逻辑隧道将选择性 MPLS 流量端口镜像到远程监控设备。
为了支持基于 IP 的过滤,添加了额外的匹配条件,允许对 MPLS 数据包进行深度检测,以便在应用适当的过滤器之前,使用第 3 层和第 4 层标头解析内部有效负载。
仅 MPLS 标记的 IPv4 和 IPv6 数据包支持基于 IP 的过滤功能。换句话说,仅当 IP 有效负载紧跟在 MPLS 标签之后时,MPLS 过滤器才会匹配 IP 参数。
在其他情况下,如果 MPLS 有效负载包括伪线、inet 和 inet6 以外的协议或其他封装(如第 2 层 VPN 或 VPLS),则不支持基于 IP 的过滤功能。
为基于 IP 的 MPLS 流量过滤添加了以下匹配条件:
IPv4 源地址
IPv4 目标地址
IPv6 源地址
IPv6 目标地址
协议
源端口
目标端口
源 IPv4 前缀列表
目标 IPv4 前缀列表
源 IPv6 前缀列表
目标 IPv6 前缀列表
基于 IP 的 MPLS 流量过滤支持以下匹配组合:
源地址和目标地址与 IPv4 和 IPv6 前缀列表匹配条件。
源和目标端口地址和协议类型与 IPv4 和 IPv6 前缀列表的条件匹配。
MPLS 流量的选择性端口镜像
端口镜像是除了对数据包进行正常处理和转发之外,还可以将数据包镜像到配置的目标的功能。端口镜像作为防火墙过滤器的操作应用,防火墙过滤器应用于任何接口的入口或出口。同样,选择性端口镜像功能提供了使用逻辑隧道将基于 IP 参数过滤的 MPLS 流量镜像到镜像目标的功能。
要启用选择性端口镜像,除了现有的 counter、 accept和discard操作之外,还要在[edit firewall family mpls filter filter-nameterm term-name then]层次结构级别配置其他操作:
port-mirrorport-mirror-instance
Port Mirroring
该 port-mirror 操作可在设备上启用全局端口镜像,这适用于所有数据包转发引擎 (PFE) 和关联的接口。
对于 MPLS 系列过滤器,将为全局端口镜像启用该 port-mirror 操作。
Port Mirroring Instance
该 port-mirror-instance 操作使您能够使用输入采样和端口镜像输出目标的不同属性自定义每个实例,而不必使用单个系统范围的配置进行端口镜像。
通过在层次结构级别包含instance port-mirror-instance-name[edit forwarding-options port-mirror]语句,您只能为每个灵活 PIC 集中器 (FPC) 配置两个端口镜像实例。然后,您可以将各个端口镜像实例与 FPC、PIC 或(转发引擎板 (FEB) )关联,具体取决于设备硬件。
对于 MPLS 系列过滤器, port-mirror-instance 仅为端口镜像实例启用该操作。
对于和port-mirrorport-mirror-instance操作,必须使用第 2 层系列而不是第 3 层系列 MPLS(第 3 层)启用输出接口,选择性端口镜像功能才能正常工作。
配置示例
基于 IP 的过滤配置
[edit firewall family mpls filter mpls-filter]
term ipv4-term {
from {
ip-version {
ipv4 {
source-address {
10.10.10.10/24;
}
destination-address {
20.20.20.20/24;
}
protocol tcp {
source-port 100;
destination-port 200;
}
soure-prefix-list ipv4-source-users;
destination-prefix-list ipv4-destination-users;
}
}
exp 1;
}
then port-mirror;
then accept;
then count;
}
term ipv6-term {
from {
ip-version {
ipv6 {
source-address {
2000::1/128;
}
destination-address {
3000::1/128;
}
protocol tcp {
source-port 100;
destination-port 200;
}
source-prefix-list ipv6-source-users;
destination-prefix-list ipv6-destination-users;
}
}
exp 1;
}
then port-mirror-instance port-mirror-instance1;
then accept;
then count;
}
[edit policy-options]
prefix-list ipv4-source-users {
172.16.1.16/28;
172.16.2.16/28;
}
prefix-list ipv6-source-users {
2001::1/128;
3001::1/128;
}
[edit interfaces]
xe-0/0/1 {
unit 0 {
family inet {
address 100.100.100.1/30;
}
family mpls {
filter {
input mpls-filter;
}
}
}
}
选择性端口镜像配置
[edit forwarding-options]
port-mirroring {
input {
rate 2;
run-length 4;
maximum-packet-length 500;
}
family any {
output {
interface xe-2/0/2.0;
}
}
}
[edit forwarding-options]
port-mirroring {
instance {
port-mirror-instance1 {
input {
rate 3;
run-length 5;
maximum-packet-length 500;
}
family any {
output {
interface xe-2/0/2.0;
}
}
}
}
}
输出接口 xe-2/0/2.0 是针对第 2 层系列而非系列 MPLS 配置的。
对于和port-mirrorport-mirror-instance操作,必须使用第 2 层系列而不是第 3 层系列 MPLS(第 3 层)启用输出接口,选择性端口镜像功能才能正常工作。
镜像目标配置
[edit interfaces]
xe-2/0/2 {
vlan-tagging;
encapsulation extended-vlan-bridge;
unit 0 {
vlan-id 600;
}
}
[edit bridge-domains]
bd {
domain-type bridge;
interface xe-2/0/2.0;
}