Community discussions

MikroTik App
 
User avatar
shahriyora
just joined
Topic Author
Posts: 7
Joined: Thu Apr 23, 2020 11:00 pm

Mangle doesn't mark website traffic from Layer 7 Protocol entry

Fri Apr 24, 2020 5:32 pm

Hi everyone! A newbie here.

I have a hAP ac^2, upgraded to the latest firmware 6.46.5, recently reset to factory defaults, with default firewall rules except disabled fasttrack. I need to limit the incoming bandwidth of certain websites (including fast.com for testing purposes) for a range of IP addresses.
For this I've made two Mangle rules to mark all connections and packets from a Layer 7 Protocol entry, where I've described the website addresses. Then I made a Simple Queue to limit the incoming rate of marked packets for a specified range of addresses.

This doesn't work.

The queue only registers some 10KB worth of incoming data within ~2 seconds after I start a speed test at fast.com, then shows nothing at all. Mangle rule packet counter does increment, but not to the rate of incoming traffic flow from these websites, even when there are no any other traffic. But if I remove the Layer 7 Protocol option from my Mangle rule, thus effectively marking all incoming connections and packets, then the packet counter rate increases, and the queue starts working.

Here's the regexp for Layer7 going under name "limit":
^..+\.(youtube.com|googlevideo.com|facebook.com|fbcdn.net|fast.com).*$

Here are my Mangle rules:
Flags: X - disabled, I - invalid, D - dynamic 
 0  D ;;; special dummy rule to show fasttrack counters
      chain=prerouting action=passthrough 
 1  D ;;; special dummy rule to show fasttrack counters
      chain=forward action=passthrough 
 2  D ;;; special dummy rule to show fasttrack counters
      chain=postrouting action=passthrough 
 3    chain=forward action=mark-connection new-connection-mark=limc passthrough=yes layer7-protocol=limit log=no log-prefix="" 
 4    chain=forward action=mark-packet new-packet-mark=lim passthrough=no connection-mark=limc log=no log-prefix="" 

Here's my Simple Queue rule:
Flags: X - disabled, I - invalid, D - dynamic 
 0    name="limitrate" target=192.168.88.2/31 parent=none packet-marks=lim priority=8/8 queue=pcq-upload-default/pcq-download-default limit-at=0/0 
      max-limit=0/1M burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s bucket-size=0.1/0.1

And here are my Firewall Filter rules:
Flags: X - disabled, I - invalid, D - dynamic 
 0  D ;;; special dummy rule to show fasttrack counters
      chain=forward action=passthrough 

 1    ;;; defconf: accept established,related,untracked
      chain=input action=accept connection-state=established,related,untracked 

 2    ;;; defconf: drop invalid
      chain=input action=drop connection-state=invalid 

 3    ;;; defconf: accept ICMP
      chain=input action=accept protocol=icmp 

 4    ;;; defconf: accept to local loopback (for CAPsMAN)
      chain=input action=accept dst-address=127.0.0.1 

 5    ;;; defconf: drop all not coming from LAN
      chain=input action=drop in-interface-list=!LAN 

 6    ;;; defconf: accept in ipsec policy
      chain=forward action=accept ipsec-policy=in,ipsec 

 7    ;;; defconf: accept out ipsec policy
      chain=forward action=accept ipsec-policy=out,ipsec 

 8 X  ;;; defconf: fasttrack
      chain=forward action=fasttrack-connection connection-state=established,related log=no log-prefix="" 

 9    ;;; defconf: accept established,related, untracked
      chain=forward action=accept connection-state=established,related,untracked 

10    ;;; defconf: drop invalid
      chain=forward action=drop connection-state=invalid 

11    ;;; defconf: drop all from WAN not DSTNATed
      chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN

Sorry it got so lengthy. I'd really appreciate if you could check and shed some light on what's going wrong here. Maybe there are some prerequisites to be fulfilled to get this working I'm not aware of? Advices on Firewall Filters are also appreciated. Thanks.
 
User avatar
shahriyora
just joined
Topic Author
Posts: 7
Joined: Thu Apr 23, 2020 11:00 pm

Re: Mangle doesn't mark website traffic from Layer 7 Protocol entry

Wed Apr 29, 2020 6:31 pm

Guys, could you please check?

The issue still unresolved :(
 
tdw
Forum Guru
Forum Guru
Posts: 1855
Joined: Sat May 05, 2018 11:55 am

Re: Mangle doesn't mark website traffic from Layer 7 Protocol entry

Wed Apr 29, 2020 7:26 pm

From the wiki "Warning: Queues (except Queue Trees parented to interfaces), firewall filter and mangle rules will not be applied for FastTracked traffic." so try disabling the fasttrack rule.
 
User avatar
shahriyora
just joined
Topic Author
Posts: 7
Joined: Thu Apr 23, 2020 11:00 pm

Re: Mangle doesn't mark website traffic from Layer 7 Protocol entry

Thu Apr 30, 2020 4:00 pm

From the wiki "Warning: Queues (except Queue Trees parented to interfaces), firewall filter and mangle rules will not be applied for FastTracked traffic." so try disabling the fasttrack rule.
Thanks for your reply.

Disabling the FastTrack was the first thing I did before configuring Mangle and Queues. I think I've mentioned that in my post. Sorry it got so big and hard to read. I tried to describe the issue thoroughly and in detail.

It doesn't have to be exclusively this way. Maybe you could point me to a nice and informative guide about per-website bandwidth limiting, held in high standards. That'd also do.

Thanks for your time and assistance.
 
plisken
Forum Guru
Forum Guru
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Mangle doesn't mark website traffic from Layer 7 Protocol entry

Thu Apr 30, 2020 4:17 pm

Layer 7 works on http but not on https because the data is encrypted.
This is the reason that layer7 protocol fails.
 
User avatar
shahriyora
just joined
Topic Author
Posts: 7
Joined: Thu Apr 23, 2020 11:00 pm

Re: Mangle doesn't mark website traffic from Layer 7 Protocol entry

Thu Apr 30, 2020 11:19 pm

Layer 7 works on http but not on https because the data is encrypted.
This is the reason that layer7 protocol fails.
Thanks for your reply.

I had the exact same configuration at my previous workplace's CCR1009-7G-1C-1S+ to control incoming YouTube bandwidth, and it worked as good as intended. I don't have any access to that router anymore unfortunately. But I remember it had more firewall rules.

Anyhow, to elaborate on your suspicion, tomorrow I'll try a workaround by adding the websites' IP addresses to the list through a prerouting mangle rule, and then marking all connections and packets from these IPs.
 
User avatar
shahriyora
just joined
Topic Author
Posts: 7
Joined: Thu Apr 23, 2020 11:00 pm

Re: Mangle doesn't mark website traffic from Layer 7 Protocol entry

Sat May 02, 2020 1:37 pm

Okay, this is weird.

My exact original configuration I've described in the first post now began to work. The only difference now is that those dummy fasttrack mangle rules are gone now. The problem seems to be because of that.

I don't know how they are gone now. I tried removing, disabling or at least replacing them myself, but an error message appeared saying I can't touch these predefined rules, or something like that. I rebooted the router several times after turning off the fasttrack connection firewall rule, and several times more while trying to get my configuration to work. The last time I left configuring, those dummy rules were present, but today when I got back to it, they were gone.

Concluding, the dummy fasttrack mangle rules are a problem for packet marking.

I'd consider this issue solved if someone could show an explicit way to disable those Mangle special fasttrack dummy rules.

Thank you all for assistance.
 
plisken
Forum Guru
Forum Guru
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Mangle doesn't mark website traffic from Layer 7 Protocol entry  [SOLVED]

Sun May 03, 2020 4:16 pm

Look to this topic on my website and look to the movie how remove fasttrack from your router.
In dutch but the movie is verry clear.
https://www.wirelessinfo.be/verwijder-fasttrack/

I hope to helped you.
 
User avatar
shahriyora
just joined
Topic Author
Posts: 7
Joined: Thu Apr 23, 2020 11:00 pm

Re: Mangle doesn't mark website traffic from Layer 7 Protocol entry

Mon May 04, 2020 1:13 pm

Look to this topic on my website and look to the movie how remove fasttrack from your router.
In dutch but the movie is verry clear.
https://www.wirelessinfo.be/verwijder-fasttrack/

I hope to helped you.
Thank you for your help. It's a very nice article and video. Pity I don't understand what you're saying exactly, but I can see what you're doing.

One last question, a bit off-topic. From the performance point of view, is it better to mark connections and packets by using Address Lists, or by using Layer 7 Protocol rule I described in the first post? It feels like Address List is less heavy on CPU load. Am I right?
 
plisken
Forum Guru
Forum Guru
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Mangle doesn't mark website traffic from Layer 7 Protocol entry

Mon May 04, 2020 5:15 pm

The best way is to work with adress-lists.
Greatings

Who is online

Users browsing this forum: Majestic-12 [Bot] and 64 guests