How to specify a range of IP addresses or ports for linux firewall via iptables:
ip range – iptables configuration syntax:
-m iprange –src-range IPA-IPB -j ACTION
-m iprange –dst-range IPA-IPB -j ACTION
For example, allow incoming request on a port 411 for source IP in the 192.168.0.1-192.168.0.254 range, you need to add next acl/rules in iptables:
-A INPUT -p tcp --dport 411 -m iprange --src-range 192.168.0.1-192.168.0.254 -j ACCEPT
port range – iptables configuration syntax:
–sport porta:portb (if -p tcp is specified)
–dport porta:portb
Example (block all incoming ssh and ftp for source port range 513:65535) :
-A INPUT -p tcp -s 0/0 --sport 513:65535 --dport 20:22 -m state --state NEW,ESTABLISHED -j DROP



