| Linux | Security | Debian | Slax | Tiny Core | Health |
|
Iptables 1 Iptables 3 Iptables 4 Iptables 9 Erase Everything from a Hard Drive |
Iptables 6Add RulesRule OrderThe order Iptables rules are written is important. With each packet that comes into the computer, Iptables goes through the rules in the order they are written until it finds a rule applicable to that package. It is dealt with as determined by that rule, and Iptables is finished with it. As you add rules, think about the order they are written, and put them in the correct order. Allow IP Addresses Not PortsThe Iptables rules in the examples have allowed ports 53 and 80. Your computer will be more secure if you allow additional IP addresses, not ports. Do this where practical. You can find these by looking at your Iptables log file. Adding RulesYou decide what rules you want to add to your iptables set up. Following are a few examples. Allow IP AddressesYou may find the firewall has blocked something, and you can't access it. If this happens, note the time you tried to access it, look at your log file and see if there were logs with the prefix "InDrop" at that time. You can then add a rule to allow whatever is being dropped. To allow IP addresses, insert lines similar to this, with the appropriate IP address numbers.
Block IP AddressesYou may want to block IP addresses, to prevent anything undesirable coming into your computer, or to restrict what young children or employees can access. To do this, insert lines similar to this, with the appropriate IP address numbers.
Allow PortsYou Iptables set up already includes a line accepting tcp protocol from source port 80.
To add other ports or protocols, insert similar lines, changing the "80" to whatever port you want, and the "tcp" to whatever protocol you want. Block PortsTo block ports, insert lines similar to this, with whatever ports and protocols you want to block.
Combine Port, Protocol and IP AddressYou can combine all these things, and have the protocol, port, and IP address, all in one rule.
You would use a rule like this where you want to allow a certain port or protocol from an IP address, but drop other things from that IP address. Output ChainYou may add rules to the OUTPUT chain. Use similar rules replacing "INPUT" with "OUTPUT," and "s" which stands for source, with "d" which stands for destination. Established or Related RuleBe aware, many things will be allowed into the computer from sources not specifically mentioned in Iptables rules because of the established or related rule. Checking the Iptables SetupPreviously "iptables -L" was used to check the iptables set up. If you use this when including rules containing IP addresses, Iptables will try to find the name of each IP address, and this may take some time. The output will be quicker if you use:
The "n" stands for numeric. © Copyright Guy Shipard 2008 - 2009 |