How to allow a range of IP's with IPTABLES?

Solution 1:

If you only want to allow a certain range of IP addresses inside of (such as from through you can use the following command:

iptables -A INPUT -i eth1 -m iprange --src-range -j ACCEPT

If you want to allow the entire range you can use this instead:

iptables -A INPUT -i eth1 -s -j ACCEPT

See iptables man page and this question here on ServerFault: Whitelist allowed IPs (in/out) using iptables

Solution 2:

For a specific port, say 22:

iptables -A INPUT -p tcp  -m iprange --src-range  --dport 22  -j ACCEPT