Block or Allow port ranges using IPTables

You can use the IPTables to block a port range with a single statement, rather than writing the same line again and again.

Below is a simple example where I had blocked FTP ports 20 and 21 using a single line. Thus reducing my keystrokes.

iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 20:21 -j REJECT

Here is a step by step screenshot from my machine, for the tip.

Don’t forget to “like” and “share”. Also view this post on Network NUTS Facebook Page.

Using IPTables to allow or block port range

Using IPTables to allow or block port range

Advertisements