How to block multiple ports in iptables, ipset?

postcd

Member
Credits
89
Hello,

on CentOS 6, iptables 1.4.7

i can use rule to block IPs in my IPSet from accessing one port, example SSH:

Code:
-A INPUT -p tcp --dport 22 -m set --match-set blocklist src -j DROP
(note that this is not iptables command but a line from a save file "iptalbes-save > output")

But how to block multiple ports, example 21,22,25 ?

I tried --dports 21,22,25, but iptables not wanted to import it saying: iptables-restore v1.4.7: unknown option `--dports'
 


Lazydog

Member
Credits
0
To block multiple ports with IPTABLES you need something like this:

Code:
iptables -A INPUT -p tcp -m multiport --destination-port 22,53,80,110
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Latest posts

Top