bash script for iptables

This is a discussion on bash script for iptables within the Linux Security forums, part of the System Security and Security Related category; !/bin/bash # 10 JUN 2004 # Must be run as root grep "localhost kernel" /var/log/syslog|grep PROTO|...


Go Back   Usenet Forums > System Security and Security Related > Linux Security

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-23-2004
Felix Tilley
 
Posts: n/a
Default bash script for iptables

!/bin/bash
# 10 JUN 2004

# Must be run as root

grep "localhost kernel" /var/log/syslog|grep PROTO|while read a1 a2 a3 a4 a5 \
a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20

do
if test $a16 = "PROTO=UDP"
then echo $a1 $a2 $a3 "-0700" $a9 $a10 $a16 $a17 $a18
else echo $a1 $a2 $a3 "-0700" $a9 $a10 $a17 $a18 $a19
fi
done


--

Felix Tilley
Rank: MAJ
Fanatic Lartvocate
FL# 555-LART
Reply With Quote
  #2 (permalink)  
Old 07-26-2004
William Park
 
Posts: n/a
Default Re: bash script for iptables

Felix Tilley <ftilley@localhost.localdomain> wrote:
> !/bin/bash
> # 10 JUN 2004
>
> # Must be run as root
>
> grep "localhost kernel" /var/log/syslog|grep PROTO|while read a1 a2 a3
> a4 a5 \ a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20
>
> do
> if test $a16 = "PROTO=UDP"
> then echo $a1 $a2 $a3 "-0700" $a9 $a10 $a16 $a17 $a18
> else echo $a1 $a2 $a3 "-0700" $a9 $a10 $a17 $a18 $a19
> fi
> done


More sensible way of doing this kind of thing is
grep ... | sed ... | while read line; do
( declare $line # 'line' only has VAR=VALUE or VAR strings
if [ $PROTO = UDP ]; then
echo ...
else
echo ...
fi )
done

--
William Park, Open Geometry Consulting, <opengeometry@yahoo.ca>
Toronto, Ontario, Canada
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:13 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0