pftabled 1.04

2004-09-13 Thread Armin Wolfermann
Hi,

the new pftabled release 1.04 is out. Now with client selectable tables
and HMAC-SHA1 authentication.

The pftabled daemon is a small helper to make your pf tables reachable
from other hosts. You can add/delete/flush IP addresses to/from a remote
table with a single UDP datagram.

Homepage: http://www.wolfermann.org/pftabled.html
Download: http://www.wolfermann.org/pftabled-1.04.tar.gz

Regards,
Armin Wolfermann


Re: pfauth like system for modifying pf tables

2004-03-10 Thread Armin Wolfermann
* Russell Fulton [EMAIL PROTECTED] [10.03.2004 05:10]:
   In mid January I asked if anyone had written a daemon to allow one to
 modify pf tables from another system (eg an authentication system where
 people are logging in).  Someone replied off list and now I that I
 really need the information I can't find it. I've spent most of this
 afternoon searching my email archive, my browser bookmarks, googling and
 anything else I can think of.

It's in the archives: http://www.benzedrine.cx/pf/msg04036.html



Re: PF stream size

2004-01-21 Thread Armin Wolfermann
* Ed White [EMAIL PROTECTED] [19.01.2004 16:14]:
 I would like to know if there is any plan to limit the number of bytes
 a TCP connection can transfer. The idea is to drop/close the
 connection after $SIZE bytes have been transferred. 

This is a first cut at this idea. It implements a per-state traffic
limit like this:

pass in proto tcp from any to any port = 25 \
flags S/SA keep state (bytes 10)

This could be easily extended to per-rule or per-source-ip limits. I
just didn't want to invent too many keywords.

Opinions? Ideas?


Index: sys/net/pf.c
===
RCS file: /cvs/src/sys/net/pf.c,v
retrieving revision 1.418
diff -p -u -r1.418 pf.c
--- sys/net/pf.c6 Jan 2004 20:24:33 -   1.418
+++ sys/net/pf.c21 Jan 2004 15:54:19 -
@@ -5469,6 +5469,12 @@ done:
REASON_SET(reason, PFRES_MEMORY);
}
 
+   if (r-max_bytes  (s-bytes[0] + s-bytes[1] = r-max_bytes)) {
+   s-timeout = PFTM_PURGE;
+   action = PF_DROP;
+   REASON_SET(reason, PFRES_MAXBYTES);
+   }
+
if (log)
PFLOG_PACKET(kif, h, m, AF_INET, dir, reason, r, a, ruleset);
 
Index: sys/net/pfvar.h
===
RCS file: /cvs/src/sys/net/pfvar.h,v
retrieving revision 1.180
diff -p -u -r1.180 pfvar.h
--- sys/net/pfvar.h 31 Dec 2003 11:18:25 -  1.180
+++ sys/net/pfvar.h 21 Jan 2004 15:54:19 -
@@ -484,6 +484,7 @@ struct pf_rule {
u_int32_ttimeout[PFTM_MAX];
u_int32_tstates;
u_int32_tmax_states;
+   u_int64_tmax_bytes;
u_int32_tsrc_nodes;
u_int32_tmax_src_nodes;
u_int32_tmax_src_states;
@@ -859,7 +860,8 @@ struct pf_pdesc {
 #define PFRES_SHORT3   /* Dropping short packet */
 #define PFRES_NORM 4   /* Dropping by normalizer */
 #define PFRES_MEMORY   5   /* Dropped due to lacking mem */
-#define PFRES_MAX  6   /* total+1 */
+#define PFRES_MAXBYTES 6   /* Dropped due to bytes limit */
+#define PFRES_MAX  7   /* total+1 */
 
 #define PFRES_NAMES { \
match, \
@@ -868,6 +870,7 @@ struct pf_pdesc {
short, \
normalize, \
memory, \
+   bytes, \
NULL \
 }
 
Index: sbin/pfctl/parse.y
===
RCS file: /cvs/src/sbin/pfctl/parse.y,v
retrieving revision 1.436
diff -p -u -r1.436 parse.y
--- sbin/pfctl/parse.y  5 Jan 2004 22:04:24 -   1.436
+++ sbin/pfctl/parse.y  21 Jan 2004 15:53:57 -
@@ -117,12 +117,13 @@ struct node_icmp {
 
 enum   { PF_STATE_OPT_MAX, PF_STATE_OPT_NOSYNC, PF_STATE_OPT_SRCTRACK,
  PF_STATE_OPT_MAX_SRC_STATES, PF_STATE_OPT_MAX_SRC_NODES,
- PF_STATE_OPT_STATELOCK, PF_STATE_OPT_TIMEOUT };
+ PF_STATE_OPT_STATELOCK, PF_STATE_OPT_TIMEOUT, PF_STATE_OPT_BYTES };
 
 struct node_state_opt {
int  type;
union {
u_int32_tmax_states;
+   u_int64_tmax_bytes;
u_int32_tmax_src_states;
u_int32_tmax_src_nodes;
u_int8_t src_track;
@@ -399,7 +400,7 @@ typedef struct {
 %token QUEUE PRIORITY QLIMIT
 %token LOAD
 %token STICKYADDRESS MAXSRCSTATES MAXSRCNODES SOURCETRACK GLOBAL RULE
-%token TAGGED TAG IFBOUND GRBOUND FLOATING STATEPOLICY
+%token TAGGED TAG IFBOUND GRBOUND FLOATING STATEPOLICY BYTES
 %token v.string  STRING
 %token v.i   PORTBINARY
 %type  v.interface   interface if_list if_item_not if_item
@@ -1465,6 +1466,14 @@ pfrule   : action dir logquick interface 
}
r.max_states = o-data.max_states;
break;
+   case PF_STATE_OPT_BYTES:
+   if (r.max_bytes) {
+   yyerror(state option 'bytes' 
+   multiple definitions);
+   YYERROR;
+   }
+   r.max_bytes = o-data.max_bytes;
+   break;
case PF_STATE_OPT_NOSYNC:
if (r.rule_flag  PFRULE_NOSYNC) {
yyerror(state option 'sync' 
@@ -2571,6 +2580,15 @@ state_opt_item   : MAXIMUM number{
$$-next = NULL;
$$-tail = $$;
}
+   | BYTES number  {
+ 

Re: What is the smallest sensible size for a table? and pfauth like system

2004-01-15 Thread Armin Wolfermann
* Russell Fulton [EMAIL PROTECTED] [15.01.2004 05:00]:
 We are also looking at moving many of our 'standard' machines to dynamic
 table whereby they will have to log in to a 'service' which will open up
 their access through the firewall and inform our traffic meter which
 user is on the particular IP, this will pave the way for allowing
 increased usage of dynamic IP addresses.  Rather like pfauth but we will
 write a custom daemon to run on the firewall.  

Taking a look at http://wolfermann.org/pftabled.html may save you some work.



pftabled 1.01

2003-10-30 Thread Armin Wolfermann
Hi,

the pftabled daemon is a small helper to make your pf tables reachable
from other hosts. You can add/delete/flush IP addresses to/from a fixed
table with a single UDP datagram. My intention was to add IPs to spamd
from the hosts behind the firewall, but there are way more possibilities.

Server example:

# pftabled -d -p  spamd

Client example:

$ pftabled-client fw.example.com  add 1.2.3.4

Homepage: http://www.wolfermann.org/pftabled.html
Download: http://www.wolfermann.org/pftabled-1.01.tar.gz

Regards,
Armin Wolfermann



Re: Why isn't this port blocked?

2003-03-09 Thread Armin Wolfermann
* Peter Gorsuch [EMAIL PROTECTED] [08.03.2003 00:01]:
 pass in inet proto { tcp, udp } from any to any port 5899  5911 keep state
 pass out inet proto { tcp, udp } from any to any port 5899  5911 keep
 state
 pass in inet proto { tcp, udp } from any to any port 5799  5811 keep state
 pass out inet proto { tcp, udp } from any to any port 5799  5811 keep
 state
 
Just replace  with .



Recursively expanded macros

2003-03-02 Thread Armin Wolfermann
Hi,

the pf.conf(5) man page states Macros are not expanded recursively.

Luckily this is not always true:

% cat pf.conf
host1 = 1.1.1.1
host2 = 2.2.2.2
host3 = 3.3.3.3

hostgroup = $host1 $host2 $host3

pass in on rl0 from any to { $hostgroup }

% pfctl -vvnf pf.conf
host1 = 1.1.1.1
host2 = 2.2.2.2
host3 = 3.3.3.3
hostgroup = 1.1.1.1 2.2.2.2 3.3.3.3
@0 pass in on rl0 inet from any to 1.1.1.1 
@1 pass in on rl0 inet from any to 2.2.2.2 
@2 pass in on rl0 inet from any to 3.3.3.3 

-- Armin