From: "Rob Sterenborg (lists)" <lists@sterenborg.info>
To: Donghua Liu <liudonghua123@gmail.com>
Cc: netfilter@vger.kernel.org
Subject: Re: how to discard a netfilter rule
Date: Thu, 28 Feb 2013 15:37:55 +0100 [thread overview]
Message-ID: <512F6BC3.3000307@sterenborg.info> (raw)
In-Reply-To: <CAJhv45jOTpijtRJrqV7TCE6Y469W1DY8d1NWBnSSz0NYw+6-Jg@mail.gmail.com>
On 02/28/2013 07:26 AM, Donghua Liu wrote:
> Hi,
>
> Say if I set a netfilter rule by "iptables -t nat -A custom_chain -p
> tcp -dport 80 -j DNAT --to-destination 127.0.0.1:1234" for some
> requirement.
>
> I also have a LKM which will check the availablity of service
> "127.0.0.1:1234" and how can I cancel the rule's operation(Do NOT
> delete this rule), let the packet go as usual ignore the nat.
man iptables says there is a -R command to replace rules:
----
-R, --replace chain rulenum rule-specification
Replace a rule in the selected chain. If the source
and/or destination names resolve to multiple addresses, the command will
fail. Rules are numbered starting at 1.
----
Assuming you know which rulenum must be changed, you can do this:
iptables -t nat -R custom_chain 1 -p tcp -dport 80
IOW, lose the -j parameter from the rule, keeping the others. The result
is that the rule will still be there, but effectively won't do anything
except for matching and updating packet/byte counting.
--
Rob
next prev parent reply other threads:[~2013-02-28 14:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-28 6:26 how to discard a netfilter rule Donghua Liu
2013-02-28 9:02 ` Neal Murphy
2013-02-28 14:37 ` Rob Sterenborg (lists) [this message]
2013-03-01 3:19 ` Donghua Liu
-- strict thread matches above, loose matches on Subject: below --
2013-02-28 10:55 Donghua Liu
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=512F6BC3.3000307@sterenborg.info \
--to=lists@sterenborg.info \
--cc=liudonghua123@gmail.com \
--cc=netfilter@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox