From: Jason Opperisano <opie@817west.com>
To: netfilter@lists.netfilter.org
Subject: Re: specifying -m state --state NEW (Was : --policy DROP kills everything?)
Date: Fri, 10 Jun 2005 15:33:24 -0400 [thread overview]
Message-ID: <20050610193324.GA6604@bender.817west.com> (raw)
In-Reply-To: <1118430816.8207.44.camel@sonea.sterenborg.info>
On Fri, Jun 10, 2005 at 09:13:36PM +0200, Rob Sterenborg wrote:
> On Fri, 2005-06-10 at 14:08 -0400, Jason Opperisano wrote:
> > On Thu, Jun 09, 2005 at 08:26:38AM +0200, Rob Sterenborg wrote:
> > > If -m state is not specified then, in my experience, -m state --state
> > > NEW is assumed (someone please correct me if I'm telling nonsense here)
> > > so your rules *will* allow new connections.
> >
> > that is; indeed, nonsense.
>
> In that case I don't understand why both rules seem to do the same job.
> Both :
>
> $ipt -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
>
> and :
>
> $ipt -A INPUT -i eth0 -m state --state NEW -p tcp --dport 22 -j ACCEPT
>
> only work in combination with :
>
> $ipt -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
>
> At least, here it does.
using "-m state --state NEW" in your rules pretty much forces you into
using the "-m state --state RELATED,ESTABLISHED" rule (this is not a bad
thing). the first rule:
-A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
will not consider the state of the packet in the decision to match this
rule. it will match NEW, ESTABLISHED, RELATED, etc...as long as the
input interface is eth0 and the destination port is TCP 22.
> I was just looking at Oskar's tutorial where I read that the state
> matches are explicit thus have to be specifically loaded for them to
> work. Does this means that if I don't specify a state match in a rule,
> the rule just won't match any state ?
correct. just like not specifying "-d w.x.y.z" means the rule will
match any destination IP address; not specifying "-m state --state X"
means the rule will match a packet in any state.
> Assuming that that's true in the first rule, a packet coming in on port
> 22 would be accepted regardless of state ?
yes.
> In practice I know that that's not true because when I use the first
> rule without accepting RELATED or ESTABLISHED, I *cannot* connect to
> sshd. When I add the RELATED,ESTABLISHED accept rule, I *can* connect to
> sshd. (And this is how I would expect it to work.)
i would question your testing methodology, as you can run a functional
iptables firewall without using state matches at all.
> So, what is the difference in specifying and not specifying --state NEW
> in a rule ?
the difference is whether you want to match only NEW packets or not.
commercial firewalls like Cisco PIX and Check Point FW-1 enforce
something along the lines of:
-p tcp --tcp-flags ALL SYN -m state --state NEW
in the decision of whether a packet should be allowed to traverse the
filter rules or not.
in the world of netfilter--you write the rules, you decide how specific
the match will be. if you want to say, this rule only matches NEW TCP
SYN packets, then use a construct like the above--you can even use
variables to simplify your scripts, like so:
TCP_REQ="-p tcp --tcp-flags ALL SYN -m state --state NEW"
iptables -A INPUT $TCP_REQ --dport 22 -j ACCEPT
-j
--
"Brian: Congratulations, Peter. You're the Spalding Gray of crap."
--Family Guy
next prev parent reply other threads:[~2005-06-10 19:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-08 21:11 --policy DROP kills everything? David Busby
2005-06-08 22:02 ` Rob Sterenborg
2005-06-08 23:32 ` David Busby
2005-06-09 6:26 ` Rob Sterenborg
2005-06-10 18:08 ` Jason Opperisano
2005-06-10 19:13 ` specifying -m state --state NEW (Was : --policy DROP kills everything?) Rob Sterenborg
2005-06-10 19:33 ` Jason Opperisano [this message]
2005-06-10 20:31 ` Rob Sterenborg
2005-06-10 20:13 ` Jason Opperisano
2005-06-10 14:48 ` --policy DROP kills everything? Steven M Campbell
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=20050610193324.GA6604@bender.817west.com \
--to=opie@817west.com \
--cc=netfilter@lists.netfilter.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