# iptables multiple --dports ?

## njcwotx

I have several ports to open and close from a script regularly.

Up to now, I have been doing one --dport per line, but when I attempt to give it a list of --dports, it fails.

For Example this works..

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

but this fails...

iptables -A INPUT -p tcp --dport 80,443 -j ACCEPT

the only difference is I gave it a comma separated list.

I know that the : operator can give a RANGE, but these are obviously separated by many other ports.

iptables -A INPUT -p tcp --dport 80:443 -j ACCEPT

Is there a way to give it a list of separate ports without going into multiple lines?

----------

## PaulBredbury

```
man iptables-extensions
```

And search for multiport.

----------

