I have a few ip ranges to which I want my server to able to connect and users to connect from. Everything else should be blocked.
How should I do that with iptables?
My OS is Debian based linux distribution.
|
|
|
I'd suggest grabbing a sinmple firewall config tool, scuch a Firestarter, and going from there. Here are some basics for you, though.
|
|||||||
|
This will turn your system into a non-existent system for non-allowed computers. |
|||
|
|
|
If you want to allow arbitrary ranges rather than entire subnets, you can use the 'iprange' iptables module:
for example, will allow traffic coming from all machines with addressess between 192.168.1.30 and 192.168.1.50. If you want to allow incoming and outgoing traffic to the same range of IP's, I'd suggest that you create a specific chain allowing that IPs and targeting all the input and output target to it: --define the default policies to drop everithing:
--create the new chain:
--if the source is part of the allowed range, accept
--if not, return to the caller chain to continue processing
--make all traffic entering and leaving the machine go through our new chain
and that's it! of course you may need aditional rules, such as one allowing all traffic from/to the lo interface, etc. |
|||
|
|
|
Once you are happy with your rules, you probably want to save them. The comments in this link have several options on how to do that. An easy to use iptables rules generator for simple needs is ufw. The package is available in debian unstable. Also try Firestarter. Available in lenny. |
|||
|
|