All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Humme <jan.humme@xs4all.nl>
To: Pavel Mores <pvl@uh.cz>, netfilter@lists.samba.org
Subject: Re: how to delete *some* netfilter rules?
Date: Fri, 5 Jul 2002 13:49:22 +0200	[thread overview]
Message-ID: <02070513492203.14428@Lms> (raw)
In-Reply-To: <20020614161800.GA6137@kostra.uh.cz>

On Friday 14 June 2002 18:18, Pavel Mores wrote:
> Hello,
>
> the problem I'm facing now might well be already solved by someone else
> so I thought I'd better ask.
>
> My filter table is filled by several separate independent scripts, each
> serving a distinct purpose.  Say that I use one script to generate
> firewalling rules and another to enter a couple of packet accounting
> rules needed by a monitoring subsystem.  Now, what if I want to flush
> the firewalling rules *without* disturbing the traffic monitoring rules?
>
> It certainly is possible to add to the firewall script a "delete_rules"
> function that would basically mimic my "insert_rules" function, only
> with -D instead of -A or -I.  But this tends to be ugly and avoiding the
> need to edit 2 places for every single change is not easy in bash (can't
> use perl there).

Your bash script could look like this:

#!/bin/bash

ADD=-A
INS=-I

if [ -n "$1" ]; then
	if [  "$1" != "delete" ]; then
		echo usage: $0 [delete]
		exit 1
	fi
	ADD=-D
	INS=-D
fi

#examples:
iptables $ADD INPUT -i eth0 10.0.0.0/8 -j DROP
iptables $INS OUTPUT -i eth0 192.168.0.0/16 -j DROP

# etc etc etc

Now:
1) If you run your script w/o any parameter, it works like today.
2) If your provide the text "delete" as the second parameter, it deletes all 
the rules.
3) In all other cases, it prints an error message.

>P.S.  Please Cc: your replies to me since I'm not subscribed to this
list.

Please do.

Jan Humme.


  reply	other threads:[~2002-07-05 11:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-14 16:18 how to delete *some* netfilter rules? Pavel Mores
2002-07-05 11:49 ` Jan Humme [this message]
2002-07-05 13:57   ` Martin Tomasek

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=02070513492203.14428@Lms \
    --to=jan.humme@xs4all.nl \
    --cc=netfilter@lists.samba.org \
    --cc=pvl@uh.cz \
    /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.