Skip to contentSkip to conversation

Iptables Rules

DISCUSSION Jan Engelhardt 2 participants 3 messages Apr 9, 2008 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 7 lines · Minh Cao
Quoted 3 lines

Hi,
Is that matter if I placed the options/extensions ( -m and -p ) in different orders ?

No, but it matters between multiple -m.

Quoted 5 lines · Ukeme Noah

Howdy,
The last two, the ones using the state machine might give you problems if you use only those without specifying to allow established ssh connections.

So, I'd suggest you add ,ESTABLISHED right after NEW to make the line

Adding random states to rules of which you do not have the context is unlikely to be fruitful.

#2 lore raw

Thanks for your help !

Please explain why these two acting differently.
On #2 I can login as anonymous, but ls.
Can I combine two rules into one ?

1/
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -m state --state NEW -p tcp -m tcp --dport 21 -j ACCEPT

2/
-A INPUT -m state --state NEW,RELATED,ESTABLISHED -p tcp -m tcp --dport 21 -j ACCEPT

Quoted 30 lines · --- Jan Engelhardt
Quoted 4 lines · Minh Cao
Quoted 2 lines

Hi,
Is that matter if I placed the options/extensions

( -m

Quoted 3 lines
Quoted 1 line

and -p ) in different orders ?

No, but it matters between multiple -m.

Quoted 2 lines · Ukeme Noah

Howdy,
The last two, the ones using the state machine

might give you problems if

Quoted 1 line

you use only those without specifying to allow

established ssh connections.

Quoted 2 lines

So, I'd suggest you add ,ESTABLISHED right after

NEW to make the line

Adding random states to rules of which you do not
have the context
is unlikely to be fruitful.

--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 4 lines · Minh Cao

Thanks for your help !

Please explain why these two acting differently.
On #2 I can login as anonymous, but ls.

^ but not ls

That's because in #2, you limit RELATED to port 21, which is essentially meaningless.
In #1, RELATED applies to any port (as does ESTABLISHED).

Review

Quoted 7 lines

Can I combine two rules into one ?

1/
-A INPUT -m state --state RELATED,ESTABLISHED -j
ACCEPT

(quoted diff) +0 -2
-A INPUT -m state --state NEW -p tcp -m tcp --dport 21
-j ACCEPT

No.