From MikroTik Wiki
< Manual:IP‎ | Firewall
Revision as of 16:14, 8 December 2009 by Marisb (talk | contribs)
Jump to: navigation, search

Applies to RouterOS: v3, v4


layer7-protocol is a method of searching for patterns in ICMP/TCP/UDP streams.

L7 matcher is collecting first 10 packets of connection or first 2KB of connection and searches for pattern in collected data. If pattern is not found in collected data, matcher is not inspecting further. Allocated memory is freed and protocol is considered as unknown. You should take into account that a lot of connections will significantly increase memory usage. To avoid it add regular firewall matchers to reduce amount of data passed to layer-7 filters.

Additional requirement is that layer7 matcher must see both directions of traffic (incoming and outgoing). To satisfy this requirement l7 rules should be set in forward chain. If rule is set in input/prerouting chain then the same rule must be set also in output/postrouting chain, otherwise collected data may not be complete resulting in incorrectly matched pattern.

L7 patterns found in l7-filter project page and in [1] are compatible with RouterOS.
You can also download a script with a list of common protocols here (only for RouterOS v3), just run Import command with this file.


Sub-menu: /ip firewall layer7-protocol

Property Description
name (string; Default: ) Descriptive name of l7 pattern used by configuration in firewall rules. See example >>.
regexp (string; Default: ) POSIX compliant regular expression used to match pattern.


First, add Regexp strings to the protocols menu, to define strings you will be looking for. /ip firewall layer7-protocol add Then, use the defined protocols in firewall: /ip firewall filter add layer7-protocol

[Back to Content]