OPNsense Forum

English Forums => General Discussion => Topic started by: pr3p on October 12, 2016, 08:44:20 am

Title: P2P Blocking and Port Blocking - Torrents
Post by: pr3p on October 12, 2016, 08:44:20 am
Hi im new to opnsense and im just converted our ClearOS gateway to OPNsense, any guide on the following


1. how to block P2P on the gateway with firewall
2. how to bock all ports and allow certain ports only on the gateway/opnsense (this is an alternative way to block p2p and only allow certain ports to be used).


Thanks and looking for your fast response.
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: franco on October 14, 2016, 09:41:37 am
Hi there,

File sharing is elusive and hard to block. This is a fact.

The following page is in German, but it has some ideas on locking down P2P by allowing only basic network usage:

http://www.heise.de/ct/hotline/Filesharing-blockieren-1436278.html

The latter part is interesting, saying that blocking file-sharing is a multi-million dollar business for commercial vendors. It's very hard to find free alternatives that are effective.


Cheers,
Franco
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: pr3p on October 17, 2016, 05:36:55 am
Thanks franco for this one, but i was able to block p2p with firewall on clearOS.

1. Firewall Incoming - The Firewall Incoming Connections page lets you open a port (or service) on your server. For instance, if you want to run your own public web server, you must open port 80 on the firewall!

2.Firewall Outgoing - block all outgoing traffic specified allowed destination.
From the Firewall Blocking page, you can block certain kinds of traffic from leaving your network.  You have two ways to block traffic i) by port or ii) by IP address/domain.

Question: so is this possible on opnsense block all port and just open what services or port needed to lockdown the network?
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: franco on October 17, 2016, 07:04:22 am
Yes, that's what I wrote.

(1) is enabled by default for WAN.

(2) is disabled by default for LAN (it's considered a trusted zone), but you can adjust your rules accordingly. OPTn interfaces have this enabled by default.

You can import IP or Domain lists (remote or local) as aliases. You can use ports to block traffic. All you need to do is create a whitelist-style ruleset for the network you're trying to lock against P2P.

You can do URL filtering based on HTTP(S) with the Proxy.

You can do IPS filtering with your or someone else's snort/suricata rules.


Cheers,
Franco
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: pr3p on October 18, 2016, 04:34:37 am
@franco yes can you post a guide or tutorials on this one like i would like to block all port and allow port 80 and port 22 only, i was new to opnsense and pfsense so im still adjusting on the configuration and firewall rule, thanks and looking for your fast response.
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: franco on October 18, 2016, 09:51:41 pm
We don't have a specific document for your use case, but here is the alias setup that allows you to specify your whitelist ports:

https://docs.opnsense.org/manual/aliases.html

Afterwards, you can use that alias to allow your target interface in the firewall rules (Firewall: Rules) to only "pass" (action) these type of packets (destination port set to the alias).

If you want this on LAN, make sure to disable the default pass rules for IPv4 and IPv6.


Cheers,
Franco
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: pr3p on October 30, 2016, 11:37:11 am
i try to block all port and open necessary services or port i needed but i try to ping any url or ip cant ping, i was able t o browse internet, @franco any configuration or port need to open?
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: fabian on October 30, 2016, 11:52:51 am
you need to pass ICMP type echo request for sending a ping. Note that you will need two rules for that: One with ICMP + IPv4 and ICMPv6 + IPv6
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: pr3p on October 31, 2016, 04:14:41 am
Thanks, and how im just new to opnsense on firewall rule what services seems i don't see any list of choices for icmp
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: fabian on October 31, 2016, 09:30:33 am
ICMP is in the same select box as TCP/UDP (at the top of the firewall rule edit page)
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: Zeitkind on October 31, 2016, 05:32:24 pm
Thanks franco for this one, but i was able to block p2p with firewall on clearOS.

No, you only thought you have. Any recent and decent P2P-Client will use eg. port 80 or 443 for communication and use TLS to harden a detection. So even a deep packet inspection might fail because of the encryption and masquerading of the data packets.
With the right client, you can tunnel anything via port 80 or 443 (or 110, 465, ...). Wether it's Skype, TeamViewer or OpenVPN, you can tunnel through anything as long as their targets are reachable. It's an illusion to stop decent p2p clients as long as "normal web access" is granted.
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: fabian on October 31, 2016, 09:13:38 pm
Quote
With the right client, you can tunnel anything via port 80 or 443 (or 110, 465, ...). Wether it's Skype, TeamViewer or OpenVPN, you can tunnel through anything as long as their targets are reachable. It's an illusion to stop decent p2p clients as long as "normal web access" is granted.

Web can be filtered by an ICAP service which detects this traffic but it may be hard to create suitable signatures.
Other protocols may not be allowed to any destination (for example mail is only allowed to the mail server of your company).
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: Zeitkind on November 01, 2016, 01:54:06 am
There are some p2p clients around which masquerade as a standard webserver access until TLS is active. And at this point, you either give up or force a https-proxy and break security. So, yes, you might be able to stop simple p2p clients, but sure not any of those tunneling ones. Some even try to masquerade as DNS querries..
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: fabian on November 01, 2016, 08:57:52 am
Auch die Tunnel lassen sich blockieren - das geht aber mit den Boardmitteln nicht. DNS lässt sich mit einem Proxy wie RubyDNS (https://github.com/ioquatix/rubydns) filtern, Echo Requests (Ping) können komplett verboten werden (wenn benötigt kann man das ja über die Oberfläche der Firewall machen).

Nur der HTTPS-Proxy ist dann eben auch Pflicht.

Fabian
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: pr3p on November 01, 2016, 09:30:24 am
Thanks, and how im just new to opnsense on firewall rule what services seems i don't see any list of choices for icmp


ok i got thanks Fabian :)
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: pr3p on November 11, 2016, 02:21:06 am
Hi guys anyone here  can you post a complete guide for this one the block p2p or .torrent file or exe thanks and looking for your fast response.
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: fabian on November 11, 2016, 05:53:36 pm
A good start is blocking file downloads and every file URL that ends with .torrent or .exe

Kind regards

Fabian
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: pr3p on November 11, 2016, 07:15:33 pm
kindly post a complete guide on how thanks and cheers  :) where can i view this setting? this is on the proxy setting under forward proxy?
Title: Re: P2P Blocking and Port Blocking - Torrents
Post by: pr3p on November 15, 2016, 01:58:45 am
Any guide PLEASE @fabian, @franco @jschellevis thanks