访问控制列表(防火墙过滤器)
阅读本主题可了解云原生路由器中的第 3 层至第 4 层访问控制列表(防火墙过滤器)。
瞻博网络云原生路由器版本支持无状态防火墙过滤器。防火墙过滤器提供了一种保护云原生路由器的方法,使其免受将路由器传输到网络目标或发往路由引擎的过多流量的影响。无状态防火墙过滤器(也称为访问控制列表 (ACL))不会以状态方式检查流量。相反,它会静态评估数据包内容,并不跟踪网络连接的状态。无状态防火墙过滤器的基本目的是通过使用数据包过滤来增强安全性。通过数据包过滤,您可以检查传入或传出数据包的组成部分,然后对符合指定条件的数据包执行指定的作。无状态防火墙过滤器的典型用途是保护路由引擎进程和资源免受恶意或不受信任数据包的影响。
要影响允许哪些数据包在系统中传输并根据需要对数据包应用特殊作,可以配置一个或多个数据包过滤规则(称为 过滤术语)的序列。过滤器术语指定用于确定匹配 项的匹配条件 以及要对匹配数据包执行 的作 。借助无状态防火墙过滤器,您可以根据对第 3 层和第 4 层标头字段的评估来作特定协议家族的任何数据包,包括分段数据包。有关更多信息,请查看 无状态防火墙过滤器概述 主题。
在云原生路由器中,您只能将无状态防火墙过滤器应用于入口接口。支持的接口类型包括交换矩阵接口、子接口、Pod 接口和接口 irb
。
云原生路由器每个系列最多支持 16 个过滤器,每个过滤器最多支持 16 个术语。
云原生路由器支持 IPv4 和 IPv6 标准防火墙过滤器,并提供表中提供的匹配条件和作。云原生路由器还支持第 2 层访问控制列表(网桥家族的防火墙过滤器)。
匹配条件 |
描述 |
---|---|
目标地址 address |
匹配 IPv4 目标地址字段。您可以提供带有可选子网掩码的前缀。 |
目标端口 number | 匹配 UDP 或 TCP 目标端口字段。 配置基于端口的匹配时,还必须在同一筛选条件词中配置 要代替数值,可以指定以下文本同义词之一(端口号也会列出): |
源地址 address |
匹配发送数据包的源节点的 IPv4 地址。您可以提供带有可选子网掩码的前缀。 |
源端口 number |
匹配 UDP 或 TCP 源端口字段。 配置基于端口的匹配时,还必须在同一筛选条件词中配置 要代替数值,可以指定与匹配条件一起 |
协议 number |
匹配 IP 协议类型字段。要代替数值,可以指定以下文本同义词之一(也会列出字段值): |
tcp 标志 value |
匹配 TCP 报头的 8 位 TCP 标志字段中的一个或多个低阶 6 位。 若要指定各个位字段,可以指定以下文本同义词或十六进制值:
在 TCP 会话中,SYN 标志仅在发送的初始数据包中设置,而 ACK 标志在初始数据包之后发送的所有数据包中设置。 您可以使用位字段逻辑运算符将多个标志串在一起。 如果配置此匹配条件,建议同时使用同一术语配置 |
ICMP 类型 number |
匹配 ICMP 消息类型字段。 要代替数值,可以指定以下文本同义词之一(也会列出字段值): |
匹配条件 |
描述 |
---|---|
目标地址 address |
匹配 IPv6 目标地址字段。您可以提供带有可选子网掩码的前缀。 |
目标端口 number | 匹配 UDP 或 TCP 目标端口字段。 配置基于端口的匹配时,还必须在同一筛选条件词中配置 要代替数值,可以指定以下文本同义词之一(端口号也会列出): |
源地址 address |
匹配发送数据包的源节点的 IPv6 地址。您可以提供带有可选子网掩码的前缀。 |
源端口 number |
匹配 UDP 或 TCP 源端口字段。 配置基于端口的匹配时,还必须在同一筛选条件词中配置 要代替数值,可以指定与匹配条件一起 |
tcp 标志 value |
匹配 TCP 报头的 8 位 TCP 标志字段中的一个或多个低阶 6 位。 若要指定各个位字段,可以指定以下文本同义词或十六进制值:
在 TCP 会话中,SYN 标志仅在发送的初始数据包中设置,而 ACK 标志在初始数据包之后发送的所有数据包中设置。 您可以使用位字段逻辑运算符将多个标志串在一起。 |
ICMP 类型 message-type |
匹配 ICMP 消息类型字段。 要代替数值,可以指定以下文本同义词之一(也会列出字段值): |
作类型 |
描述 |
支持的作 |
---|---|---|
终止 |
停止对特定数据包的防火墙过滤器的所有评估。路由器(或交换机)执行指定的作,并且不会使用其他术语来检查数据包。 您只能在防火墙过滤器术语中指定一个终止作。如果尝试在筛选器术语中指定多个终止作,则最新的终止作将替换现有的终止作。但是,您可以在单个术语中将一个终止作指定为一个或多个非终止作。例如,在术语中,可以使用 |
|
非终止 |
对数据包执行其他功能(如递增计数器、记录有关数据包标头的信息、对数据包数据进行采样或使用系统日志功能向远程主机发送信息),但任何其他术语都用于检查数据包。 注意:云原生路由器仅在与终止作一起添加时才支持 |
计数 counter-name |
配置示例
使用 configlet 资源 来配置 cRPD pod。
您可以在层次结构下 firewall
使用无状态防火墙过滤器配置云原生路由器控制器。IPv4 家族的配置示例如下:
firewall { family inet { filter temp { term a { from { source-address { 10.0.0.1/32; } destination-address { 10.0.0.2/32; } protocol icmp; icmp-type echo-request; source-port http; destination-port bgp; tcp-flags fin; } then { count c1; accept; } } } } }
IPv6 家族的配置示例如下:
firewall { family inet6 { filter temp6 { term a { from { source-address { 2001:db8::1/128; } destination-address { 2001:db8::1/128; } icmp-type echo-request; source-port http; destination-port bgp; tcp-flags fin; } then { count c1; discard; } } } } }
过滤器将应用于入口接口。支持的接口包括交换矩阵接口、子接口、Pod 接口和接口 irb
。过滤器只能应用于接口的输入:
user@host > show interfaces enp4s0 unit 0 { family inet { filter { input temp; } address 10.0.0.1/24; } family inet6 { filter { input temp6; } } }
故障 排除
云原生路由器控制器命令
显示系列 inet (IPv4) 的所有防火墙过滤器
user@host> show firewall family inet Filter: temp Counters: Name Bytes Packets c1 0 0 c2 1532909 22500 Filter: temp 2 Counters: Name Bytes Packets c3 0 0 c4 100 100
显示系列 inet 的特定防火墙过滤器
user@host> show firewall family inet filter temp Filter: temp Counters: Name Bytes Packets c1 0 0 c2 1532909 22500
显示族 inet 的防火墙过滤器的特定计数器
user@host> show firewall family inet filter temp counter c2 Filter: temp Counters: Name Bytes Packets c2 1532909 22500
显示系列 inet6 (IPv6) 的所有防火墙过滤器
user@host> show firewall family inet6 Filter: temp6 Counters: Name Bytes Packets c1 0 0 c2 1532909 22500 Filter: temp6_2 Counters: Name Bytes Packets c3 0 0 c4 100 100
您可以使用以下命令清除计数器统计信息:
clear firewall family name >> clear all counter statistics for a family clear firewall family name filter name >> clear all counter statistics for a specific filter for a family clear firewall family name filter name count counter-name >> clear statistics for a specific counter for a specific filter for a family
vRouter 命令
bash-5.1# acl --family inet --filter f4 --term t4 ======================================= Filter: f4 ======================================= Term: t4 ----- Priority: 268420555 Dest IP: 10.0.0.1/32 Src IP: 10.0.0.2/32 Dst ports: [179 - 179] Src ports: [179 - 179] Action: accept (n/a)
bash-5.1# acl --list-actions [1] inet filter "f1": Counter "c1" Rx Packets: 2 [2] inet filter "f1": Counter "c2" Rx Packets: 1
其他 acl
命令包括:
acl --list-filters --family <inet/inet6/mpls> >>Lists the full acl table acl --list-actions >>Shows the acl entry corresponding to filter name and term name acl --family <inet/inet6/mpls> --filter <name> [--list-terms] >>Shows the ACL term list acl --family <inet/inet6/mpls> --filter <name> [--term <name>] >>Shows the ACL term details acl --family <inet/inet6/mpls> --filter <name> [--action <name>] >>Shows the ACL action details acl --family <inet/inet6/mpls> --filter <name> [--action <name>] --clear >>Clears the ACL action details acl --help >>Prints the help messages
您可以使用以下命令查看与接口关联的 vif --get
过滤器:
bash-5.1# vif --get 5 Vrouter Interface Table Flags: P=Policy, X=Cross Connect, S=Service Chain, Mr=Receive Mirror Mt=Transmit Mirror, Tc=Transmit Checksum Offload, L3=Layer 3, L2=Layer 2 D=DHCP, Vp=Vhost Physical, Pr=Promiscuous, Vnt=Native Vlan Tagged Mnp=No MAC Proxy, Dpdk=DPDK PMD Interface, Rfl=Receive Filtering Offload, Mon=Interface is Monitored Uuf=Unknown Unicast Flood, Vof=VLAN insert/strip offload, Df=Drop New Flows, L=MAC Learning Enabled Proxy=MAC Requests Proxied Always, Er=Etree Root, Mn=Mirror without Vlan Tag, HbsL=HBS Left Intf HbsR=HBS Right Intf, Ig=Igmp Trap Enabled, Ml=MAC-IP Learning Enabled, Me=Multicast Enabled vif0/5 PCI: 0000:07:00.0 NH: 10 MTU: 9000 Type:Physical HWaddr:02:8b:65:44:27:bd IPaddr:0.0.0.0 DDP: OFF SwLB: ON Vrf:0 Mcast Vrf:0 Flags:L3L2Vof QOS:0 Ref:9 RX device packets:8807 bytes:374638 errors:0 RX port packets:8806 errors:0 RX queue errors to lcore 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Fabric Interface: 0000:07:00.0 Status: UP Driver: 0000:07:00.0 RX packets:8806 bytes:374596 errors:0 TX packets:2 bytes:240 errors:0 Drops:0 TX queue packets:2 errors:0 TX port packets:2 errors:0 TX device packets:8 bytes:912 errors:0 inet acl f1 inet6 acl f1v6