Skip to contentSkip to conversation

IPTABLES syntax problem.

DISCUSSION ads nat 6 participants 16 messages Dec 23, 2003

lore
Share & tools
lore

ads nat

author
#0 lore raw

Hi,
I am trying to setup IPTABLES rules. I am newbe to this.

One of the rule in filter table is
#######
-A INPUT -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "New not syn:"
#############

I am getting following error :

[root@allweb root]# /etc/init.d/iptables restart Flushing all current rules and user defined chains:
[ OK ]
Clearing all current rules and user defined chains:
[ OK ]
Applying iptables firewall rules: iptables-restore v1.2.6a: Unknown arg `--syn'
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

I am using /etc/init.d/iptables restart to apply
iptables rules.

I think I have used proper syntax "--syn" from Oskar Anderson IPTABLES tutorials.

Looking for support.
Thanks

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

#1 lore raw

What do you want to do with this rule?

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of ads nat
Sent: 23. december 2003 12:47
To: [email protected]
Subject: IPTABLES syntax problem.

Hi,
I am trying to setup IPTABLES rules. I am newbe to this.

One of the rule in filter table is
#######
-A INPUT -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "New not syn:"
#############

I am getting following error :

[root@allweb root]# /etc/init.d/iptables restart Flushing all current rules and user defined chains:
[ OK ]
Clearing all current rules and user defined chains:
[ OK ]
Applying iptables firewall rules: iptables-restore v1.2.6a: Unknown arg `--syn'
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

I am using /etc/init.d/iptables restart to apply
iptables rules.

I think I have used proper syntax "--syn" from Oskar Anderson IPTABLES tutorials.

Looking for support.
Thanks

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

#2 lore raw
Quoted 1 line · Jan Kaastrup

What do you want to do with this rule?

Presumably the intention is to catch packets which are not part of an existing connection, but which are not SYN packets - eg FIN scans?

Antony.

Quoted 44 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of ads nat
Sent: 23. december 2003 12:47
To: [email protected]
Subject: IPTABLES syntax problem.

Hi,
I am trying to setup IPTABLES rules. I am newbe to this.

One of the rule in filter table is
#######
-A INPUT -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "New not syn:"
#############

I am getting following error :

[root@allweb root]# /etc/init.d/iptables restart Flushing all current rules and user defined chains:
[ OK ]
Clearing all current rules and user defined chains:
[ OK ]
Applying iptables firewall rules: iptables-restore v1.2.6a: Unknown arg `--syn'
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

I am using /etc/init.d/iptables restart to apply
iptables rules.

I think I have used proper syntax "--syn" from Oskar Anderson IPTABLES tutorials.

Looking for support.
Thanks

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

Signature · 4 lines
This email was created using 100% recycled electrons.

                                                     Please reply to the list;
                                                           please don't CC me.
author
#3 lore raw
In reply to Jan Kaastrup

I have setup initial rules as follows:

*filter
-F INPUT
-F OUTPUT
-F FORWARD

-A INPUT -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "New not syn:"
-A INPUT -p tcp --tcp-flags SYN,ACK SYN,ACK -m state --state NEW -j REJECT
-A INPUT -p tcp ! --syn -m state --state NEW -j DROP -A INPUT -p all -s 192.168.0.0/24 -i eth0 -j REJECT -A INPUT -p all -s 192.168.1.0/24 -i eth0 -j REJECT -A INPUT -p all -s localhost -i eth0 -j REJECT -A INPUT -p tcp --syn -j ACCEPT
-A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT

Rule No. 1) I want to send ! --syn and NEW packet to log file.
Rule No. 2) New packets from outside should be rejected.
Rule No.3) To avoid spoofing, packets from 192.168.0.1 and 192.168.1.0 going to eth0 (Internet eth0) Rule No.4) To avoid packets from localhost going to eth0 (Internet eth0)
RULE 5) TO accept syn packets initiated form LAN user and having Estabilshed connection.

Please guide about rules.
Thanks

Here I want to reject New packets

Quoted 43 lines · --- Jan Kaastrup

What do you want to do with this rule?

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On
Behalf Of ads nat
Sent: 23. december 2003 12:47
To: [email protected]
Subject: IPTABLES syntax problem.

Hi,
I am trying to setup IPTABLES rules. I am newbe to this.

One of the rule in filter table is
#######
-A INPUT -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "New not syn:"
#############

I am getting following error :

[root@allweb root]# /etc/init.d/iptables restart Flushing all current rules and user defined chains:

[ OK ]
Clearing all current rules and user defined chains:

[ OK ]
Applying iptables firewall rules: iptables-restore v1.2.6a: Unknown arg `--syn'
Try `iptables-restore -h' or 'iptables-restore --help'
for more information.

I am using /etc/init.d/iptables restart to apply
iptables rules.

I think I have used proper syntax "--syn" from Oskar Anderson IPTABLES tutorials.

Quoted 9 lines

Looking for support.
Thanks

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

#4 lore raw
In reply to ads nat
Quoted 8 lines · ads nat

Hi,
I am trying to setup IPTABLES rules. I am newbe to this.

One of the rule in filter table is
#######
-A INPUT -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "New not syn:"

Try:
iptables -A INPUT -p tcp ! --tcp-flags SYN SYN -m state --state NEW -j LOG --log-prefix " New not syn: "

Note the change in specifying flags from ipchains to iptables. Also note I added spaces around your prefix. This will make it easier to read in the logs.

HTH,
C

author
#5 lore raw

I modified rules as follows :

###########
-A INPUT -p tcp ! --tcp-flags SYN SYN -m state --state NEW -j LOG --log-prefix " New not syn: "

-A INPUT -p tcp ! --tcp-flags SYN SYN -m state --state NEW -j DROP

-A INPUT -p all -s 192.168.0.0/24 -i eth0 -j REJECT -A INPUT -p all -s 192.168.1.0/24 -i eth0 -j REJECT

-A INPUT -p all -s localhost -i eth0 -j REJECT

#

# allowed chain
#

-A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT

##########

Get following error :
[root@allweb root]# /etc/init.d/iptables restart Flushing all current rules and user defined chains:
[ OK ]
Clearing all current rules and user defined chains:
[ OK ]
Applying iptables firewall rules: iptables-restore v1.2.6a: Unknown arg `--tcp-flags'
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

[FAILED]

Quoted 16 lines · --- Chris Brenton
Quoted 7 lines · ads nat

Hi,
I am trying to setup IPTABLES rules. I am newbe to this.

One of the rule in filter table is
#######
-A INPUT -p tcp ! --syn -m state --state NEW -j

LOG

Quoted 1 line

--log-prefix "New not syn:"

Try:
iptables -A INPUT -p tcp ! --tcp-flags SYN SYN -m state --state NEW -j
LOG --log-prefix " New not syn: "

Quoted 10 lines

Note the change in specifying flags from ipchains to iptables. Also note
I added spaces around your prefix. This will make it easier to read in
the logs.

HTH,
C

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

#6 lore raw
Quoted 10 lines · ads nat

Get following error :
[root@allweb root]# /etc/init.d/iptables restart Flushing all current rules and user defined chains:
[ OK ]
Clearing all current rules and user defined chains:
[ OK ]
Applying iptables firewall rules: iptables-restore v1.2.6a: Unknown arg `--tcp-flags'
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

You must need to specify -m tcp to access TCP match options such as --tcp-flags.

Signature · 2 lines
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines

Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!

#7 lore raw
In reply to ads nat
Quoted 5 lines · ads nat

I modified rules as follows :

###########
-A INPUT -p tcp ! --tcp-flags SYN SYN -m state --state NEW -j LOG --log-prefix " New not syn: "

<snip>

Quoted 2 lines

Applying iptables firewall rules: iptables-restore v1.2.6a: Unknown arg `--tcp-flags'

Well this could be your problem. Try upgrading to 1.2.8 or later. Could be the option is not supported in older version, especially as an inverse.

To isolate whether its your script or a version issue, try running the iptables command straight from the command line and see if you get the same error.

HTH,
C

author
#8 lore raw

Ya,
Following worked from command line :
#######
iptables -A INPUT -p tcp ! --tcp-flags SYN SYN -m state --state NEW -j LOG --log-prefix " New not syn: "

#######

Does this means that I should enter all rules from command line.
Please guide me.
Thanks

Quoted 19 lines · --- Chris Brenton
Quoted 4 lines · ads nat

I modified rules as follows :

###########
-A INPUT -p tcp ! --tcp-flags SYN SYN -m state

--state

Quoted 1 line

NEW -j LOG --log-prefix " New not syn: "

<snip>

Quoted 2 lines

Applying iptables firewall rules: iptables-restore v1.2.6a: Unknown arg `--tcp-flags'

Well this could be your problem. Try upgrading to 1.2.8 or later. Could
be the option is not supported in older version, especially as an
inverse.

Quoted 10 lines

To isolate whether its your script or a version issue, try running the
iptables command straight from the command line and see if you get the
same error.

HTH,
C

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

#9 lore raw
Quoted 11 lines · ads nat

Ya,
Following worked from command line :
#######
iptables -A INPUT -p tcp ! --tcp-flags SYN SYN -m state --state NEW -j LOG --log-prefix " New not syn: "

#######

Does this means that I should enter all rules from command line.

If you are using iptables-save and iptables-restore, then yes, you should enter all your rules at the command line, then use iptables-save to keep them for restoring later.

The alternative way to preserve your rules is to write them into a script which gets executed on bootup (or whenever).

Either is good - different people use each.

Antony.

Signature · 7 lines
It is also possible that putting the birds in a laboratory setting 
inadvertently renders them relatively incompetent.

 - Daniel C Dennet

                                                     Please reply to the list;
                                                           please don't CC me.
#10 lore raw
In reply to Chris Brenton
Quoted 4 lines · Chris Brenton
Quoted 2 lines

-A INPUT -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "New not syn:"

iptables -A INPUT -p tcp ! --tcp-flags SYN SYN -m state --state NEW -j LOG --log-prefix " New not syn: "

"--syn" is equivalent to "--tcp-flags SYN,RST,ACK SYN"

I can confirme that iptables-save generates a --tcp-flag line :

cbr@elendil:~$ sudo iptables -A INPUT -p tcp ! --syn -m state
		--state	NEW -j LOG
cbr@elendil:~$ sudo iptables-save
# Generated by iptables-save v1.2.8 on Tue Dec 23 14:44:17 2003
[...]
*filter
:INPUT DROP [529:81210]
[...]
-A INPUT -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state
		--state	NEW -j LOG

So, for the OP (ads nat) : you seem to have modified your ruleset by hand and used a alias (--syn) that iptables-<save/restore> does not understand.

Signature · 2 lines
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines

Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!

author
#11 lore raw

Yes, I have edited "iptables" manually and copies all rule sets to it and then restarted with "/etc/init.d/iptables restart"

Is it not allowed?
Thanks for support

--- Cedric Blancher <[email protected]>

Quoted 28 lines · wrote:
Quoted 1 line · Chris Brenton
Quoted 1 line

-A INPUT -p tcp ! --syn -m state --state NEW -j

LOG

Quoted 2 lines
Quoted 1 line

--log-prefix "New not syn:"

iptables -A INPUT -p tcp ! --tcp-flags SYN SYN -m

state --state NEW -j

Quoted 1 line

LOG --log-prefix " New not syn: "

"--syn" is equivalent to "--tcp-flags SYN,RST,ACK
SYN"

I can confirme that iptables-save generates a
--tcp-flag line :

cbr@elendil:~$ sudo iptables -A INPUT -p tcp ! --syn
-m state
		--state	NEW -j LOG
cbr@elendil:~$ sudo iptables-save
# Generated by iptables-save v1.2.8 on Tue Dec 23
14:44:17 2003
[...]
*filter
:INPUT DROP [529:81210]
[...]
(quoted diff) +0 -2
-A INPUT -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN
-m state

--state NEW -j LOG

Quoted 14 lines

So, for the OP (ads nat) : you seem to have modified your ruleset by
hand and used a alias (--syn) that iptables-<save/restore> does not
understand.

Signature · 3 lines
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint:
FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 1 line
Quoted 1 line

Hi! I'm your friendly neighbourhood signature

virus.

Quoted 1 line
Quoted 1 line

Copy me to your signature file and help me

spread!

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

#12 lore raw
Quoted 1 line · ads nat

Is it not allowed?

When a file is iptables-save generated, it's better not modifying it by hand. Update your running ruleset then issue an

iptables-save > iptables

Signature · 2 lines
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines

Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!

author
#13 lore raw

O.K.
As adviced I have uploaded all rules from command line. With no error. Thanks.
saved them as follows:
[root@allweb root]# iptables-save > iptables

No error. Thanks.

Now I want to add following error at begining of the file from command prompt:

###########
IPTABLES -F INPUT
IPTABLES -F OUTPUT
IPTABLES -F FORWARD

IPTABLES -P INPUT DROP
IPTABLES -P OUTPUT DROP
IPTABLES -P FORWARD DROP
###########

Can I upload straight as done earlier and then give command :
iptables-save > iptables

I am adding rules on live network. I don't want it to stop and create any problems.

After saving all rules, what should be command for rules to save permenantly so that when I reboot system Rules should remain.

I have tried to use iptables-save and iptables-restore but could not use properly, Therefore asking in detail.
Please guide me to do.
Thanks for support.

--- Cedric Blancher <[email protected]>

Quoted 17 lines · wrote:
Quoted 1 line · ads nat

Is it not allowed?

When a file is iptables-save generated, it's better not modifying it by
hand. Update your running ruleset then issue an

iptables-save > iptables

Signature · 3 lines
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint:
FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 1 line
Quoted 1 line

Hi! I'm your friendly neighbourhood signature

virus.

Quoted 1 line
Quoted 1 line

Copy me to your signature file and help me

spread!

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

author
#14 lore raw
In reply to Cedric Blancher

O.K.
As adviced I have uploaded all rules from command line. With no error. Thanks.
saved them as follows:
[root@allweb root]# iptables-save > iptables

No error. Thanks.

Now I want to add following error at begining of the file from command prompt:

###########
IPTABLES -F INPUT
IPTABLES -F OUTPUT
IPTABLES -F FORWARD

IPTABLES -P INPUT DROP
IPTABLES -P OUTPUT DROP
IPTABLES -P FORWARD DROP
###########

Can I upload straight as done earlier and then give command :
iptables-save > iptables

I am adding rules on live network. I don't want it to stop and create any problems.

After saving all rules, what should be command for rules to save permenantly so that when I reboot system Rules should remain.

I have tried to use iptables-save and iptables-restore but could not use properly, Therefore asking in detail.
Please guide me to do.
Thanks for support.

--- Cedric Blancher <[email protected]>

Quoted 17 lines · wrote:
Quoted 1 line · ads nat

Is it not allowed?

When a file is iptables-save generated, it's better not modifying it by
hand. Update your running ruleset then issue an

iptables-save > iptables

Signature · 3 lines
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint:
FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 1 line
Quoted 1 line

Hi! I'm your friendly neighbourhood signature

virus.

Quoted 1 line
Quoted 1 line

Copy me to your signature file and help me

spread!

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

#15 lore raw
In reply to ads nat

Holy Moly, all the smart people are here today! I can see ads nat is in good hands so I'm going to keep my mouth shut for once. ;-)

Quoted 39 lines · ads nat

Hi,
I am trying to setup IPTABLES rules. I am newbe to this.

One of the rule in filter table is ####### -A INPUT -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "New not syn:"
#############

I am getting following error :

[root@allweb root]# /etc/init.d/iptables restart Flushing all current rules and user defined chains:
[ OK ]
Clearing all current rules and user defined chains:
[ OK ]
Applying iptables firewall rules: iptables-restore v1.2.6a: Unknown arg `--syn'
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

I am using /etc/init.d/iptables restart to apply
iptables rules.

I think I have used proper syntax "--syn" from Oskar Anderson IPTABLES tutorials.

Looking for support.
Thanks

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree