Skip to main content
Version: current

filter


ip/firewall/filter

Type: Directory

ArgumentTypeDescription
allswitch
staticswitch
dynamicswitch
chain ( mandatory )enumSpecifies to which chain the rule will be added. If the input does not match the name of an already defined chain, a new chain will be created.
actionenum (accept | jump | return | log | passthrough | add-src-to-address-list | add-dst-to-address-list | drop | reject | tarpit | fasttrack-connection)

Action to take if a packet is matched by the rule:

  • accept - accept the packet. A packet is not passed to the next firewall rule.
  • add-dst-to-address-list - add the destination address to the address list specified by the address-list parameter.
  • add-src-to-address-list - add the source address to the address list specified by the address-list parameter.
  • jump - jump to the user-defined chain specified by the value of the jump-target parameter.
  • log - add a message to the system log containing the following data: in-interface, out-interface, src-mac, protocol, src-ip:port->dst-ip:port, and length of the packet. After a packet is matched it is passed to the next rule in the list, similar to passthrough.
  • passthrough - if a packet is matched by the rule, increase the counter and go to the next rule (useful for statistics).
  • return - passes control back to the chain from where the jump took place.
  • drop - drop the packet.
  • reject - reject the packet and send an ICMP response.
  • tarpit - capture and hold the connection open.
  • fasttrack-connection - fasttrack the connection.
jump-targetenum ()Name of the target chain to jump to. Applicable only if action=jump.
reject-withenum (icmp-network-unreachable | icmp-host-unreachable | icmp-protocol-unreachable | icmp-port-unreachable | icmp-net-prohibited | icmp-host-prohibited | tcp-reset | icmp-admin-prohibited)

Specifies the ICMP error to be sent back if the packet is rejected. Applicable if action=reject.

  • icmp-no-route - sends an ICMP address no-route message. ICMP type 1, code 0
  • icmp-admin-prohibited - sends an ICMP address prohibited message. ICMP type 1, code 1
  • icmp-not-neighbour - sends an ICMP address not-member message. ICMP type 1, code 2
  • icmp-address-unreachable - sends an ICMP address unreachable message. ICMP type 1, code 3
  • icmp-port-unreachable - sends an ICMP port unreachable message. ICMP type 1, code 4
  • tcp-reset - sends an ICMP message resetting a TCP connection. ICMP type 1, code 6
  • icmp-err-src-routing-header - sends an ICMP Error in Source Routing Header message. ICMP type 1, code 7
  • icmp-headers-too-long - sends an ICMP Headers too long message. ICMP type 1, code 8
hw-offload (syscap=crs_prestera)bool { }Enables or disables FastTrack hardware offloading. Supported only on switches with FastTrack offloading and when action=fasttrack-connection is set.
tcp-flagssuper { !, , multi { array-id, array-id, super { ! , enum (fin | syn | rst | psh | ack | urg | ece | cwr) { fin:0, syn:1, rst:2, psh:3, ack:4, urg:5, ece:6, cwr:7 } } { ! , enum (fin | syn | rst | psh | ack | urg | ece | cwr) { fin:0, syn:1, rst:2, psh:3, ack:4, urg:5, ece:6, cwr:7 } } } { array-id, array-id, super { ! , enum (fin | syn | rst | psh | ack | urg | ece | cwr) { fin:0, syn:1, rst:2, psh:3, ack:4, urg:5, ece:6, cwr:7 } } { ! , enum (fin | syn | rst | psh | ack | urg | ece | cwr) { fin:0, syn:1, rst:2, psh:3, ack:4, urg:5, ece:6, cwr:7 } } } }

Matches the specified TCP flags:

  • ack - acknowledging data.
  • cwr - congestion window reduced.
  • ece - ECN-echo flag (explicit congestion notification).
  • fin - close connection.
  • psh - push function.
  • rst - drop connection.
  • syn - new connection.
  • urg - urgent data.
p2psuper { ! , enum (fasttrack | gnutella | direct-connect | edonkey | bit-torrent | blubster | soulseek | winmx | warez | all-p2p) { fasttrack:0x01, gnutella:0x02, direct-connect:0x03, edonkey:0x04, bit-torrent:0x05, blubster:0x06, soulseek:0x07, winmx:0x08, warez:0x09, all-p2p:0xFF } }Matches some unencrypted P2P protocols. Deprecated since mostly everything is encrypted and requires deep packet inspection to identify. IPv4 only.
connection-statesuper { ! , ubit (invalid, established, related, new, untracked) { invalid, established, related, new, untracked } }

Interprets the connection tracking analytics data for a particular packet:

  • established - a packet that belongs to an existing connection.
  • invalid - a packet that does not have a determined state in connection tracking (usually severe out-of-order packets, packets with wrong sequence/ack number, or in case of resource over usage on the router). An invalid packet will not participate in NAT (as only connection-state=new packets do), and will still contain the original source IP address when routed. You should drop all connection-state=invalid packets in the firewall filter forward and input chains.
  • new - the packet has started a new connection or is otherwise associated with a connection that has not seen packets in both directions.
  • related - a packet that is related to, but not part of an existing connection, such as ICMP errors or a packet that begins an FTP data connection.
  • untracked - a packet that was set to bypass connection tracking in firewall RAW tables.
connection-nat-statesuper { ! , ubit (srcnat, dstnat, ein-snat, ein-dnat) { srcnat, dstnat, ein-snat, ein-dnat } }Matches connections that are source-natted, destination-natted, or both. The connection-state=related connections' connection-nat-state is determined by the direction of the first packet, and if connection tracking needs to use dst-nat to deliver this connection to the same hosts as the main connection, it will be in connection-nat-state=dstnat even if there are no dst-nat rules at all.
tls-hostsuper { ! , string }Matches HTTPS traffic based on TLS SNI hostname. Accepts GLOB syntax for wildcard matching. The matcher will not be able to match the hostname if the TLS handshake frame is fragmented into multiple TCP segments.
connection-limitsuper { ! , num , ,num }Matches connections per address or address block after a given value is reached. You should use this together with connection-state=new and/or with tcp-flags=syn because the matcher is very resource-intensive.
layer7-protocolsuper { ! , enum }Layer7 filter name defined in the layer7 protocol menu.
realmsuper { ! , num }Matches the routing realm. IPv4 only.
protocolsuper { ! , enum () { } }Matches the particular IP protocol specified by protocol name or number.
src-addresssuper { ! , ipRange }Matches packets whose source is equal to the specified IP or falls into the specified IP range.
dst-addresssuper { ! , ipRange }Matches packets whose destination is equal to the specified IP or falls into the specified IP range.
fragmentsuper { bool }Matches fragmented packets. The first (starting) fragment does not count. If connection tracking is enabled there will be no fragments as the system automatically assembles every packet. IPv4 only.
psdsuper { num , ,time , ,num , ,num }

Attempts to detect TCP and UDP scans. Parameters are in the following format: WeightThreshold, DelayThreshold, LowPortWeight, HighPortWeight.

  • WeightThreshold - total weight of the latest TCP/UDP packets with different destination ports coming from the same host to be treated as port scan sequence.
  • DelayThreshold - delay for the packets with different destination ports coming from the same host to be treated as possible port scan subsequence.
  • LowPortWeight - the weight of the packets with privileged destination port (<1024).
  • HighPortWeight - the weight of the packets with a non-privileged destination port. IPv4 only.
ipv4-optionssuper { enum (strict-source-routing | loose-source-routing | no-source-routing | record-route | no-record-route | timestamp | no-timestamp | router-alert | no-router-alert | any | none) { strict-source-routing:0x1, loose-source-routing:0x2, no-source-routing:0x4, record-route:0x8, no-record-route:0x10, timestamp:0x20, no-timestamp:0x40, router-alert:0x80, no-router-alert:0x100, any:0x200, none:0x400 } }

Matches IPv4 header options.

  • any - matches packets with at least one of the IPv4 options.
  • loose-source-routing - matches packets with a loose source routing option.
  • no-record-route - matches packets with no record route option.
  • no-router-alert - matches packets with no router alert option.
  • no-source-routing - matches packets with no source routing option.
  • no-timestamp - matches packets with no timestamp option.
  • record-route - matches packets with record route option.
  • router-alert - matches packets with router alert option.
  • strict-source-routing - matches packets with a strict source routing option.
  • timestamp - matches packets with a timestamp. IPv4 only.
src-address-typesuper { ! , ubit (unicast, local, broadcast, multicast, blackhole) { unicast, local, broadcast, multicast, blackhole } }

Matches the source address type:

  • unicast - an IP address used for point-to-point transmission.
  • local - the address is assigned to one of the router's interfaces.
  • broadcast - a packet is sent to all devices in the subnet.
  • multicast - a packet is forwarded to a defined group of devices.
dst-address-typesuper { ! , ubit (unicast, local, broadcast, multicast, blackhole) { unicast, local, broadcast, multicast, blackhole } }

Matches the destination address type:

  • unicast - an IP address used for point-to-point transmission.
  • local - the destination address is assigned to one of the router's interfaces.
  • broadcast - a packet is sent to all devices in a subnet.
  • multicast - a packet is forwarded to a defined group of devices.
src-address-listsuper { ! , enum }Matches the source address of a packet against a user-defined address list. Supports only one list.
dst-address-listsuper { ! , enum }Matches the destination address of a packet against a user-defined address list. Supports only one list.
hotspotmulti { array-id, array-id, super { ! , enum (from-client | auth | local-dst | to-client | http) { from-client:0, auth:1, local-dst:2, to-client:3, http:4 } } { ! , enum (from-client | auth | local-dst | to-client | http) { from-client:0, auth:1, local-dst:2, to-client:3, http:4 } } }

Matches packets received from HotSpot clients against various HotSpot matchers.

  • auth - matches authenticated HotSpot client packets.
  • from-client - matches packets coming from the HotSpot client.
  • http - matches HTTP requests sent to the HotSpot server.
  • local-dst - matches packets destined to the HotSpot server.
  • to-client - matches packets sent to the HotSpot client. IPv4 only.
address-listenum ()Name of the address list to be used. Applicable if the action is add-dst-to-address-list or add-src-to-address-list.
address-list-timeoutalt { enum (none-dynamic | none-static) { none-dynamic:0, none-static:0xffffffff } , time [ .. 21474836] , }

Time interval after which the address will be removed from the address list specified by the address-list parameter. Used in conjunction with add-dst-to-address-list or add-src-to-address-list actions.

  • none-dynamic (00:00:00) will leave the address in the address list till reboot.
  • none-static will leave the address in the address list forever and will be included in the configuration export/backup.
ttlsuper { enum (equal | not-equal | less-than | greater-than) { equal:0, not-equal:1, less-than:2, greater-than:3 } , :num [0 .. 255] }Matches the packet TTL value. IPv4 only.
connection-marksuper { ! , enum }Matches packets marked by the mangle facility with a particular connection mark. If no-mark is set, the rule will match any unmarked connection.
connection-typesuper { ! , enum (ftp | pptp | h323 | sip | irc | quake3 | tftp) { ftp:0, pptp:1, h323:2, sip:3, irc:4, quake3:5, tftp:6 } }Matches packets from related connections based on information from their connection tracking helpers. A relevant connection helper must be enabled under /ip/firewall/service-port.
connection-bytessuper { num , -num }Matches packets only if a given amount of bytes has been transferred through the particular connection. 0 means infinity, for example connection-bytes=2000000-0 means that the rule matches if more than 2MB has been transferred through the relevant connection.
connection-ratesuper { ! , num , -num }Allows capturing traffic based on the present speed of the connection.
routing-marksuper { ! , enum () { } }Matches packets marked by the mangle facility with a particular routing mark.
in-interfacesuper { ! , iface_enum { } { } }Interface the packet has entered the router.
out-interfacesuper { ! , iface_enum { } { } }Interface the packet is leaving the router.
in-interface-listsuper { ! , enum }Set of interfaces defined in interface list. Works the same as in-interface.
out-interface-listsuper { ! , enum }Set of interfaces defined in interface list. Works the same as out-interface.
in-bridge-portsuper { ! , iface_enum { } { } }Actual interface the packet has entered the router if the incoming interface is a bridge. Works only if use-ip-firewall is enabled in bridge settings.
out-bridge-portsuper { ! , iface_enum { } { } }Actual interface the packet leaves the router if the outgoing interface is a bridge. Works only if use-ip-firewall is enabled in bridge settings.
in-bridge-port-listsuper { ! , enum }Set of interfaces defined in interface list. Works the same as in-bridge-port.
out-bridge-port-listsuper { ! , enum }Set of interfaces defined in interface list. Works the same as out-bridge-port.
packet-marksuper { ! , enum }Matches packets marked by the mangle facility with a particular packet mark. If no-mark is set, the rule will match any unmarked packet.
src-portsuper { ! , multi { , , range [ .. 65535] } { , , range [ .. 65535] } }List of source ports and ranges of source ports. Applicable only if the protocol is TCP or UDP.
dst-portsuper { ! , multi { , , range [ .. 65535] } { , , range [ .. 65535] } }List of destination port numbers or port number ranges.
portsuper { ! , multi { , , range [ .. 65535] } { , , range [ .. 65535] } }Matches if any (source or destination) port matches the specified list of ports or port ranges. Applicable only if protocol is TCP or UDP.
icmp-optionssuper { ! , num [0 .. 255] , [ :range [ .. 255]] }Matches ICMP type:code fields.
src-mac-addresssuper { ! , macAddr }Matches the source MAC address of the packet.
contentsuper { ! , string }Matches packets that contain the specified text.
ingress-prioritysuper { ! , num [0 .. 63] }Matches the priority of an ingress packet. Priority may be derived from VLAN, WMM, DSCP, or MPLS EXP bit.
prioritysuper { ! , num [0 .. 63] }Matches the packet's priority after a new priority has been set. Priority may be derived from VLAN, WMM, DSCP, MPLS EXP bit, or from the priority set by using the set-priority action.
dscpsuper { ! , num [0 .. 63] }Matches the DSCP IP header field.
tossuper { ! , num [0 .. 255] , [ /num [0 .. 255]] }
limitsuper { ! , num [1 .. 32000000000] , [ /time [1 .. ]] , ,num [ .. 2000000000] , [ :enum (packet | bit) { packet:0, bit:1 }] }

Matches packets up to a limited rate (packet rate or bit rate). A rule with this matcher will match until this limit is reached. Parameters are written in the following format: rate[/time],burst:mode.

  • rate - packet or bit count per time interval to match.
  • time - specifies the time interval in which the packet or bit rate cannot be exceeded (optional, 1s will be used if not specified).
  • burst - initial number of packets or bits to match: this number gets recharged every 10ms so burst should be at least 1/100 of a rate per second.
  • mode - packet or bit mode.
dst-limitsuper { num , [ /time] , ,num , ,enum (dst-address | dst-address-and-port | src-address | src-and-dst-addresses | addresses-and-dst-port) { dst-address:1, dst-address-and-port:3, src-address:4, src-and-dst-addresses:5, addresses-and-dst-port:7 } , [ /time] }

Matches packets until a given rate is exceeded. Rate is defined as packets per time interval. As opposed to the limit matcher, every flow has its own limit. Flow is defined by a mode parameter. Parameters are written in the following format: rate[/time],burst,mode[/expire].

  • rate - packet count per time interval per-flow to match.
  • time - specifies the time interval in which the packet count rate per flow cannot be exceeded (optional, 1s will be used if not specified).
  • burst - initial number of packets per flow to match: this number gets recharged by one every time/rate, up to this number.
  • mode - specifies what unique fields define flow (src-address, dst-address, src-and-dst-address, dst-address-and-port, addresses-and-dst-port).
  • expire - specifies interval after which flow with no packets will be allowed to be deleted (optional).
timesuper { ! , time [0 .. 86400] , -time [0 .. 86400] , ,ubit (sun, mon, tue, wed, thu, fri, sat) { sun, mon, tue, wed, thu, fri, sat } }Creates a filter based on the packets' arrival time and date or, for locally generated packets, departure time and date. The matcher takes into account the time and timezone configured on the router.
randomsuper { num [1 .. 99] }Matches packets randomly with a given probability.
nthsuper { ! , num [1 .. ] , [ ,num [1 .. ]] }Matches every nth packet: nth=2,1 will match every first packet of 2, hence, 50% of all the traffic matched by the rule.
tcp-msssuper { ! , num [0 .. 65535] , -num [0 .. 65535] }Matches the TCP MSS value of an IP packet.
per-connection-classifiersuper { ! , enum (src-address | dst-address | both-addresses | src-port | src-address-and-port | dst-port | dst-address-and-port | both-ports | both-addresses-and-ports) { src-address:1, dst-address:2, both-addresses:3, src-port:4, src-address-and-port:5, dst-port:8, dst-address-and-port:10, both-ports:12, both-addresses-and-ports:15 } , :num [1 .. ] , /num [0 .. ] }PCC matcher allows dividing traffic into equal streams with the ability to keep packets with a specific set of options in one particular stream.
packet-sizesuper { ! , num [ .. 65535] , -num [ .. 65535] }Matches packets of specified size or size range in bytes.
logboolAdd a message to the system log containing the following data: in-interface, out-interface, src-mac, protocol, src-ip:port->dst-ip:port, and length of the packet. Allows logging of packets even if the action is not log, useful for debugging the firewall.
log-prefixstringAdds the specified text at the beginning of every log message. Applicable if action=log or log=yes is configured.
ipsec-policysuper { enum (in | out) { in:0, out:1 } , ,enum (none | ipsec) { none:0, ipsec:1 } }

Matches the policy used by IPsec. Value is written in the following format: direction, policy.

  • in - valid in the PREROUTING, INPUT, and FORWARD chains.
  • out - valid in the POSTROUTING, OUTPUT, and FORWARD chains.
  • ipsec - matches if the packet is subject to IPsec processing.
  • none - matches packets that are not subject to IPsec processing.

ip/firewall/filter/reset-counters

Type: Command

ip/firewall/filter/reset-counters-all

Type: Command