fbpx

How can layer7 be applied in MikroTik?

The implementation of Layer 7 (L7) in MikroTik RouterOS allows you to identify and classify network traffic based on the actual content of the packets, rather than just the IP address or port.

This is useful for filtering, prioritizing, or limiting specific traffic, such as blocking specific websites, prioritizing VoIP traffic, or limiting bandwidth for streaming applications. Here's how to configure Layer 7 rules in MikroTik RouterOS:

1. Define a Layer 7 Pattern

First, you must create a Layer 7 pattern that RouterOS will use to identify specific traffic. This is done in the “IP” menu → “Firewall” and then in the “Layer7 Protocols” tab. Here you can define a new L7 pattern.

/ip firewall layer7-protocol
add name="nombre_protocolo_L7" regexp="expresión_regular"

For example, to identify HTTP traffic that contains the word “facebook” in the packet header, you could use a regular expression like this:

add name="facebook" regexp="facebook.com"

2. Create a Firewall Rule Using the L7 Pattern

After defining the L7 pattern, you can use it in a firewall rule to filter or prioritize traffic. This is done in the “IP” → “Firewall” menu and then in the “Filter Rules” or “Mangle” tab depending on what you want to achieve.

  • To block traffic:
/ip firewall filter
add action=drop chain=forward layer7-protocol=nombre_protocolo_L7
  • To flag traffic and then apply specific policies (such as rate limiting or prioritization):
/ip firewall mangle
add action=mark-packet chain=forward layer7-protocol=nombre_protocolo_L7 new-packet-mark=marcado_paquete

Important considerations

  • Performance: Heavy use of L7 rules can significantly increase the load on the device's CPU, as it requires inspecting the contents of packets. It is important to monitor router performance after implementing these rules, especially on high-traffic networks.
  • Accuracy: Regular expressions must be written carefully to ensure that only the desired traffic is captured. A poorly defined regular expression can lead to false positives or negatives.
  • Encryption: Today, much Internet traffic uses encryption (such as HTTPS), which can limit the effectiveness of Layer 7-based rules in identifying the specific content of the traffic. For encrypted traffic, consider alternative identification and control methods, such as blocking or prioritization based on IP addresses, ports, or SNI TLS connections.

The Layer 7 configuration in MikroTik RouterOS is a powerful tool for advanced traffic management, allowing network administrators to implement sophisticated network policies based on the actual content of data packets.

There are no tags for this post.
Did this content help you?
Facebook
Twitter
LinkedIn
WhatsApp
Telegram

Other documents in this category

Leave your comment

Your email address will not be published. Required fields are marked with *

Tutorials available at MikroLABs

No Courses Found!

DISCOUNT CODE

AN24-LIB

applies to MikroTik books and book packs

Days
Hours
Minutes
Seconds

Introduction to
OSPF - BGP - MPLS

Sign up for this Free course

MAE-RAV-ROS-240118
Days
Hours
Minutes
Seconds

Sign up for this Free course

MAS-ROS-240111

Promo for Three Kings Day!

KINGS24

15%

all the products

MikroTik courses
Academy courses
MikroTik books

Take advantage of the Three Kings Day discount code!

* promotion valid until Sunday January 7, 2024
** the code (KINGS24) applies to shopping cart
*** buy your course now and take it until March 31, 2024

New Year's Eve Promo!

NY24

20%

all the products

MikroTik courses
Academy courses
MikroTik books

Take advantage of the New Year's Eve discount code!

* promotion valid until Monday, January 1, 2024
** the code (NY24) applies to shopping cart
*** buy your course now and take it until March 31, 2024

Christmas discounts!

XMAS23

30%

all the products

MikroTik courses
Academy courses
MikroTik books

Take advantage of the discount code for Christmas!!!

**codes are applied in the shopping cart
Promo valid until Monday December 25, 2023

CYBER WEEK DISCOUNTS

CW23-MK

17%

all MikroTik OnLine courses

CW23-AX

30%

all Academy courses

CW23-LIB

25%

all MikroTik Books and Book Packs

Take advantage of the discount codes for Cyber ​​Week!!!

**codes are applied in the shopping cart
Promo valid until Sunday December 3, 2023

BLACK FRIDAY DISCOUNTS

BF23-MX

22%

all MikroTik OnLine courses

BF23-AX

35%

all Academy courses

BF23-LIB

30%

all MikroTik Books and Book Packs

Take advantage of the discount codes for Black Friday!!!

**Codes are applied in the shopping cart

codes are applied in the shopping cart
valid until Sunday November 26, 2023

Days
Hours
Minutes
Seconds

Sign up for this Free course

MAE-VPN-SET-231115

Halloween promo

Take advantage of discount codes for Halloween.

Codes are applied in the shopping cart

HW23-MK

11% discount on all MikroTik OnLine courses

11%

HW23-AX

30% discount on all Academy courses

30%

HW23-LIB

25% discount on all MikroTik Books and Book Packs

25%

Register and participate in the free course Introduction to Advanced Routing with MikroTik (MAE-RAV-ROS)

Today (Wednesday) October 11, 2023
7pm to 11pm (Colombia, Ecuador, Peru)

MAE-RAV-ROS-231011