All of lore.kernel.org
 help / color / mirror / Atom feed
* Question, my modifed -j LOG
@ 2005-08-20 17:28 Joakim Axelsson
  2005-08-20 20:01 ` Jan Engelhardt
  2005-08-21 14:16 ` Robbie Dinn
  0 siblings, 2 replies; 12+ messages in thread
From: Joakim Axelsson @ 2005-08-20 17:28 UTC (permalink / raw)
  To: netfilter-devel

In my effort to try to make my router's firewall some what better i have
been thinking of modifying -j LOG in some ways:

The --log-prefix is way to short only allowing 30 characters. I have a huge
firewall with over 10000 rules (of couse not every packet using every rule).
Its impossible to keep track on where the packet is unless i supply the
table (filter,nat,mangle,raw) and the chain name in --log-prefix. Even if i
try to keep this short there is very little, if no room, left for a reason
to fit in --log-prefix. Simple solution for me is to modify -j LOG to handle
a longer --log-prefix.

Then i was thinking of another solution. Perhaps i could add one or two
options which beside the user supplied --log-prefix also prints the table
name and the chain name. It's easy to find the table name. Just store it in
userdata when the checkentry code runs. However, i havn't found a way to get
the chain name.

Mind that i'm also thinking of (yes wrongly) making my new -j LOG into a -m
log. A match that always matches. This will reduce the number of chains i
need alot. I can see that match->checkentry is given the struct ipt_entry.
But i can't figure out how to get the chain name for there.

To explain why i want to make it a match is because i very often have these
protectors in my firewall:

iptables -N chain_tcpsyn
iptables -A chain_tcpsyn -m limit --limit 1000/s -j RETURN
iptables -A chain_tcpsyn -m limit 1/s -j LOG --log-prefix "FW raw chain_tcpsyn"
iptables -A chain_tcpsyn -j DROP

iptables -N chain
iptables -A chain -p tcp --syn -j chain_tcpsyn
iptables -A chain -p tcp --syn -j RETURN
iptables -A chain -p tcp -j chain_tcp
iptables -A chain -p tcp -j RETURN
... udp icmp ...
iptables -A chain -j chain_otherprotocols


This gives me alot of chains and alot of rules. Mind also that i have _alot_
of interface on this router and even more of these limiters to keep the
machine alive during DDoSes. (I use a perl-script to generete a file which
can be loaded with iptables-restore.)

I have reduced the above by making a better and more accurate limit match
called only 'lim'. This lim can invert the match and only match those
packets that overlimits. Along with a possbile -m log (that in it self
limits the logger so kernel wont be flooded with logging messages) i could
reduce the above to:

iptables -N chain
iptables -A chain -p tcp --syn \
                  -m lim --lim-packets ! 1000/s \
                  -m log --log-lim 1/s --log-prefix "FW raw chain tcpsyn" \
                  -j DROP
iptables -A chain -p tcp --syn -j RETURN
...

I havn't figured a way to nicely remove that last -j RETURN. But it will
aleast save alot of rules and chains by the above idea.

Thx for any reply.

-- 
/Joakim Axelsson A.K.A Gozem@EFnet

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-08-21 19:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-20 17:28 Question, my modifed -j LOG Joakim Axelsson
2005-08-20 20:01 ` Jan Engelhardt
2005-08-20 20:25   ` Joakim Axelsson
2005-08-20 22:14     ` Joakim Axelsson
2005-08-20 22:38     ` Jan Engelhardt
2005-08-21  0:27       ` Carl-Daniel Hailfinger
2005-08-21  2:41         ` Peter Surda
2005-08-21  4:37       ` Joakim Axelsson
2005-08-21  8:36         ` Jan Engelhardt
2005-08-21 18:30         ` Carl-Daniel Hailfinger
2005-08-21 19:12           ` Joakim Axelsson
2005-08-21 14:16 ` Robbie Dinn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.