I have 800 internet users and want to mark youtube and facebook connections to prioritize traffic.
I ran script for whatsapp, to fetch DNS cache and it worked very well…
But for youtube and facebook it did not.
I have CCR1016
The option i have it to use:
1-
Layer7 protocols
. I am affraid that CCR1016 wan’t be able to handle that much of matching processing power for 800 users. It shows internal ip addresses also
2-
DNS fetching technique. Did not show any ip address, while whatsapp for it does
3-
manual configuration for youtube in address list where mikrotik will put the ips dynamically. Did not show all ip addresses for youtube and facebook
2 and 3 failed.
i want to know:
the best method to do that for youtube and facebook
why DNS fetching technique did not work for youtube and facebook with whatsapp script below
TLS-host matcher is similarly resource-intensive as L7 matcher - it uses pattern matching as well, except that the pattern syntax is more limited (thus simpler to execute) and that it takes place only after parsing the packet for being a TLS Client Hello and for containing the server_host “extension” which the ****
tls-host
matcher looks into.
But neither L7 matching nor TLS-host matching should be a resource-killer if used carefully. In particular, I would suggest to use that rule to match only TCP packets from client to server which are not connection-marked yet and their size exceeds, say, 80 bytes, and connection-mark all of them, even those which do not match any TLS host.
When a https session is established, it looks as follows:
client server
------- SYN (empty) ----->
<--- SYN,ACK (empty) -----
------ ACK (empty) ------>
--- ACK (Client Hello) -->
So we need to let through the first two packets from the client, which are small as they carry no TCP payload, without matching them for TLS host. The first packet with a TCP payload contains either the TLS Client Hello (in case of https connections) or the http GET (in case of plaintext http connections), and this is the one on whose contents we base the decision on priority group. So a row of rules translating the match patterns to connection marks expressing priority categories must be applied on this first “significant” packet of each connection, and what is important, packets mathing none of the rules must get a connection mark as well. Due to that, any further packets belonging to these connections will not be matched on TLS host or L7 pattern either.
So the whole setup for marking Youtube connections for priority handling would look as follows:
/ip firewall mangle
add chain=prerouting action=mark-packet new-packet-mark=priorityA connection-mark=priorityA passthrough=no
... similar rules for lower priorities here ...
add chain=prerouting action=mark-packet new-packet-mark=priorityZ connection-mark=priorityZ passthrough=no
#so now any already connection-marked packets, which constitute the vast majority of traffic, have been let through, without inspecting even for protocol to save as much CPU as possible
#so what got up to this point must have no connection mark
add chain=prerouting action=accept packet-size=0-80
#skip further processing of all packets from LAN which are too small to be useful for TLS host matching; again, we're matching as little as possible to save CPU
add chain=prerouting protocol=tcp action=mark-connection in-interface-list=LAN tls-host=*youtube* new-connection-mark=priorityA passthrough=yes
...similar rules for lower priorities here...
add chain=prerouting protocol=tcp action=mark-connection in-interface-list=LAN new-connection-mark=priorityZ passthrough=yes
... additional rules changing the connection mark to a lower priority one for connections which have already transported more than X bytes of data may be placed here ...
... all the rules translating connection mark to packet mark may be repeated here to speed up connection establishment a tiny bit ...
Have you analyzed which part did not work? Use ****
/ip firewall mangle print stats
to see whether the rules with
tls-host
work.
My problem during testing was that my Android phone has established a TLS session to Youtube once forever, so I had to disconnect it from the network and connect it again to generate a new TLS session establishment. Check this too if you cannot see any matches on the ****
P.S. Method 2 did not work if i omitted the in and out interfaces. In this case for downstream traffic in-interface should be ether1-wan and for upstream traffic, out-interface should be ether1-wan for method 2 to work successfully.
I don’t know why…i have to investigate.