mangle
ip/firewall/mangle
Type: Directory
| Argument | Type | Description |
|---|---|---|
| all | switch | |
| static | switch | |
| dynamic | switch | |
| chain ( mandatory ) | enum | Specifies 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. |
| action | enum (accept | jump | return | log | passthrough | add-src-to-address-list | add-dst-to-address-list | sniff-tzsp | sniff-pc | drop | mark-packet | mark-connection | change-mss | change-dscp | strip-ipv4-options | change-ttl | mark-routing | set-priority | clear-df | fasttrack-connection | route) | Action to take if a packet is matched by the rule:
|
| jump-target | enum () | Name of the target chain to jump to. Applicable only if action=jump. |
| new-packet-mark | enum () | Sets the new packet mark value. |
| new-connection-mark | enum () | Sets the new connection mark value. |
| new-routing-mark | enum () | Sets a new routing-mark value. In RouterOS v7 routing mark must be created beforehand as a new Routing table |
| new-mss | alt { , enum (clamp-to-pmtu) { clamp-to-pmtu:65535 } , num [40 .. 65534] } | Sets a new MSS for a packet. Important: Clamp-to-pmtu feature sets the DF bit in the IP header to dynamically discover the PMTU of a path. The host sends all datagrams on that path with the DF bit set until it receives ICMP Destination Unreachable messages with a code meaning "fragmentation needed and DF set". Upon receipt of such a message, the source host reduces its assumed PMTU for the path. |
| new-dscp | enum (from-priority-to-high-3-bits | from-priority) | Sets the new DSCP value. |
| new-priority | alt { , enum (from-dscp | from-ingress | from-dscp-high-3-bits) { from-dscp:65536, from-ingress:65537, from-dscp-high-3-bits:65538 } , num [0 .. 63] } | ets a new priority for a packet. This can be the VLAN, WMM, DSCP or MPLS EXP priority Read more. This property can also be used to set an internal priority. |
| new-ttl | super { , enum (set | increment | decrement) { set:0, increment:1, decrement:2 } , :num [0 .. 255] } | Sets the new TTL value. |
| passthrough | bool { } | Whether to let the packet pass through to the next rule. |
| tcp-flags | super { !, , 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:
|
| p2p | super { ! , 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-state | super { ! , ubit (invalid, established, related, new, untracked) { invalid, established, related, new, untracked } } | Interprets the connection tracking analytics data for a particular packet:
|
| connection-nat-state | super { ! , ubit (srcnat, dstnat) { srcnat, dstnat } } | 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. |
| sniff-target | ipAddr { } | IP address to send the sniffed packet to. |
| sniff-target-port | num { } | Port to send the sniffed packet to. |
| sniff-id | num { } | ID of the sniffing session. |
| route-dst | ipAddr { } | Specifies the route destination for the route action. |
| tls-host | super { ! , 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-limit | super { ! , 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-protocol | super { ! , enum } | Layer7 filter name defined in the layer7 protocol menu. |
| realm | super { ! , num } | Matches the routing realm. IPv4 only. |
| protocol | super { ! , enum () { } } | Matches the particular IP protocol specified by protocol name or number. |
| src-address | super { ! , ipRange } | Matches packets whose source is equal to the specified IP or falls into the specified IP range. |
| dst-address | super { ! , ipRange } | Matches packets whose destination is equal to the specified IP or falls into the specified IP range. |
| fragment | super { 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. |
| psd | super { num , ,time , ,num , ,num } | Attempts to detect TCP and UDP scans. Parameters are in the following format:
|
| ipv4-options | super { 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.
|
| src-address-type | super { ! , ubit (unicast, local, broadcast, multicast, blackhole) { unicast, local, broadcast, multicast, blackhole } } | Matches the source address type:
|
| dst-address-type | super { ! , ubit (unicast, local, broadcast, multicast, blackhole) { unicast, local, broadcast, multicast, blackhole } } | Matches the destination address type:
|
| src-address-list | super { ! , enum } | Matches the source address of a packet against a user-defined address list. Supports only one list. |
| dst-address-list | super { ! , enum } | Matches the destination address of a packet against a user-defined address list. Supports only one list. |
| hotspot | multi { 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.
|
| address-list | enum () | 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-timeout | alt { 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
|
| ttl | super { 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-mark | super { ! , 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-type | super { ! , 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-bytes | super { 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-rate | super { ! , num , -num } | Allows capturing traffic based on the present speed of the connection. |
| routing-mark | super { ! , enum () { } } | Matches packets marked by the mangle facility with a particular routing mark. |
| in-interface | super { ! , iface_enum { } { } } | Interface the packet has entered the router. |
| out-interface | super { ! , iface_enum { } { } } | Interface the packet is leaving the router. |
| in-interface-list | super { ! , enum } | Set of interfaces defined in interface list. Works the same as in-interface. |
| out-interface-list | super { ! , enum } | Set of interfaces defined in interface list. Works the same as out-interface. |
| in-bridge-port | super { ! , 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-port | super { ! , 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-list | super { ! , enum } | Set of interfaces defined in interface list. Works the same as in-bridge-port. |
| out-bridge-port-list | super { ! , enum } | Set of interfaces defined in interface list. Works the same as out-bridge-port. |
| packet-mark | super { ! , 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-port | super { ! , multi { , , range [ .. 65535] } { , , range [ .. 65535] } } | List of source ports and ranges of source ports. Applicable only if the protocol is TCP or UDP. |
| dst-port | super { ! , multi { , , range [ .. 65535] } { , , range [ .. 65535] } } | List of destination port numbers or port number ranges. |
| port | super { ! , 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-options | super { ! , num [0 .. 255] , [ :range [ .. 255]] } | Matches ICMP type:code fields. |
| src-mac-address | super { ! , macAddr } | Matches the source MAC address of the packet. |
| content | super { ! , string } | Matches packets that contain the specified text. |
| ingress-priority | super { ! , num [0 .. 63] } | Matches the priority of an ingress packet. Priority may be derived from VLAN, WMM, DSCP, or MPLS EXP bit. |
| priority | super { ! , 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. |
| dscp | super { ! , num [0 .. 63] } | Matches the DSCP IP header field. |
| tos | super { ! , num [0 .. 255] , [ /num [0 .. 255]] } | |
| limit | super { ! , 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:
|
| dst-limit | super { 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
|
| time | super { ! , 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. |
| random | super { num [1 .. 99] } | Matches packets randomly with a given probability. |
| nth | super { ! , 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-mss | super { ! , num [0 .. 65535] , -num [0 .. 65535] } | Matches the TCP MSS value of an IP packet. |
| per-connection-classifier | super { ! , 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-size | super { ! , num [ .. 65535] , -num [ .. 65535] } | Matches packets of specified size or size range in bytes. |
| log | bool | 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. Allows logging of packets even if the action is not log, useful for debugging the firewall. |
| log-prefix | string | Adds the specified text at the beginning of every log message. Applicable if action=log or log=yes is configured. |
| ipsec-policy | super { 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:
|
ip/firewall/mangle/reset-counters
Type: Command
ip/firewall/mangle/reset-counters-all
Type: Command