LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-21-2009, 10:41 AM   #1
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Rep: Reputation: 39
Question about an iptables option


Hi there --

I am testing out a script that checks the status of iptables. The script is the following text:

Code:
#!/bin/bash

# IPT='/usr/sbin/iptables'
IPT='/sbin/iptables'
GREP='/bin/grep'
AWK='/bin/awk'
EXPR='/usr/bin/expr'
WC='/usr/bin/wc'

STAT=0
OUTPUT=''
CHAINS=`$IPT -nvL | $GREP 'Chain' | $AWK '{ print $2 }'`

for CHAIN in $CHAINS ; do
        if [ "$CHAIN" != 'FORWARD' ] && [ "$CHAIN" != 'OUTPUT' ] && [ `$EXPR substr $CHAIN 1 4` != "LOG_" ] ; then
                CNT=`expr $($IPT -S $CHAIN | $WC -l) '-' 1`
                if [ $CNT -eq 0 ] ; then
                        OUTPUT="<b>${OUTPUT}ERROR $CHAIN $CNT rules!</b><br>"
                        STAT=2
                else
                        OUTPUT="${OUTPUT}OK $CHAIN $CNT rules<br>"
                fi
        fi
done

echo $OUTPUT

exit $STAT
The argument that I am unfamiliar with is the following:

Code:
$IPT -S $CHAIN | $WC -l
I have looked up the man page for iptables, and there is no reference to the -S argument. The version of iptables that is running on the server in question is version 1.3.8.

Is this argument available on another version of iptables, or should it be replaced by another one? Thanks.
 
Old 01-21-2009, 06:18 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
It is --list-rules

In this case for each chain and it's counting the lines.

jlinkels
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
SSH option question... (How to) abovenbeyond Linux - Newbie 2 08-19-2008 07:15 PM
Do you have to choose some compile option for iptables to work in 2.6.xx kernel? M$ISBS Slackware 1 07-15-2006 07:20 PM
question about gcc/g++ -M option George2 Programming 4 04-27-2006 11:02 PM
iptables-restore v1.2.11: Line 68 seems to have a -t table option. SupaDucta Linux - Networking 2 01-11-2006 06:38 AM
just a question with an option in ppp chankunchan Linux - Networking 1 03-23-2004 02:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:54 PM.

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