Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Is it possible to add a IPTABLES rule which allows all the protocols for specific source and destination ports? I tried the following but it didn't work.

iptables -I FORWARD 1 -s -d -p 0 --sport 0:65535 --dport 1191:1191 -j ACCEPT

iptables error: unknown option `--sport`

Any comments are greatly appreciated.

share|improve this question
Many protocols do not have ports (gre, icmp, etc). – Zoredache Aug 8 '12 at 22:43
Yes. I notice when you use -p tcp --dports and save the firewall state, the save file also has -m tcp on each line, which implies to me that you cant do it for multiple protocols. I don't know for certain though. – Sirex Aug 8 '12 at 22:45
up vote 2 down vote accepted

You can't use --sport or --dport with -p 0 (or -p all) because IP transport layer can have protocols that aren't tied to ports. You can do this with protocols like udp/tcp/sctp/etc.

share|improve this answer

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.