In most Linux installs iptables has become a standard option, especially Red Hat. There is a very good chance that iptables is already installed on your machine.
Check by:
- Opening a terminal window (making sure to be logged in as root).
-
- Typing: # iptables
- If iptables is installed, you should get the following message:
iptables v1.2.8: no command specified
Try 'iptables -h' or 'iptables --help' for more information
- If this message does not appear, then follow the directions below to install iptables.
This document will give a quick overview of how to install iptables manually, but each distribution's package manager (apt-get for Debian, YaST2 for SuSE, and so on) should be able to install iptables for you.
Manual Instructions
Manually installing iptables may be a bit more complicated, but it allows you to use the latest version of iptables as well as any additional options that you may wish to install. However, you will not be able to use your distribution's packet manager to update it later. This document will run through the basic install steps that should work on nearly all versions of Linux.
Note: Manual installation also requires that the kernel-source package be installed. This can usually be installed through each distributions package utility, please check your distributions instructions for installing the kernel-source packages.
- Get the iptables tarball containing all the needed files.
- To get the latest version of iptables go to netfilter.org
-
- Downloads are available at http://www.netfilter.org/downloads.html
-
- The file should be named iptables-1.*.*.tar.bz2 where the asterisks represent the numbers of the latest version
-
- Save this file to a temporary directory, we will use /tmp in this example.
-
Open a terminal window.
- Change your directory to where you saved iptables by typing:
# cd /tmp
- Uncompress the archive to the /usr/src directory by typing:
# tar -xvjf ./iptables-1.*.*.tar.bz2 -C /usr/src
where the asterisks represent the version number of the file you downloaded.
- Change to the directory it created (typically iptables-1.*.*), by typing:
# cd /usr/src/iptables-1.*.*
- Using the kernel directories above, type:
# /bin/sh -c make
- To finish the install, type:
# /bin/sh -c make install
Iptables should now be installed. You can test the installation as described in the beginning of this section to see if it is working.
If the above install steps seemed to execute without any error, but typing:
# iptables -V
brings up an error, it is possible that the program did not install itself to the sbin directory. To fix this, type the following command from the iptables-1.*.* directory:
ComputerName:~# cp ./iptables /sbin