LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-09-2016, 03:41 AM   #1
S3TH76
Member
 
Registered: Dec 2014
Posts: 34

Rep: Reputation: Disabled
Pf filtering with tables - How to block all protocols inbound ?


Hi!

Can anyone help me with correct syntax on filtering rules with PF (on FreeBSD) and with tables?

The rules that I want to make it work are for blocking blocks of IP's by country (from IPDeny).

here it is:

table <blck_zone-br_1> persist file "/path/to/file - br.zone"
table <blck_zone-br_2> persist file "/path/to/file - br-aggregated.zone"

There are 2 file used to block brazilians IP's: br.zone & br-aggregated.zone
Below is the syntax that is working for blocking brazilians IP's and offcourse it is too lenghty for blocking tcp, udp, icmp, icmp6 protocols that came inbound from blocked zone.
...
block in quick on IF_NET0 proto tcp from <blck_zone-br_1> to any
block in quick on IF_NET0 proto udp from <blck_zone-br_1> to any
block in quick on IF_NET0 proto icmp from <blck_zone-br_1> to any
block in quick on IF_NET0 proto icmp6 from <blck_zone-br_1> to any

block in quick on IF_NET0 proto tcp from <blck_zone-br_2> to any
block in quick on IF_NET0 proto udp from <blck_zone-br_2> to any
block in quick on IF_NET0 proto icmp from <blck_zone-br_2> to any
block in quick on IF_NET0 proto icmp6 from <blck_zone-br_2> to any
###
Ok, I tried something like:

block in quick on IF_NET0 all from <blck_zone-br_1> to any
block in quick on IF_NET0 all from <blck_zone-br_2> to any

...but pf says: syntax error and I don't know where or what I am doing wrong...

Please help me.

Last edited by S3TH76; 03-10-2016 at 12:45 AM.
 
Old 03-09-2016, 10:00 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
The protocol match is optional. Have you tried just leaving it out altogether? (block in quick on IF_NET0 from <blck_zone-br-1> to any).
 
Old 03-10-2016, 01:10 AM   #3
S3TH76
Member
 
Registered: Dec 2014
Posts: 34

Original Poster
Rep: Reputation: Disabled
No. So, if understand correctly with your rule: block in quick on IF_NET0 from <blck_zone-br-1> to any automatically are blocked any connections from any protocols disregarding if it is tcp, udp, icmp, icmp6, ipv4, ipv6, bgp, etc?

I found an detailed example of rules of PF from wich I extrapolate my rule that now look like this:

block in quick on IF_NET0 proto {tcp, udp, icmp, icmp6} from <blck_zone-br-1> to any

but you are right your rule is much shorter, simple and elegant. I just want to be sure that is blocking ALL PROTOCOLS from any connection attempt from that zone because I will expand this rule at blocking russians, chinese, etc.

So a lighter ruleset for matching in PF filtering but with the same efect or more powerfull efect is better for my server.

Thank you.

Last edited by S3TH76; 03-10-2016 at 01:19 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MAC Address Filtering through IP Tables sjain_ivp Linux - Security 2 01-05-2016 07:43 AM
problems filtering with ip tables over bridge Gone_Crazy Linux - Networking 2 07-15-2006 04:54 AM
Inbound web URL filtering anoop_sweet Linux - Security 4 12-11-2005 11:45 PM
problem with static arp tables and it`s filtering J4b0l Linux - Networking 0 11-18-2005 02:20 PM
iptables : how do I block inbound traffic from one ip address only? Apollo77 Linux - Security 7 03-22-2004 10:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration