All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eliezer Croitoru <eliezer@ngtech.co.il>
To: Aaron Lewis <the.warl0ck.1989@gmail.com>
Cc: netfilter mailing list <netfilter@vger.kernel.org>
Subject: Re: [SOLVED] Re: Native support of counting rules?
Date: Fri, 04 Jan 2013 07:02:35 +0200	[thread overview]
Message-ID: <50E6626B.8040705@ngtech.co.il> (raw)
In-Reply-To: <CAJZVxRkyDyZyWUBbhP+H5gv2Dk1_Jj=v4QRAheHKWEnSKTdrhg@mail.gmail.com>

Since iptables are kind of static I think a simple script should be good 
enough.

A one liner should do the trick:
tables="filter nat raw mangle";counter="0"; for i in $tables; do 
add=`iptables -t $i -L -n --line-numbers |egrep "^[0-9]+\ " |wc -l`; 
counter=`expr $counter + $add`;done ;echo $counter

You dont need to read the proc file system to know that there are only 
four tables exits in iptables.

Just remind me why do we need another tool on-top all the existing ones?
But I do seem to understand what you mean by that there is no option to 
just count the number of rules in a table.
if you really want to to be used as a command just restrict the script 
to execution only..
This is why permissions do exist.

Best regards,
Eliezer

On 1/3/2013 4:13 PM, Aaron Lewis wrote:
> Already checked the manual on my system ... there's no counting
> support, the only thing relevant was --line-numbers,
>
> My code is here, for anyone who needed
>
> https://raw.github.com/CaledoniaProject/ipt_counting/master/ipt-count.c
>
> I just hope one day such feature would be included officially.
>
>
> On Wed, Jan 2, 2013 at 9:58 PM, Eliezer Croitoru <eliezer@ngtech.co.il> wrote:
>> Hey Aaron,
>>
>> I feel kind of odd but this should answer you:
>> http://linux.die.net/man/8/iptables
>> www.garron.me/linux/iptables-manual.html
>>
>> Eliezer
>>
>>
>> On 1/2/2013 3:48 PM, Aaron Lewis wrote:
>>>
>>> Hi,
>>>       I want to know if I could get how many rules are present, i.e in
>>>       filter table?
>>>
>>>       Now I do `iptables -L | wc -l` like stuff, I know it's not right,
>>>       but iptables itself doesn't seem to count rules anyway.
>>>
>>>       I need this just to let user to know how many rules are present,
>>>       without root privileges, and now being able to view actual rules.
>>>
>>
>
>
>

-- 
Eliezer

  parent reply	other threads:[~2013-01-04  5:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-02 13:48 Native support of counting rules? Aaron Lewis
2013-01-02 13:58 ` Eliezer Croitoru
2013-01-03 14:13   ` [SOLVED] " Aaron Lewis
2013-01-03 14:56     ` Jan Vales
2013-01-03 16:05       ` Jan Engelhardt
2013-01-03 17:27         ` Jan Vales
2013-01-04  5:45           ` Born Without
2013-01-04  5:02     ` Eliezer Croitoru [this message]
2013-01-04  5:39       ` Born Without
2013-01-04  5:57         ` Eliezer Croitoru
2013-01-02 15:11 ` Aaron Lewis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50E6626B.8040705@ngtech.co.il \
    --to=eliezer@ngtech.co.il \
    --cc=netfilter@vger.kernel.org \
    --cc=the.warl0ck.1989@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.