Layer-7

circle-info

Layer-7 filtering enables RouterOS to inspect packet contents and identify applications, protocols, and specific traffic patterns for advanced filtering, QoS, and bandwidth management beyond simple port-based rules.

In WinBox you can configure layer-7 protocols in IP -> Firewall -> Layer7 Protocols, then use them in filter, mangle, or queue rules.

Layer-7 inspection allows identification of applications that use dynamic ports, encrypted traffic, or protocols that tunnel through standard ports.


Layer-7 fundamentals

How layer-7 detection works

Detection methods:

  • Regular expressions - Pattern matching against packet payload

  • Connection state tracking - First few packets of connections analyzed

  • Signature matching - Known application signatures and behaviors

  • Port-independent - Identifies protocols regardless of port used

Processing characteristics:

  • CPU intensive - Requires packet content inspection

  • Connection-based - Only first packets analyzed, then connection marked

  • Memory usage - Stores connection states and patterns

  • Performance impact - More complex patterns affect throughput

Common use cases:

  • Application blocking - Block P2P, social media, streaming

  • Bandwidth management - Limit specific application bandwidth

  • QoS policies - Prioritize business vs recreational traffic

  • Content filtering - Block unwanted content categories


Creating layer-7 protocols

Basic protocol definitions

Create layer-7 protocol patterns for common applications:

Messaging and communication

Gaming and entertainment


Application blocking with layer-7

Block social media platforms

Prevent access to social media during work hours:

Block P2P and file sharing

Prevent bandwidth abuse from P2P applications:

Block streaming during peak hours

Control bandwidth usage during busy periods:


Traffic shaping with layer-7

QoS based on applications

Prioritize or limit specific application traffic:

Bandwidth allocation per application


Advanced layer-7 techniques

Custom protocol detection

Create custom patterns for internal applications:

Multi-pattern protocol detection

Combine multiple patterns for accurate detection:

Layer-7 with time-based policies


Layer-7 with address lists

Dynamic application-based blocking

Combine layer-7 with dynamic address lists:

User-based application policies


Performance optimization

Optimize layer-7 processing

Connection state management


Monitoring layer-7 traffic

Monitor detected protocols

Debug layer-7 detection


Troubleshooting layer-7

Common issues and solutions

Performance troubleshooting


chevron-rightShow complete layer-7 content filtering setuphashtag

Layer-7 best practices

Design recommendations

  1. Start simple - Use basic patterns before complex regex

  2. Test thoroughly - Verify detection accuracy with real traffic

  3. Monitor performance - Watch CPU impact of layer-7 rules

  4. Use connection marking - Mark once, use many times

  5. Plan for scale - Consider impact with many concurrent connections

Security considerations

  1. Encrypted traffic - Layer-7 cannot inspect encrypted payloads

  2. Evasion techniques - Applications may bypass detection

  3. Privacy concerns - Deep packet inspection has privacy implications

  4. False positives - Overly broad patterns may block legitimate traffic

  5. Regular updates - Application patterns change over time

Performance guidelines

  1. Limit scope - Apply layer-7 only where needed

  2. Optimize patterns - Use efficient regex patterns

  3. Connection limits - Monitor connection table usage

  4. CPU monitoring - Watch for performance degradation

  5. Memory management - Layer-7 increases memory usage

Last updated

Was this helpful?