/ip firewall layer7-protocol
add name=torrentsites regexp="^.*(get|GET).+(torrent|\
thepiratebay|isohunt|entertane|demonoid|btjunkie|mininova|flixflux|\
torrentz|vertor|h33t|btscene|bitunity|bittoxic|thunderbytes|\
entertane|zoozle|vcdq|bitnova|bitsoup|meganova|fulldls|btbot|\
flixflux|seedpeer|fenopy|gpirate|commonbits).*\$\
"
in "ip firewall layer7-protocols".name=torrentsites
regexp:
^.*(get|GET).+(torrent|
thepiratebay|isohunt|entertane|demonoid|btjunkie|mininova|flixflux|
torrentz|vertor|h33t|btscene|bitunity|bittoxic|thunderbytes|
entertane|zoozle|vcdq|bitnova|bitsoup|meganova|fulldls|btbot|
flixflux|seedpeer|fenopy|gpirate|commonbits).*$
but 3 times (with the 3 src-addresses 192.168.1.0, 192.168.2.0 and 192.168.3.0)add chain=forward src-address=192.168.1.0/24 layer7-protocol=torrentsites action=drop comment=torrentsites
add chain=forward src-address=192.168.1.0/24 protocol=17 dst-port=53 layer7-protocol=torrentsites action=drop comment=dropDNS
add chain=forward src-address=192.168.1.0/24 content=torrent action=drop comment=keyword_drop
add chain=forward src-address=192.168.1.0/24 content=tracker action=drop comment=trackers_drop
add chain=forward src-address=192.168.1.0/24 content=getpeers action=drop comment=get_peers_drop
add chain=forward src-address=192.168.1.0/24 content=info_hash action=drop comment=info_hash_drop
add chain=forward src-address=192.168.1.0/24 content=announce_peers action=drop comment=announce_peers_drop
...
add chain=forward src-address=192.168.1.0/24 p2p=all-p2p action=drop comment=p2p_drop
> ip firewall filter print
Flags: X - disabled, I - invalid, D - dynamic
0 ;;; TCP Connection Limits
chain=forward action=drop tcp-flags=syn protocol=tcp
src-address=1.......1.0/24 connection-limit=101,32
1 ;;; TCP Connection Limits
chain=forward action=drop tcp-flags=syn protocol=tcp
src-address=1.......2.0/24 connection-limit=101,32
2 ;;; TCP Connection Limits
chain=forward action=drop tcp-flags=syn protocol=tcp
src-address=1.......3.0/24 connection-limit=101,32
3 ;;; UDP Connection Limits
chain=forward action=drop protocol=udp src-address=1.......1.0/24
connection-limit=71,32
4 ;;; UDP Connection Limits
chain=forward action=drop protocol=udp src-address=1.......2.0/24
connection-limit=71,32
5 ;;; UDP Connection Limits
chain=forward action=drop protocol=udp src-address=1.......3.0/24
connection-limit=71,32
6 ;;; Accept established connections
chain=input action=accept connection-state=established
7 ;;; Accept related connections
chain=input action=accept connection-state=related
8 ;;; Drop invalid connections
chain=input action=drop connection-state=invalid
9 ;;; UDP
chain=input action=accept protocol=udp
10 ;;; p2p
chain=forward action=drop p2p=all-p2p
11 ;;; warez
chain=forward action=drop p2p=warez
12 ;;; kazaa
chain=forward action=drop p2p=fasttrack
13 ;;; block torrent sites
chain=forward action=drop layer7-protocol=torrent-dns
14 ;;; block torrent dns
chain=forward action=drop protocol=udp layer7-protocol=torrent-dns
dst-port=53
15 ;;; torrentsites
chain=forward action=drop layer7-protocol=torrentsites
16 ;;; keyword_drop
chain=forward action=drop content=torrent
17 ;;; trackers_drop
chain=forward action=drop content=tracker
18 ;;; get_peers_drop
chain=forward action=drop content=getpeers
19 ;;; info_hash_drop
chain=forward action=drop content=info_hash
20 ;;; announce_peers_drop
chain=forward action=drop content=announce_peers
I believe if you Layer 7 filter everything it will severely impact your routers CPU. So you want to make sure you have plenty of processing capacity before you do it. So with the smaller 400 series boards, I typically just filter selected users via IP address lists.Hello and thank you for the information.
I have a question:
If they use it without the source-addresses it will work for the hole board if there are 3 wireless-client-cards with addresses 192.168.1.0, 192.168.2.0 and 192.168.3.0?
Or have I to write all the rules particular for each address?
Saludos
Uli
/ip firewall filter
add action=drop chain=forward comment="P2P drop " disabled=no p2p=all-p2p
add action=drop chain=forward comment="more connection closed" disabled=no
this rule : add action=drop chain=forward comment="more connection closed" disabled=no/ip firewall filter
add action=drop chain=forward comment="P2P drop " disabled=no p2p=all-p2p
add action=drop chain=forward comment="more connection closed" disabled=no
Hey guys! I have done this, and it works pretty great for what I needed, but I have one question. Is there a way to make it redirect to a website instead of just dropping? I want to tell all customers that it is against ToS to use torrents through a web page. Thanks
I just copied this from somewhere in the forum, I want to integrate it with blocking downloading of .mp3, *.mp4 etc, how will I add this to the l7-layer, is this one correct cus i dont see it catching any trafficAsume you want to block torrent & p2p traffic on 192.168.1.0/24
replace ip according to your need
/ip firewall layer7-protocol>
use winbox to copy paste name=torrentsites
regexp:
^.*(get|GET).+(torrent|
thepiratebay|isohunt|entertane|demonoid|btjunkie|mininova|flixflux|
torrentz|vertor|h33t|btscene|bitunity|bittoxic|thunderbytes|
entertane|zoozle|vcdq|bitnova|bitsoup|meganova|fulldls|btbot|
flixflux|seedpeer|fenopy|gpirate|commonbits).*$
/ip firewall filter>
add chain=forward src-address=192.168.1.0/24 layer7-protocol=torrentsites action=drop comment=torrentsites
add chain=forward src-address=192.168.1.0/24 protocol=17 dst-port=53 layer7-protocol=torrentsites action=drop comment=dropDNS
add chain=forward src-address=192.168.1.0/24 content=torrent action=drop comment=keyword_drop
add chain=forward src-address=192.168.1.0/24 content=tracker action=drop comment=trackers_drop
add chain=forward src-address=192.168.1.0/24 content=getpeers action=drop comment=get_peers_drop
add chain=forward src-address=192.168.1.0/24 content=info_hash action=drop comment=info_hash_drop
add chain=forward src-address=192.168.1.0/24 content=announce_peers action=drop comment=announce_peers_drop
& also use default rule to drop p2p traffic which alone is not working for me
add chain=forward src-address=192.168.1.0/24 p2p=all-p2p action=drop comment=p2p_drop
Enjoy
in my case i have identified torrent traffic by discard, detecting another protocols and services usually leave me with torrent on the "unclassified" part of the traffic leaving it with low priorityI agree with chechito. The only "small problem"™ is to correctly identifying the torrent traffic.
Blocking the download of the torrent file itself is useless as torrents can be added manually from other sources.
I think that only Deep Packet Inspection can help.
Any ideas?
Do you mean "everything else" (everything but HTTP, HTTPS, SSH, SMTPS, IMAP4S POP3S..) is considered torrent?in my case i have identified torrent traffic by discard
people are using 80 and 443 and 53 or another well known ports because of the blocking, because that is better to throttle than blockingDo you mean "everything else" (everything but HTTP, HTTPS, SSH, SMTPS, IMAP4S POP3S..) is considered torrent?in my case i have identified torrent traffic by discard
If so, which protocols are you considering?
If not, please elaborate.
As I cannot really block P2P in general, I am trying to throttle "everything else".
The problem is that outgoing P2P can also go to TCP:80, TCP:443, TCP:53 and UDP:53 and so on...
In these cases throttling wouldn't apply. And this is why I am talking about DPI.
So, was I right?people are using 80 and 443 and 53 or another well known ports because of the blocking, because that is better to throttle than blockingDo you mean "everything else" (everything but HTTP, HTTPS, SSH, SMTPS, IMAP4S POP3S..) is considered torrent?in my case i have identified torrent traffic by discard
If so, which protocols are you considering?
If not, please elaborate.
As I cannot really block P2P in general, I am trying to throttle "everything else".
The problem is that outgoing P2P can also go to TCP:80, TCP:443, TCP:53 and UDP:53 and so on...
In these cases throttling wouldn't apply. And this is why I am talking about DPI.
and with throttle im referencing to give the torrent the possibility of using all the spare bandwidth not throttling it to a ridiculous speeds
Is not perfect but it works in many cases and its free
if some one need better detection of P2P is better to go with an expensive fortigate or another UTM and pay the expensive annual license fee
for example
fortigate 80d recommended for 65mbps of wan channel cost ~750US without services, and ~1.740US with 3 year service subscription that is ~330 US per year of subscription
fortigate 200d recommended for 150mbps of wan channel cost ~2.300US without services, and ~5.200US with 3 year service subscription that is ~960 US per year of subscription
fortigate 600d recommended for 1.100mbps of wan channel cost ~8.000US without services, and ~17.840US with 3 year service subscription that is ~3.280 US per year of subscription
fortigate 1500d recommended for 2.300mbps of wan channel cost ~30.000US without services, and ~66.900US with 3 year service subscription that is ~12.300 US per year of subscription
fortigate 3000d recommended for 6.000mbps of wan channel cost ~60.000US without services, and ~133.800US with 3 year service subscription that is ~24.600 US per year of subscription
yes i priorize traffic in this order:So, was I right?
I mean, do you simply throttle "everything else" but a bunch of "well known useful protocols"?
Asume you want to block torrent & p2p traffic on 192.168.1.0/24
replace ip according to your need
/ip firewall layer7-protocol>
use winbox to copy paste name=torrentsites
regexp:
^.*(get|GET).+(torrent|
thepiratebay|isohunt|entertane|demonoid|btjunkie|mininova|flixflux|
torrentz|vertor|h33t|btscene|bitunity|bittoxic|thunderbytes|
entertane|zoozle|vcdq|bitnova|bitsoup|meganova|fulldls|btbot|
flixflux|seedpeer|fenopy|gpirate|commonbits).*$
/ip firewall filter>
add chain=forward src-address=192.168.1.0/24 layer7-protocol=torrentsites action=drop comment=torrentsites
add chain=forward src-address=192.168.1.0/24 protocol=17 dst-port=53 layer7-protocol=torrentsites action=drop comment=dropDNS
add chain=forward src-address=192.168.1.0/24 content=torrent action=drop comment=keyword_drop
add chain=forward src-address=192.168.1.0/24 content=tracker action=drop comment=trackers_drop
add chain=forward src-address=192.168.1.0/24 content=getpeers action=drop comment=get_peers_drop
add chain=forward src-address=192.168.1.0/24 content=info_hash action=drop comment=info_hash_drop
add chain=forward src-address=192.168.1.0/24 content=announce_peers action=drop comment=announce_peers_drop
& also use default rule to drop p2p traffic which alone is not working for me
add chain=forward src-address=192.168.1.0/24 p2p=all-p2p action=drop comment=p2p_drop
Enjoy
Can we complete it with another "keyword", another website name ?/ip firewall layer7-protocol>
use winbox to copy paste name=torrentsites
regexp:
^.*(get|GET).+(torrent|
thepiratebay|isohunt|entertane|demonoid|btjunkie|mininova|flixflux|
torrentz|vertor|h33t|btscene|bitunity|bittoxic|thunderbytes|
entertane|zoozle|vcdq|bitnova|bitsoup|meganova|fulldls|btbot|
flixflux|seedpeer|fenopy|gpirate|commonbits).*$
This will only block the download of a torrent file, not the torrent traffic itself.Hi!
I followed your tutorial and it's perectly work on my router ! Thank you a lot !
(I work for a small french ISP and we receive letters from Hadopi, so we are searching a solution to limit the illegal download ^^ )
I have a question, maybe it will sounds stupid for you, but this code :Can we complete it with another "keyword", another website name ?/ip firewall layer7-protocol>
use winbox to copy paste name=torrentsites
regexp:
^.*(get|GET).+(torrent|
thepiratebay|isohunt|entertane|demonoid|btjunkie|mininova|flixflux|
torrentz|vertor|h33t|btscene|bitunity|bittoxic|thunderbytes|
entertane|zoozle|vcdq|bitnova|bitsoup|meganova|fulldls|btbot|
flixflux|seedpeer|fenopy|gpirate|commonbits).*$
Is it this ? A sort of list of torrent sites names ?
Thank you again !
Noémie
PS : sorry for my bad english, I'm french
Hi!This will only block the download of a torrent file, not the torrent traffic itself.
Try to first download the torrent file, then enable the rules and finally ask your torrent client to load the torrent file to start the p2p exchange.
You will see the p2p traffic bidirectionally flowing unimpeded!
Hello from FranceP.S.
I am even more sorry for my english: I am Italian!
Well, the OP titled this thread as "Block Torrents & p2p Traffic 100% working" so I thought the topic was still sticking.Hi!This will only block the download of a torrent file, not the torrent traffic itself.
Try to first download the torrent file, then enable the rules and finally ask your torrent client to load the torrent file to start the p2p exchange.
You will see the p2p traffic bidirectionally flowing unimpeded!
I don't want to block it (we can't ! Because gaming used p2p, for example, and it's perfectly legal) !
I just want to identify the customers who try to download and then, limits their bandwhidth, send them an email, things like that !
Hello from FranceP.S.
I am even more sorry for my english: I am Italian!
Yep ! This is why I used this topic to mark people who have visited torrent website.Anyway, you are right. P2P (DHT) is being used for a number of purposes that cannot easily be told apart from each other.
I think now this thread title is misleading for two reasons:
1. you cannot block (real) P2P traffic based upon specific usage (lawful vs unlawful)
2. the proposed solution doesn't "Block Torrents & p2p Traffic" at all.
Blocking can also be shaping (or queueing in mikrotik lingo).Hello from the US.
Why would you want to block torrents? It is often legitimate traffic. Perhaps torrents are sometimes used to copy copyrighted content without appropriate license, but that is on the person making the illegal copy.
The ISP cannot know if a torrent is legal or illegal without confronting the customer to check their license for the content.
It seems to me if an ISP offers a customer bandwidth, say 1M up and 10M down for example, then the ISP is obligated to deliver 1M up and 10M down 99% of the time. After all, that's what the customer was sold.Blocking can also be shaping (or queueing in mikrotik lingo).
P2P traffic creates sustained loads in both directions and can be overkilling for most WANs.
I cannot and don't want to tell legitimate from unlegitimate content access: no sane net admin would.
Being able to tell P2P traffic from other things would be interesting. It seems it's impossible at the moment.
What I can do at the moment is to shape high TCP/UDP port traffic, but that's neither enough nor proper.
I've managed networks for a few small ISPs over the years. I admit I don't know your environment at all, so I'm just making uninformed opinions here. It seems to me with 100Mbps symmetric, why not offer the customers something like 1M up and 5M down or something similar? Depending on the number of subscribers, that might be a reasonable balance of bandwidth offering, and oversubscription could be more reasonably managed. The queues could even be set up in such a way that users exceed the max subscribed bandwidth when it's available if you wanted.I have 100mbps symmetrical.
One or two clients doing BitTorrent with a few files to be shared are enough to eat 50+% of the available bandwidth.
This is why I mind about p2p!
Well that totally changes my opinion. I thought you were an ISP.I am not an ISP. I manage a company network with BYOD policy.
You're right! But we receive letters from Hadopi and I think it will be temporary ! Just the time to send an email to the customers, or something like that, we will limit his bandwidth. Basically, my boss want me to directly send an email to the customers, to make him confirm that he might be do something illegal and if it is, he have risk consciousness.It seems to me if an ISP offers a customer bandwidth, say 1M up and 10M down for example, then the ISP is obligated to deliver 1M up and 10M down 99% of the time. After all, that's what the customer was sold.
If an ISP can't deliver promised bandwidth in aggregate due to oversubscription, overutilized gear, or any other cause, then the ISP needs to establish more bandwidth at the point of congestion. Sure, it can be expensive, but lying to the customers about the service an ISP is capable of providing can also be expensive.
Checking the legitimacy of any traffic falls far beyond the responsibilities and the capabilities of a network manager.You're right! But we receive letters from Hadopi and I think it will be temporary ! Just the time to send an email to the customers, or something like that, we will limit his bandwidth. Basically, my boss want me to directly send an email to the customers, to make him confirm that he might be do something illegal and if it is, he have risk consciousness.It seems to me if an ISP offers a customer bandwidth, say 1M up and 10M down for example, then the ISP is obligated to deliver 1M up and 10M down 99% of the time. After all, that's what the customer was sold.
If an ISP can't deliver promised bandwidth in aggregate due to oversubscription, overutilized gear, or any other cause, then the ISP needs to establish more bandwidth at the point of congestion. Sure, it can be expensive, but lying to the customers about the service an ISP is capable of providing can also be expensive.
We will not blocking p2p, it's impossible and we know
But this letters...
I have thinking about port mirroring and wireshark to check if the customers is downloading something.This is why I aim at identifying the P2P traffic (BitTorrent, DHT-based protocols and the likes).
If I succeed I can do something: blocking, limiting ...
If I cannot, then I have little to discuss.
Again, downloading a torrent file is NOTHING.
Have you tried to use a recent BitTorrent client with "KAD support"?
It doesn't need any torrent file but just the hash value, a string you can get by email or on the web.
The DHT will make the "rest of the magics", by just requiring some more time to "look" for a list of suitable peers.
So you won't be able to block or shape anything as even the torrent file is not needed any more.
You can only block everything, as they can be using "low ports" and apply a "light disguise" to the traffic as P2P can use any TCP and UDP ports from 1 to 65535!
What I see doable here is to allow "low ports" and a few "high ports" and block or limit the bandwidth to anything else.
It's more like "traffic containment" than "traffic control", but I see no option here.
Almost all P2P traffic is encrypted, thus inspecting the content wouldn't help much.I have thinking about port mirrorring and wireshark to chek if the customers is download something.This is why I aim at identifying the P2P traffic (BitTorrent, DHT-based protocols and the likes).
If I succeed I can do something: blocking, limiting ...
If I cannot, then I have little to discuss.
Again, downloading a torrent file is NOTHING.
Have you tried to use a recent BitTorrent client with "KAD support"?
It doesn't need any torrent file but just the hash value, a string you can get by email or on the web.
The DHT will make the "rest of the magics", by just requiring some more time to "look" for a list of suitable peers.
So you won't be able to block or shape anything as even the torrent file is not needed any more.
You can only block everything, as they can be using "low ports" and apply a "light disguise" to the traffic as P2P can use any TCP and UDP ports from 1 to 65535!
What I see doable here is to allow "low ports" and a few "high ports" and block or limit the bandwidth to anything else.
It's more like "traffic containment" than "traffic control", but I see no option here.
What do you think about this solution ?
Anyway it's impossible to identify if the customers is doing something illegal... :/
(And I don't know DHT ! Thanks for this information ! I found on the forum a guy who block this type of trafic by using dns static and some things like that. )