帮助我们改善您的体验。

让我们了解您的想法。

您是否能抽出两分钟的时间完成一份问卷调查?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
list Table of Contents

机器翻译对您有帮助吗?

starstarstarstarstar
Go to English page
免责声明:

我们将使用第三方机器翻译软件翻译本页面。瞻博网络虽已做出相当大的努力提供高质量译文,但无法保证其准确性。如果对译文信息的准确性有任何疑问,请参阅英文版本. 可下载的 PDF 仅提供英文版.

基本单速率双色监管器

date_range 18-Jan-25

单速率双色监管器概述

单速率双色管制通过对不符合限制的流量应用隐式或配置的操作,为特定服务级别强制实施配置的流量速率。将单速率双色监管器应用于接口上的输入或输出流量时,监管器会将流量计量到由以下组件定义的速率限制:

  • 带宽限制 — 在接口上接收或传输的数据包允许的平均每秒位数。您可以将带宽限制指定为每秒绝对位数或 1 到 100 之间的百分比值。如果指定了百分比值,则有效带宽限制将按物理接口介质速率或 逻辑接口 配置的整形速率的百分比计算。

  • 每秒数据包数 (pps) 限制(仅限带 MPC 的 MX 系列)– 在接口上接收或传输的数据包允许的平均每秒数据包数。您可以将 pps 限制指定为每秒数据包的绝对数量。

  • 突发大小限制 - 数据突发允许的最大大小。

  • 数据包突发限制–

对于符合配置限制的流量(归类为绿色流量),数据包将隐式标记为数据包丢失优先级 (PLP) 级别 low ,并允许其不受限制地通过接口。

对于超出配置限制的信息流(归类为红色流量),将根据为监管器配置的流量监管操作来处理数据包。操作可能是丢弃数据包,也可能是使用指定的转发类和/或指定的 PLP 重新标记数据包,然后传输数据包。

要对第 3 层流量进行速率限制,您可以通过以下方式应用双色监管器:

  • 直接连接到特定协议级别的逻辑接口。

  • 作为在特定协议级别应用于逻辑接口的标准无状态 防火墙过滤器 的操作。

要对第 2 层流量进行速率限制,只能将双色监管器用作 逻辑接口监管器 。您不能通过防火墙过滤器将双色监管器应用于第 2 层流量。

注:

在 MX 平台上,当流量确认配置的监管器限制时,丢包优先级 (PLP) 不会隐式为低(绿色)。相反,它采用用户配置的 PLP 值,如高、中高、中低。在 下使用 dp-rewrite 在 MX edit firewall policer <policer-name> 平台上启用此行为。如果未启用旋钮,则数据包可能会带有其原始颜色和丢失优先级。

示例:通过配置入口单速率双色监管器来限制网络边界的入站流量

此示例说明如何配置入口单速率双色监管器以过滤传入流量。监管器对合同内和合同外流量实施服务等级 (CoS) 策略。您可以将单速率双色监管器应用于传入数据包和/或传出数据包。此示例将监管器用作输入(入口)监管器。本主题的目标是通过使用演示流量管制操作的示例来向您介绍管制。

监管器使用称为令牌桶的概念,根据为监管器定义的参数分配系统资源。对令牌桶概念及其底层算法的全面解释超出了本文档的范围。有关流量监管和一般 CoS 的更多信息,请参阅 Miguel Barreiros 和 Peter Lundqvist 撰写的 《支持 QOS 的网络 — 工具和基础 》。这本书在许多在线书商和 www.juniper.net/books 都有售。

要求

为了验证此过程,此示例使用流量生成器。流量生成器可以基于硬件,也可以是在服务器或主机上运行的软件。

运行 Junos OS 的设备上广泛支持此过程中的功能。此处显示的示例已在运行 Junos OS 10.4 版的 MX 系列路由器上进行了测试和验证。

概述

单速率双色管制通过将隐式或配置的操作应用于不符合限制的流量,为特定服务级别强制执行配置的流量速率。将单速率双色监管器应用于接口上的输入或输出流量时,监管器会将流量计量到由以下组件定义的速率限制:

  • 带宽限制 — 在接口上接收或传输的数据包允许的平均每秒位数。您可以将带宽限制指定为每秒绝对位数或 1 到 100 之间的百分比值。如果指定了百分比值,则有效带宽限制将按物理接口介质速率或逻辑接口配置的整形速率的百分比计算。

  • 突发大小限制 - 数据突发允许的最大大小。突发大小以字节为单位。我们建议使用两个公式来计算突发大小:

    突发大小 = 带宽 x 突发流量允许时间 / 8

    突发大小 = 接口 mtu x 10

    有关配置突发大小的信息,请参阅 确定流量监管器的适当突发大小

    注:

    接口的缓冲区空间有限。通常,接口的估计总缓冲区深度约为 125 毫秒。

对于符合配置限制的流量(归类为绿色流量),数据包被隐式标记为低数据包丢失优先级 (PLP),并允许其不受限制地通过接口。

对于超出配置限制的信息流(归类为红色流量),将根据为监管器配置的流量监管操作来处理数据包。此示例丢弃突增超过 15 KBps 限制的数据包。

要对第 3 层流量进行速率限制,您可以通过以下方式应用双色监管器:

  • 直接连接到特定协议级别的逻辑接口。

  • 作为在特定协议级别应用于逻辑接口的标准无状态防火墙过滤器的操作。这是此示例中使用的技术。

要对第 2 层流量进行速率限制,只能将双色监管器用作逻辑接口监管器。您不能通过防火墙过滤器将双色监管器应用于第 2 层流量。

警告:

您可以在监管器中选择带宽限制或带宽百分比,因为它们是互斥的。您不能将监管器配置为对聚合、隧道和软件接口使用带宽百分比。

在此示例中,主机是模拟 Web 服务器的流量生成器。设备 R1 和 R2 归服务提供商所有。Web 服务器由设备 Host2 上的用户访问。设备 Host1 将使用源 TCP HTTP 端口 80 向用户发送流量。配置单速率双色监管器并将其应用于设备 R1 上连接到设备 Host1 的接口。监管器强制执行 Web 服务器所有者与拥有设备 R1 的服务提供商之间建立的合同带宽可用性,用于通过将设备 Host1 连接到设备 R1 的链路流动的 Web 流量。

根据 Web 服务器所有者与拥有设备 R1 和 R2 的服务提供商之间的合同带宽可用性,监管器会将源自设备 Host1 的 HTTP 端口 80 流量限制为使用可用带宽的 700 Mbps (70%),允许的突发速率是主机设备 Host1 和设备 R1 之间千兆以太网接口 MTU 大小的 10 倍。

注:

在实际场景中,您可能还会对各种其他端口(如 FTP、SFTP、SSH、TELNET、SMTP、IMAP 和 POP3)的限制流量进行速率,因为它们通常作为 Web 托管服务的附加服务包含在内。

注:

您需要为网络控制协议(如路由协议、DNS 和保持网络连接正常运行所需的任何其他协议)留出一些不受速率限制的额外带宽。这就是防火墙过滤器具有最终接受条件的原因。

拓扑学

此示例使用 中的 图 1拓扑。

图 1: 单速率双色监管器场景单速率双色监管器场景

图 2 显示了监管行为。

图 2: 单速率双色监管器场景中的流量限制单速率双色监管器场景中的流量限制

配置

程序

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI [edit] 中。

设备 R1

content_copy zoom_out_map
set interfaces ge-2/0/5 description to-Host
set interfaces ge-2/0/5 unit 0 family inet address 172.16.70.2/30
set interfaces ge-2/0/5 unit 0 family inet filter input mf-classifier
set interfaces ge-2/0/8 description to-R2
set interfaces ge-2/0/8 unit 0 family inet address 10.50.0.1/30
set interfaces lo0 unit 0 description looback-interface
set interfaces lo0 unit 0 family inet address 192.168.13.1/32
set firewall policer discard if-exceeding bandwidth-limit 700m
set firewall policer discard if-exceeding burst-size-limit 15k
set firewall policer discard then discard
set firewall family inet filter mf-classifier term t1 from protocol tcp
set firewall family inet filter mf-classifier term t1 from port 80
set firewall family inet filter mf-classifier term t1 then policer discard
set firewall family inet filter mf-classifier term t2 then accept
set protocols ospf area 0.0.0.0 interface ge-2/0/5.0 passive
set protocols ospf area 0.0.0.0 interface lo0.0 passive
set protocols ospf area 0.0.0.0 interface ge-2/0/8.0

设备 R2

content_copy zoom_out_map
set interfaces ge-2/0/8 description to-R1
set interfaces ge-2/0/8 unit 0 family inet address 10.50.0.2/30
set interfaces ge-2/0/7 description to-Host
set interfaces ge-2/0/7 unit 0 family inet address 172.16.80.2/30
set interfaces lo0 unit 0 description looback-interface
set interfaces lo0 unit 0 family inet address 192.168.14.1/32
set protocols ospf area 0.0.0.0 interface ge-2/0/7.0 passive
set protocols ospf area 0.0.0.0 interface lo0.0 passive
set protocols ospf area 0.0.0.0 interface ge-2/0/8.0
分步过程

下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器

要配置设备 R1:

  1. 配置设备接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R1# set ge-2/0/5 description to-Host
    user@R1# set ge-2/0/5 unit 0 family inet address 172.16.70.2/30
    user@R1# set ge-2/0/8 description to-R2
    user@R1# set ge-2/0/8 unit 0 family inet address 10.50.0.1/30
    user@R1# set lo0 unit 0 description looback-interface
    user@R1# set lo0 unit 0 family inet address 192.168.13.1/32
    
  2. 将防火墙过滤器应用于接口 ge-2/0/5 作为输入过滤器。

    content_copy zoom_out_map
    [edit interfaces ge-2/0/5 unit 0 family inet]
    user@R1# set filter input mf-classifier
    
  3. 将监管器配置为将 HTTP 流量(TCP 端口 80)的速率限制为 700 Mbps 带宽和 15000 KBps 的突发大小。

    content_copy zoom_out_map
    [edit firewall policer discard]
    user@R1# set if-exceeding bandwidth-limit 700m
    user@R1# set if-exceeding burst-size-limit 15k
    
  4. 将监管器配置为丢弃红色流量流中的数据包。

    content_copy zoom_out_map
    [edit firewall policer discard]
    user@R1# set then discard
    
  5. 将防火墙的两个条件配置为接受到端口 HTTP(端口 80)的所有 TCP 流量。

    content_copy zoom_out_map
    [edit firewall  family inet filter mf-classifier]
    user@R1# set term t1 from protocol tcp
    user@R1# set term t1 from port 80
    
  6. 配置防火墙操作以使用监管器对 HTTP TCP 流量进行速率限制。

    content_copy zoom_out_map
    [edit firewall  family inet filter mf-classifier]
    user@R1# set term t1 then policer discard
    
  7. 在防火墙过滤器的末尾,配置接受所有其他流量的默认操作。

    否则,到达接口且防火墙未明确接受的所有流量都将被丢弃。

    content_copy zoom_out_map
    [edit firewall  family inet filter mf-classifier]
    user@R1# set term t2 then accept
    
  8. 配置 OSPF。

    content_copy zoom_out_map
    [edit protocols ospf]
    user@R1# set area 0.0.0.0 interface ge-2/0/5.0 passive
    user@R1# set area 0.0.0.0 interface lo0.0 passive
    user@R1# set area 0.0.0.0 interface ge-2/0/8.0
    
分步过程

要配置设备 R2:

  1. 配置设备接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R1# set ge-2/0/8 description to-R1
    user@R1# set ge-2/0/7 description to-Host
    user@R1# set lo0 unit 0 description looback-interface
    user@R1# set ge-2/0/8 unit 0 family inet address 10.50.0.2/30
    user@R1# set ge-2/0/7 unit 0 family inet address 172.16.80.2/30
    user@R1# set lo0 unit 0 family inet address 192.168.14.1/32
    
  2. 配置 OSPF。

    content_copy zoom_out_map
    [edit protocols ospf]
    user@R1# set area 0.0.0.0 interface ge-2/0/7.0 passive
    user@R1# set area 0.0.0.0 interface lo0.0 passive
    user@R1# set area 0.0.0.0 interface ge-2/0/8.0
    
结果

在配置模式下,输入 show interfacesshow firewallshow protocols ospf 命令确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
user@R1# show interfaces
ge-2/0/5 {
    description to-Host;
    unit 0 {
        family inet {
            filter {
                input mf-classifier;
            }
            address 172.16.70.2/30;
        }
    }
}
ge-2/0/8 {
    description to-R2;
    unit 0 {
        family inet {
            address 10.50.0.1/30;
        }
    }
}
lo0 {
    unit 0 {
        description looback-interface;
        family inet {
            address 192.168.13.1/32;
        }
    }
}
content_copy zoom_out_map
user@R1# show firewall
family inet {
    filter mf-classifier {
        term t1 {
            from {
                protocol tcp;
                port 80;
            }
            then policer discard;
        }
        term t2 {
            then accept;
        }
    }
}
policer discard {
    if-exceeding {
        bandwidth-limit 700m;
        burst-size-limit 15k;
    }
    then discard;
}
content_copy zoom_out_map
user@R1# show protocols ospf
area 0.0.0.0 {
    interface ge-2/0/5.0 {
        passive;
    }
    interface lo0.0 {
        passive;
    }
    interface ge-2/0/8.0;
}

如果完成设备 R1 的配置,请从配置模式输入 commit

content_copy zoom_out_map
user@R2# show interfaces
ge-2/0/7 {
    description to-Host;
    unit 0 {
        family inet {
            address 172.16.80.2/30;
        }
    }
}
ge-2/0/8 {
    description to-R1;
    unit 0 {
        family inet {
            address 10.50.0.2/30;
        }
    }
}
lo0 {
    unit 0 {
        description looback-interface;
        family inet {
            address 192.168.14.1/32;
        }
    }
}
content_copy zoom_out_map
user@R2# show protocols ospf
area 0.0.0.0 {
    interface ge-2/0/7.0 {
        passive;
    }
    interface lo0.0 {
        passive;
    }
    interface ge-2/0/8.0;
}

如果完成设备 R2 配置,请从配置模式输入 commit

验证

确认配置工作正常。

清除计数器

目的

确认已清除防火墙计数器。

操作

在设备 R1 上,运行 clear firewall all 命令以将防火墙计数器重置为 0。

content_copy zoom_out_map
user@R1> clear firewall all

将 TCP 流量发送到网络并监控丢弃

目的

确保发送的目标流量在输入接口 (ge-2/0/5) 上受速率限制。

操作
  1. 使用流量生成器发送 10 个源端口为 80 的 TCP 数据包。

    -s 标志设置源端口。-k 标志使源端口保持稳定在 80 而不是递增。-c 标志将数据包数设置为 10。-d 标志设置数据包大小。

    目标 IP 地址 172.16.80.1 属于连接到设备 R2 的设备主机 2。设备主机 2 上的用户已从设备主机 1(由设备主机 1 上的流量生成器模拟的 Web 服务器)请求网页。受速率限制的数据包从设备主机 1 发送,以响应来自设备主机 2 的请求。

    注:

    在此示例中,监管器数量减少到 8 Kbps 的带宽限制和 1500 KBps 的突发大小限制,以确保在此测试期间丢弃某些数据包。

    content_copy zoom_out_map
    [root@host]#  hping 172.16.80.1  -c 10 -s 80  -k -d 300
    
    
    [User@Host]#  hping 172.16.80.1 -c 10 -s 80 -k -d 350
    HPING 172.16.80.1 (eth1 172.16.80.1): NO FLAGS are set, 40 headers + 350 data bytes
    len=46 ip=172.16.80.1 ttl=62 DF id=0 sport=0 flags=RA seq=0 win=0 rtt=0.5 ms
    .
    .
    .
    --- 172.16.80.1 hping statistic ---
    10 packets transmitted, 6 packets received, 40% packet loss
    round-trip min/avg/max = 0.5/3000.8/7001.3 ms
  2. 在设备 R1 上,使用 show firewall 命令检查防火墙计数器。

    content_copy zoom_out_map
    user@R1> show firewall
    
    
    User@R1# run show firewall         
    
    Filter: __default_bpdu_filter__                                
    
    Filter: mf-classifier                                          
    Policers:
    Name                                                Bytes              Packets
    discard-t1                                          1560               4
意义

在步骤 1 和 2 中,两个设备的输出显示丢弃了 4 个数据包 这意味着至少有 8 Kbps 的绿色(合同内 HTTP 端口 80)流量,并且超过了红色合同外 HTTP 端口 80 流量的 1500 KBps 突发选项。

示例:在同一接口上配置接口和防火墙过滤器监管器

此示例说明如何配置三个单速率双色监管器,并将监管器应用于同一单标记虚拟 LAN (VLAN) 逻辑接口上的 IPv4 输入流量。

要求

配置此示例之前,不需要除设备初始化之外的特殊配置。

概述

在此示例中,您配置三个单速率双色监管器,并将监管器应用于同一单标记 VLAN 逻辑接口上的 IPv4 输入流量。两个监管器通过防火墙过滤器应用于接口,一个监管器直接应用于接口。

您可以配置一个名为 的监管器, p-all-1m-5k-discard以将流量速率限制为 1 Mbps,突发大小为 5000 字节。您可以将此监管器直接应用于逻辑接口上的 IPv4 输入流量。当您将监管器直接应用于逻辑接口上的协议特定流量时,该监管器被称为 接口监管器

您可以将其他两个监管器配置为允许 500 KB 的突发大小,并使用 IPv4 标准无状态防火墙过滤器将这些监管器应用于逻辑接口上的 IPv4 输入流量。当您通过防火墙过滤器操作将监管器应用于逻辑接口上的协议特定流量时,监管器被称为 防火墙过滤器监管器

  • 您可以配置名为 p-icmp-500k-500k-discard 的监管器,通过丢弃不符合这些限制的数据包,将流量速率限制为 500 Kbps,突发大小为 500 Kbytes。您可以配置其中一个防火墙过滤器术语,以将此监管器应用于互联网控制消息协议 (ICMP) 数据包。

  • 您可以配置名为 p-ftp-10p-500k-discard 的监管器,通过丢弃不符合这些限制的数据包,将流量速率限制为 10% 带宽,突发大小为 500 KB。您可以配置另一个防火墙过滤器术语以将此监管器应用于文件传输协议 (FTP) 数据包。

您配置的带宽限制以百分比值(而不是绝对带宽值)表示的监管器称为 带宽监管器。只有单速率双色监管器可以配置百分比带宽规格。默认情况下,带宽监管器会将流量速率限制为目标逻辑接口底层物理接口线速的指定百分比。

拓扑学

您可以将目标逻辑接口配置为以 100 Mbps 运行的快速以太网接口上的单标记 VLAN 逻辑接口。这意味着,您配置了 10% 带宽限制的监管器(应用于 FTP 数据包的监管器)将此接口上的 FTP 流量速率限制为 10 Mbps。

注:

在此示例中,您没有将带宽监管器配置为 逻辑带宽监管器。因此,该百分比基于物理介质速率,而不是逻辑接口的配置整形速率。

配置为引用两个监管器的防火墙过滤器必须配置为 接口特定的过滤器。由于用于对 FTP 数据包进行速率限制的监管器将带宽限制指定为百分比值,因此引用此监管器的防火墙过滤器必须配置为特定于接口的过滤器。因此,如果将此防火墙过滤器应用于多个接口,而不仅仅是本例中的快速以太网接口,则将为应用过滤器的每个接口创建唯一的监管器和计数器。

配置

下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参见 在配置模式下使用 CLI 编辑器

要配置此示例,请执行以下操作:

CLI 快速配置

要快速配置此示例,请将以下配置命令复制到文本文件中,删除所有换行符,然后将命令粘贴到层次结构级别的 CLI [edit] 中。

content_copy zoom_out_map
set interfaces fe-0/1/1 vlan-tagging
set interfaces fe-0/1/1 unit 0 vlan-id 100
set interfaces fe-0/1/1 unit 0 family inet address 10.20.15.1/24
set interfaces fe-0/1/1 unit 1 vlan-id 101
set interfaces fe-0/1/1 unit 1 family inet address 10.20.240.1/24
set firewall policer p-all-1m-5k-discard if-exceeding bandwidth-limit 1m
set firewall policer p-all-1m-5k-discard if-exceeding burst-size-limit 5k
set firewall policer p-all-1m-5k-discard then discard
set firewall policer p-ftp-10p-500k-discard if-exceeding bandwidth-percent 10
set firewall policer p-ftp-10p-500k-discard if-exceeding burst-size-limit 500k
set firewall policer p-ftp-10p-500k-discard then discard
set firewall policer p-icmp-500k-500k-discard if-exceeding bandwidth-limit 500k
set firewall policer p-icmp-500k-500k-discard if-exceeding burst-size-limit 500k
set firewall policer p-icmp-500k-500k-discard then discard
set firewall family inet filter filter-ipv4-with-limits interface-specific
set firewall family inet filter filter-ipv4-with-limits term t-ftp from protocol tcp
set firewall family inet filter filter-ipv4-with-limits term t-ftp from port ftp
set firewall family inet filter filter-ipv4-with-limits term t-ftp from port ftp-data
set firewall family inet filter filter-ipv4-with-limits term t-ftp then policer p-ftp-10p-500k-discard
set firewall family inet filter filter-ipv4-with-limits term t-icmp from protocol icmp
set firewall family inet filter filter-ipv4-with-limits term t-icmp then policer p-icmp-500k-500k-discard
set firewall family inet filter filter-ipv4-with-limits term catch-all then accept
set interfaces fe-0/1/1 unit 1 family inet filter input filter-ipv4-with-limits
set interfaces fe-0/1/1 unit 1 family inet policer input p-all-1m-5k-discard

配置单标记 VLAN 逻辑接口

分步过程

要配置单标记 VLAN 逻辑接口,请执行以下操作:

  1. 启用快速以太网接口的配置。

    content_copy zoom_out_map
    [edit]
    user@host# edit interfaces fe-0/1/1
    
  2. 启用单标记 VLAN 成帧。

    content_copy zoom_out_map
    [edit interfaces fe-0/1/1]
    user@host# set vlan-tagging
    
  3. 将 VLAN ID 绑定到逻辑接口。

    content_copy zoom_out_map
    [edit interfaces fe-0/1/1]
    user@host# set unit 0 vlan-id 100
    user@host# set unit 1 vlan-id 101
    
  4. 在单标记 VLAN 逻辑接口上配置 IPv4。

    content_copy zoom_out_map
    [edit interfaces fe-0/1/1]
    user@host# set unit 0 family inet address 10.20.15.1/24
    user@host# set unit 1 family inet address 10.20.240.1/24
    
结果

通过输入 show interfaces 配置模式命令确认 VLAN 的配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。

content_copy zoom_out_map
[edit]
user@host# show interfaces
fe-0/1/1 {
    vlan-tagging;
    unit 0 {
        vlan-id 100;
        family inet {
            address 10.20.15.1/24;
        }
    }
    unit 1 {
        vlan-id 101;
        family inet {
            address 10.20.240.1/24;
        }
    }
}

配置三个监管器

分步过程

要配置三个监管器:

  1. 启用双色监管器的配置,以丢弃不符合 1 Mbps 带宽和 5000 字节突发大小的数据包。

    注:

    您可以将此监管器直接应用于单标记 VLAN 逻辑接口上的所有 IPv4 输入流量,这样数据包在受到速率限制之前不会被过滤。

    content_copy zoom_out_map
    [edit]
    user@host# edit firewall policer p-all-1m-5k-discard
    
  2. 配置第一个监管器。

    content_copy zoom_out_map
    [edit firewall policer p-all-1m-5k-discard]
    user@host# set if-exceeding bandwidth-limit 1m
    user@host# set if-exceeding burst-size-limit 5k
    user@host# set then discard
    
  3. 启用双色监管器的配置,以丢弃不符合指定为“10%”的带宽和 500,000 字节突发大小的数据包。

    您只能将此监管器应用于单标记 VLAN 逻辑接口上的 FTP 流量。

    您可以将此监管器应用为与来自 TCP 的 FTP 数据包匹配的 IPv4 防火墙过滤器术语的操作。

    content_copy zoom_out_map
    [edit firewall policer p-all-1m-5k-discard]
    user@host# up
     
    [edit]
    user@host# edit firewall policer p-ftp-10p-500k-discard
    
  4. 配置监管限制和操作。

    content_copy zoom_out_map
    [edit firewall policer p-ftp-10p-500k-discard]
    user@host# set if-exceeding bandwidth-percent 10
    user@host# set if-exceeding burst-size-limit 500k
    user@host# set then discard
    

    由于带宽限制以百分比形式指定,因此引用此监管器的防火墙过滤器必须配置为特定于接口的过滤器。

    注:

    如果您希望此监管器的速率限制为逻辑接口配置整形速率的 10%(而不是物理接口介质速率的 10%),则需要在[edit firewall policer p-all-1m-5k-discard]层次结构级别包含logical-bandwidth-policer该语句。这种类型的监管器称为 逻辑带宽监管器

  5. 启用 ICMP 数据包的 IPv4 防火墙过滤器监管器的配置。

    content_copy zoom_out_map
    [edit firewall policer p-ftp-10p-500k-discard]
    user@host# up
     
    [edit]
    user@host# edit firewall policer p-icmp-500k-500k-discard
    
  6. 配置监管限制和操作。

    content_copy zoom_out_map
    [edit firewall policer p-icmp-500k-500k-discard]
    user@host# set if-exceeding bandwidth-limit 500k
    user@host# set if-exceeding burst-size-limit 500k
    user@host# set then discard
    
结果

通过输入 show firewall 配置模式命令确认监管器的配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。

content_copy zoom_out_map
[edit]
user@host# show firewall
policer p-all-1m-5k-discard {
    if-exceeding {
        bandwidth-limit 1m;
        burst-size-limit 5k;
    }
    then discard;
}
policer p-ftp-10p-500k-discard {
    if-exceeding {
        bandwidth-percent 10;
        burst-size-limit 500k;
    }
    then discard;
}
policer p-icmp-500k-500k-discard {
    if-exceeding {
        bandwidth-limit 500k;
        burst-size-limit 500k;
    }
    then discard;
}

配置 IPv4 防火墙过滤器

分步过程

要配置 IPv4 防火墙过滤器,请执行以下操作:

  1. 启用 IPv4 防火墙过滤器的配置。

    content_copy zoom_out_map
    [edit]
    user@host# edit firewall family inet filter filter-ipv4-with-limits
    
  2. 将防火墙过滤器配置为特定于接口。

    content_copy zoom_out_map
    [edit firewall family inet filter filter-ipv4-with-limits]
    user@host# set interface-specific
    

    防火墙过滤器必须特定于接口,因为引用的其中一个监管器配置了以百分比值表示的带宽限制。

  3. 启用过滤器术语的配置以对 FTP 数据包进行速率限制。

    content_copy zoom_out_map
    [edit firewall family inet filter filter-ipv4-with-limits]
    user@host# edit term t-ftp
     
    [edit firewall family inet filter filter-ipv4-with-limits term t-ftp]
    user@host# set from protocol tcp
    user@host# set from port [ ftp ftp-data ]
    

    FTP 消息通过 TCP 端口 20 (ftp) 发送,并通过 TCP 端口 21 (ftp-data) 接收。

  4. 配置过滤器术语以匹配 FTP 数据包。

    content_copy zoom_out_map
    [edit firewall family inet filter filter-ipv4-with-limits term t-ftp]
    user@host# set then policer p-ftp-10p-500k-discard
    
  5. 启用过滤器术语的配置以对 ICMP 数据包进行速率限制。

    content_copy zoom_out_map
    [edit firewall family inet filter filter-ipv4-with-limits term t-ftp]
    user@host# up
     
    [edit firewall family inet filter filter-ipv4-with-limits]
    user@host# edit term t-icmp
    
  6. 配置 ICMP 数据包的过滤器术语

    content_copy zoom_out_map
    [edit firewall family inet filter filter-ipv4-with-limits term t-icmp]
    user@host# set from protocol icmp
    user@host# set then policer p-icmp-500k-500k-discard
    
  7. 配置过滤器术语以接受所有其他数据包而不进行管制。

    content_copy zoom_out_map
    [edit firewall family inet filter filter-ipv4-with-limits term t-icmp]
    user@host# up
     
    [edit firewall family inet filter filter-ipv4-with-limits]
    user@host# set term catch-all then accept
    
结果

通过输入 show firewall 配置模式命令确认防火墙过滤器的配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。

content_copy zoom_out_map
[edit]
user@host# show firewall
family inet {
    filter filter-ipv4-with-limits {
        interface-specific;
        term t-ftp {
            from {
                protocol tcp;
                port [ ftp ftp-data ];
            }
            then policer p-ftp-10p-500k-discard;
        }
        term t-icmp {
            from {
                protocol icmp;
            }
            then policer p-icmp-500k-500k-discard;
        }
        term catch-all {
            then accept;
        }
    }
}
policer p-all-1m-5k-discard {
    if-exceeding {
        bandwidth-limit 1m;
        burst-size-limit 5k;
    }
    then discard;
}
policer p-ftp-10p-500k-discard {
    if-exceeding {
        bandwidth-percent 10;
        burst-size-limit 500k;
    }
    then discard;
}
policer p-icmp-500k-500k-discard {
    if-exceeding {
        bandwidth-limit 500k;
        burst-size-limit 500k;
    }
    then discard;
}

将接口监管器和防火墙过滤器监管器应用于逻辑接口

分步过程

要将三个监管器应用于 VLAN,请执行以下操作:

  1. 在逻辑接口上启用 IPv4 配置。

    content_copy zoom_out_map
    [edit]
    user@host# edit interfaces fe-0/1/1 unit 1 family inet
    
  2. 将防火墙过滤器监管器应用于接口。

    content_copy zoom_out_map
    [edit interfaces fe-0/1/1 unit 1 family inet]
    user@host# set filter input filter-ipv4-with-limits
    
  3. 将接口监管器应用于接口。

    content_copy zoom_out_map
    [edit interfaces fe-0/1/1 unit 1 family inet]
    user@host# set policer input p-all-1m-5k-discard
    

    在 的 fe-0/1/1.0 输入数据包之前,先根据接口监管器对其进行评估。有关更多详细信息,请参阅监管器和防火墙过滤器操作的顺序

结果

通过输入 show interfaces 配置模式命令确认接口的配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。

content_copy zoom_out_map
[edit]
user@host# show interfaces
fe-0/1/1 {
    vlan-tagging;
    unit 0 {
        vlan-id 100;
        family inet {
            address 10.20.15.1/24;
        }
    }
    unit 1 {
        vlan-id 101;
        family inet {
            filter {
                input filter-ipv4-with-limits;
            }
            policer {
                input p-all-1m-5k-discard;
            }
            address 10.20.240.1/24;
        }
    }
}

如果完成设备配置,请从配置模式输入 commit

验证

确认配置工作正常。

显示直接应用于逻辑接口的监管器

目的

验证在逻辑接口上接收数据包时是否评估接口监管器。

操作

show interfaces policers对逻辑接口 fe-0/1/1.1使用操作模式命令。列 ProtoInput Policer 列的命令输出部分显示,当逻辑接口上收到数据包时,将评估监管器 p-all-1m-5k-discard

content_copy zoom_out_map
user@host> show interfaces policers fe-0/1/1.1
Interface       Admin Link Proto Input Policer         Output Policer
fe-0/1/1.1      up    up        
                           inet  p-all-1m-5k-discard-fe-0/1/1.1-inet-i

在此示例中,接口监管器仅适用于输入方向上的逻辑接口流量。

显示直接应用于逻辑接口的监管器的统计信息

目的

验证接口监管器评估的数据包数。

操作

show policer使用操作模式命令并选择性地指定监管器的名称。命令输出显示每个已配置的监管器(或指定的监管器)在每个方向上评估的数据包数。

content_copy zoom_out_map
user@host> show policer p-all-1m-5k-discard-fe-0/1/1.1-inet-i
Policers:
Name                                                Bytes              Packets
p-all-1m-5k-discard-fe-0/1/1.1-inet-i                 200                    5

显示应用于接口的监管器和防火墙过滤器

目的

验证防火墙过滤器 filter-ipv4-with-limits 是否已应用于逻辑接口 fe-0/1/1.1上的 IPv4 输入流量。

操作

show interfaces statistics对逻辑接口 fe-0/1/1.1使用操作模式命令,并包括该detail选项。在 Protocol inet 命令输出部分的部分下, Input FiltersPolicer 行显示应用于输入方向逻辑接口的过滤器和监管器的名称。

content_copy zoom_out_map
user@host> show interfaces statistics fe-0/1/1.1 detail
  Logical interface fe-0/1/1.1 (Index 83) (SNMP ifIndex 545) (Generation 153)
    Flags: SNMP-Traps 0x4000 VLAN-Tag [ 0x8100.100 ]  Encapsulation: ENET2
    Traffic statistics:
     Input  bytes  :                    0
     Output bytes  :                   46
     Input  packets:                    0
     Output packets:                    1
    Local statistics:
     Input  bytes  :                    0
     Output bytes  :                   46
     Input  packets:                    0
     Output packets:                    1
    Transit statistics:
     Input  bytes  :                    0                    0 bps
     Output bytes  :                    0                    0 bps
     Input  packets:                    0                    0 pps
     Output packets:                    0                    0 pps
    Protocol inet, MTU: 1500, Generation: 176, Route table: 0
      Flags: Sendbcast-pkt-to-re
      Input Filters: filter-ipv4-with-limits-fe-0/1/1.1-i
      Policer: Input: p-all-1m-5k-discard-fe-0/1/1.1-inet-i
      Addresses, Flags: Is-Preferred Is-Primary
        Destination: 10.20.130/24, Local: 10.20.130.1, Broadcast: 10.20.130.255,
        Generation: 169

在此示例中,两个防火墙过滤器监管器仅适用于输入方向上的逻辑接口流量。

显示防火墙过滤器监管器的统计信息

目的

验证防火墙过滤器监管器评估的数据包数。

操作

show firewall对应用于逻辑接口的过滤器使用操作模式命令。

content_copy zoom_out_map
[edit]
user@host> show firewall filter filter-ipv4-with-limits-fe-0/1/1.1-i

Filter: filter-ipv4-with-limits-fe-0/1/1.1-i                              
Policers:
Name                                                Bytes              Packets
p-ftp-10p-500k-discard-t-ftp-fe-0/1/1.1-i               0                    0
p-icmp-500k-500k-discard-t-icmp-fe-0/1/1.1-i            0                    0

命令输出显示监管器的名称(p-ftp-10p-500k-discardp-icmp-500k-500k-discard),以及指定监管器操作的过滤器术语的名称(t-ftp 分别为 和 t-icmp)。监管器特定的输出线路显示与过滤器术语匹配的数据包数。这只是不规范(不规范)数据包计数,而不是监管器监管的所有数据包。

footer-navigation