Ip tables rules block specific range

Posted on 2014-03-06
Last Modified: 2014-10-21
I need help writing iptables rules that will allow a certain range of private address (  outgoing access to one or two specific named sites and nothing else.

Here is my current setup
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 81 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

Thank you
Question by:santasvillage
  • 3
  • 2

Assisted Solution

by:Jordan Medlen
Jordan Medlen earned 250 total points
ID: 39909291
You would use the following syntax...

-m iprange --src-range -j ACTION

You can read more in the following article.

Author Comment

ID: 39909493
Could you give more specific help?  This really is not my forte..

Thank you

Expert Comment

by:Jordan Medlen
ID: 39909513
What are the two named sites that you want the IP addresses internally to be able to get to?
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!


Author Comment

ID: 39909525
I do not know the exact domain names as of yet, will know soon, they are for a credit card processor.


we could use any site as an example:
so are allowed to go to and no where else?

A proxy server is not a viable alternative right now

Thank you

Author Comment

ID: 39926489
LVL 27

Accepted Solution

skullnobrains earned 250 total points
ID: 39931405
-A INPUT --src-range -m tcp -p tcp --dport 22 -j ACCEPT

would restrict your rule that allows ssh to the corresponding source range


you can remove the rule
and also " -m state --state NEW"
as all this is implicit in netfilter


don't freak, not understanding it quickly does not mean you are out of your league : netfilter uses a crazy syntax and it's documentation is far from complete, not to mention all the other reasons i have to hate it but that would probably start a useless flame war. if you can use pf or ipf, do so, it you're stuck with linux, you may consider installing one of the numerous so called "firewalls" that actually have simpler rule syntaxes and generate configs for netfilter so you don't have to learn the syntax yourself

Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
OpenWrt 1 47
Bonjour traffic not going through sonicwall fw 6 120
How to connect witth Remote Desktop 2 computers using Comodo Firewall 10 132
Palo Alto Networks Global Protect 2 147
Wikipedia defines 'Script Kiddies' in this informal way: "In hacker culture, a script kiddie, occasionally script bunny, skiddie, script kitty, script-running juvenile (SRJ), or similar, is a derogatory term used to describe those who use scripts or…
Do you have a windows based Checkpoint SmartCenter for centralized Checkpoint management?  Have you ever backed up the firewall policy residing on the SmartCenter?  If you have then you know the hassles of connecting to the server, doing an upgrade_…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question