Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write IPtables rules,but I'm finding it difficult.

I've got:

iptables -A FORWARD -m state –state RELATED,ESTABLISHED -j ACCEPT

which fails with Bad argument `–state'


iptables -t nat -A POSTROUTING -s -j SNAT –to server.ip

which fails with Bad argument `–to'

How do I rectify the rules?

share|improve this question
up vote 9 down vote accepted

Long form options require two - hyphen characters, not one, and it doesn't allow a dash . So use --state instead of -state. Perhaps your text editor is converting a double -- to a dash ? Do not use Word, Wordpad, or some other office product for editing, they almost always try to automatically make changes like this for you. Use a text editor like vi, emacs, nano, notepad++/notepad/etc, or anything else designed for scripting or programming.

share|improve this answer
I still long for the day when SF implements the "long upvote" that is equivalent to two, or maybe 10-15, upvotes. "Text editors" that correct -- to an m-dash are an abomination! – MadHatter Feb 15 '12 at 23:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.