44

This doesn't work for me:

# iptables -A INPUT -p tcp --dports 110,143,993,995 -j ACCEPT

iptables v1.4.7: unknown option `--dports'
Try `iptables -h' or 'iptables --help' for more information.

However in the man page, there is an option --dports... any ideas?

Cristian Ciupitu
  • 6,226
  • 2
  • 41
  • 55
Zenet
  • 878
  • 4
  • 10
  • 14
  • 8
    Quick guess would be that you need to use the multiport module: `-m multiport --dports 110,143,993,995 ...` – cyberx86 Jan 24 '12 at 15:55

2 Answers2

73

You have to use --match multiport in the rule for defining more ports

#iptables -A INPUT -p tcp  --match multiport --dports 110,143,993,995 -j ACCEPT
Mughil
  • 1,869
  • 1
  • 18
  • 28
14

You need to specify the -m multiport module before using the dports options

kaji
  • 2,510
  • 16
  • 17