Linux Security Debian Slax Tiny Core Health

Security

Frugal Install

Encryption

Definitions

Iptables 1
Set Up a Simple Firewall

Iptables 2
Simplify the Setup

Iptables 3
Start the Firewall Automatically

Iptables 4
Change the Policy to Drop

Iptables 5
Logging

Iptables 6
Add Rules

Iptables 7
IP Address Blocks

Iptables 8
Add Chains

Iptables 9
Change Rules While in Use

Iptables Summary

Graphical Firewalls

Check for Malware

Erase Everything from a Hard Drive

Security Links


Other Links


Contact Details

Iptables 2

Simplify the Set Up

You have seen how to set up a firewall. But it would take a long time if you typed all of the commands each time. Let's simplify the process.

Open the Text Editor, not the Terminal this time, and type everything into a file, so it can be saved and used again. This will eliminate the need to type all of the commands every time you set up a firewall.

Type:

iptables -F

This tells iptables to flush, or delete everything from Iptables. Without this, the rules would be added again, so each rule would be written twice.

Still using the Text Editor, type all of the commands used on the previous page.

When you have finished, save the file.

You should now have:

iptables -F
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A INPUT -j DROP

Copy all of the lines together, and paste them to the Root Terminal.

Notice, the terminal will process them one after another.

You may need to press "Enter," when it gets to the last line. This depends on whether you copied the return at the end of the last line. If you are not sure, there is no harm in pressing "Enter" again. When copying the iptables set up, if you include the return at the end of the last line, you will not need to press enter when it gets to the last line.

If you typed something incorrectly, you may get a message following that line. Check that there are no messages. You can scroll up in the terminal if it is already off the top of the screen. If you made a mistake, correct it in your file with the Text Editor, and paste the whole lot again.

Now, every time you want to set up Iptables, you can copy this file, and paste it to Iptables.


Save Your Iptables Setup

If you want to add more commands, you can add them to your file with the Text Editor, and paste the whole lot again. Save each new rule you want to add, in your file. If you keep a record of you iptables set up, setting it up again in the future will be quick and easy.


< Iptables 1 Set Up a Simple Firewall

Iptables 3 Start the Firewall Automatically >


© Copyright Guy Shipard 2008 - 2009