2004-06-10 13:47:11 +08:00
|
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2007-04-05 03:42:53 +08:00
|
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
2004-06-10 13:47:11 +08:00
|
|
|
<!ENTITY % general-entities SYSTEM "../../general.ent">
|
|
|
|
%general-entities;
|
|
|
|
|
2006-08-09 22:21:54 +08:00
|
|
|
<!ENTITY iptables-download-http "http://www.netfilter.org/projects/iptables/files/iptables-&iptables-version;.tar.bz2">
|
2004-06-10 13:47:11 +08:00
|
|
|
<!ENTITY iptables-download-ftp "ftp://ftp.netfilter.org/pub/iptables/iptables-&iptables-version;.tar.bz2">
|
2010-03-07 07:42:24 +08:00
|
|
|
<!ENTITY iptables-md5sum "645941dd1f9e0ec1f74c61918d70d52f">
|
|
|
|
<!ENTITY iptables-size "456 KB">
|
|
|
|
<!ENTITY iptables-buildsize "10.5 MB">
|
|
|
|
<!ENTITY iptables-time "0.2 SBU">
|
2004-06-10 13:47:11 +08:00
|
|
|
]>
|
|
|
|
|
2007-02-15 01:41:56 +08:00
|
|
|
<sect1 id="iptables" xreflabel="iptables-&iptables-version;">
|
2005-05-14 19:01:30 +08:00
|
|
|
<?dbhtml filename="iptables.html"?>
|
|
|
|
|
|
|
|
<sect1info>
|
|
|
|
<othername>$LastChangedBy$</othername>
|
|
|
|
<date>$Date$</date>
|
|
|
|
</sect1info>
|
|
|
|
|
|
|
|
<title>Iptables-&iptables-version;</title>
|
|
|
|
|
|
|
|
<indexterm zone="iptables">
|
|
|
|
<primary sortas="a-Iptables">Iptables</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
|
|
|
<sect2 role="package">
|
|
|
|
<title>Introduction to Iptables</title>
|
|
|
|
|
|
|
|
<para>The next part of this chapter deals with firewalls. The principal
|
2010-03-07 07:42:24 +08:00
|
|
|
firewall tool for Linux is <application>iptables</application>. You will
|
|
|
|
need to install <application>iptables</application> if you intend on using
|
|
|
|
any form of a firewall.</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
|
|
|
|
<bridgehead renderas="sect3">Package Information</bridgehead>
|
|
|
|
<itemizedlist spacing="compact">
|
|
|
|
<listitem>
|
|
|
|
<para>Download (HTTP): <ulink url="&iptables-download-http;"/></para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>Download (FTP): <ulink url="&iptables-download-ftp;"/></para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>Download MD5 sum: &iptables-md5sum;</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>Download size: &iptables-size;</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>Estimated disk space required: &iptables-buildsize;</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>Estimated build time: &iptables-time;</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
2004-06-10 13:47:11 +08:00
|
|
|
|
2006-04-11 02:38:22 +08:00
|
|
|
<para condition="html" role="usernotes">User Notes:
|
|
|
|
<ulink url="&blfs-wiki;/iptables"/></para>
|
|
|
|
|
2007-02-08 03:59:33 +08:00
|
|
|
</sect2>
|
2004-06-10 13:47:11 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<sect2 role="kernel" id='iptables-kernel'>
|
|
|
|
<title>Kernel Configuration</title>
|
2004-06-10 13:47:11 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<para>A firewall in Linux is accomplished through a portion of the
|
|
|
|
kernel called netfilter. The interface to netfilter is
|
|
|
|
<application>iptables</application>. To use it, the appropriate
|
2010-03-07 07:42:24 +08:00
|
|
|
kernel configuration parameters are found in Networking Support ⇒
|
|
|
|
Networking Options ⇒ Network Packet Filtering Framework.</para>
|
2005-03-11 11:40:05 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<indexterm zone="iptables iptables-kernel">
|
|
|
|
<primary sortas="d-iptables">Iptables</primary>
|
|
|
|
</indexterm>
|
2005-01-27 10:31:07 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
</sect2>
|
2005-01-27 10:31:07 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<sect2 role="installation">
|
|
|
|
<title>Installation of Iptables</title>
|
2005-01-27 10:31:07 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<note>
|
2007-02-08 03:59:33 +08:00
|
|
|
<para>The installation below does not include building some specialized
|
|
|
|
extension libraries which require the raw headers in the
|
|
|
|
<application>Linux</application> source code. If you wish to build the
|
|
|
|
additional extensions (if you aren't sure, then you probably don't), you
|
|
|
|
can look at the <filename>INSTALL</filename> file to see an example of
|
|
|
|
how to change the <parameter>KERNEL_DIR=</parameter> parameter to point
|
|
|
|
at the <application>Linux</application> source code. Note that if you
|
|
|
|
upgrade the kernel version, you may also need to recompile
|
2007-02-08 04:18:00 +08:00
|
|
|
<application>iptables</application> and that the BLFS team has not tested
|
|
|
|
using the raw kernel headers.</para>
|
2007-02-08 03:59:33 +08:00
|
|
|
|
|
|
|
<!-- <para>Installation of <application>iptables</application> will fail
|
2005-05-14 19:01:30 +08:00
|
|
|
if raw kernel headers are found in <filename
|
|
|
|
class='directory'>/usr/src/linux</filename> either as actual files
|
|
|
|
or a symlink. As of the Linux 2.6 kernel series, this directory
|
|
|
|
should no longer exist because appropriate headers were installed
|
2005-07-27 03:55:34 +08:00
|
|
|
from the <application>Linux-Libc-Headers</application> package during
|
2007-02-08 03:59:33 +08:00
|
|
|
the base LFS installation.</para> -->
|
2008-05-09 20:42:27 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<para>For some non-x86 architectures, the raw kernel headers may be
|
2007-02-08 03:59:33 +08:00
|
|
|
required. In that case, modify the <parameter>KERNEL_DIR=</parameter>
|
|
|
|
parameter to point at the <application>Linux</application> source
|
|
|
|
code.</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
</note>
|
|
|
|
|
|
|
|
<para>Install <application>iptables</application> by running the following
|
|
|
|
commands:</para>
|
|
|
|
|
2010-03-07 07:42:24 +08:00
|
|
|
<screen><userinput>./configure --prefix=/usr &&
|
|
|
|
make</userinput></screen>
|
2007-02-08 03:59:33 +08:00
|
|
|
|
|
|
|
<para>This package does not come with a test suite.</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
|
|
|
|
<para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
|
|
|
|
2010-03-07 07:42:24 +08:00
|
|
|
<screen role="root"><userinput>make install</userinput></screen>
|
2005-05-14 19:01:30 +08:00
|
|
|
|
|
|
|
</sect2>
|
2010-03-07 07:42:24 +08:00
|
|
|
<!--
|
2005-05-14 19:01:30 +08:00
|
|
|
<sect2 role="commands">
|
|
|
|
<title>Command Explanations</title>
|
|
|
|
|
2007-08-02 22:50:17 +08:00
|
|
|
<para><command>sed -i 's/name="$node/name="node/' iptables.xslt</command>:
|
|
|
|
This corrects a syntax error in the XSLT stylesheet for use with
|
|
|
|
<command>iptables-xml</command>.</para>
|
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<para><parameter>PREFIX=/usr LIBDIR=/lib BINDIR=/sbin</parameter>:
|
2007-08-02 22:50:17 +08:00
|
|
|
Compiles and installs <application>iptables</application> modules
|
2005-05-14 19:01:30 +08:00
|
|
|
into <filename class="directory">/lib</filename>, binaries into
|
|
|
|
<filename class="directory">/sbin</filename> and the remainder into
|
|
|
|
the <filename class="directory">/usr</filename> hierarchy instead of
|
|
|
|
<filename class="directory">/usr/local</filename>. Firewalls are
|
|
|
|
generally activated during the boot process and
|
|
|
|
<filename class="directory">/usr</filename> may not be mounted at
|
|
|
|
that time.</para>
|
|
|
|
|
2007-02-08 03:59:33 +08:00
|
|
|
<para><parameter>KERNEL_DIR=/usr</parameter>: This parameter is used to
|
|
|
|
point at the sanitized kernel headers in
|
|
|
|
<filename class='directory'>/usr</filename> and not use the raw kernel
|
|
|
|
headers in <filename class='directory'>/usr/src/linux</filename>.</para>
|
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
</sect2>
|
2010-03-07 07:42:24 +08:00
|
|
|
-->
|
2005-05-14 19:01:30 +08:00
|
|
|
<sect2 role="configuration">
|
|
|
|
<title>Configuring Iptables</title>
|
|
|
|
|
|
|
|
<para>Introductory instructions for configuring your firewall are
|
2008-03-13 00:05:41 +08:00
|
|
|
presented in the next section: <xref linkend="fw-firewall"/></para>
|
2005-05-14 19:01:30 +08:00
|
|
|
|
|
|
|
<sect3 id="iptables-init">
|
|
|
|
<title>Boot Script</title>
|
|
|
|
|
|
|
|
<para>To set up the iptables firewall at boot, install the
|
|
|
|
<filename>/etc/rc.d/init.d/iptables</filename> init script included
|
2005-12-29 09:38:36 +08:00
|
|
|
in the <xref linkend="bootscripts"/> package.</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
|
|
|
|
<indexterm zone="iptables iptables-init">
|
|
|
|
<primary sortas="f-iptables">iptables</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
|
|
|
<screen role="root"><userinput>make install-iptables</userinput></screen>
|
|
|
|
|
|
|
|
</sect3>
|
|
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
|
|
<sect2 role="content">
|
|
|
|
<title>Contents</title>
|
|
|
|
|
|
|
|
<segmentedlist>
|
|
|
|
<segtitle>Installed Programs</segtitle>
|
|
|
|
<segtitle>Installed Libraries</segtitle>
|
2010-03-07 07:42:24 +08:00
|
|
|
<segtitle>Installed Directories</segtitle>
|
2005-05-14 19:01:30 +08:00
|
|
|
|
|
|
|
<seglistitem>
|
2010-03-07 07:42:24 +08:00
|
|
|
<seg>iptables, iptables-restore, iptables-save, iptables-xml,
|
|
|
|
iptables-multi, ip6tables, ip6tables-restore, ip6tables-save,
|
|
|
|
and ip6tables-multii</seg>
|
|
|
|
<seg>libip4tc.so, libip6tc.so, libiptc.so, libxtables.so,
|
|
|
|
and numerous modules in /usr/libexec/xtables/</seg>
|
|
|
|
<seg>/usr/libexec/xtables and /usr/include/libiptc</seg>
|
2005-05-14 19:01:30 +08:00
|
|
|
</seglistitem>
|
|
|
|
</segmentedlist>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
|
|
|
<?dbfo list-presentation="list"?>
|
|
|
|
<?dbhtml list-presentation="table"?>
|
|
|
|
|
|
|
|
<varlistentry id="iptables-prog">
|
|
|
|
<term><command>iptables</command></term>
|
|
|
|
<listitem>
|
|
|
|
<para>is used to set up, maintain, and inspect the tables of
|
2010-03-07 07:42:24 +08:00
|
|
|
IP packet filter rules in the Linux kernel. It is a
|
|
|
|
symbolic link to iptables-multi.</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
<indexterm zone="iptables iptables-prog">
|
|
|
|
<primary sortas="b-iptables">iptables</primary>
|
|
|
|
</indexterm>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry id="iptables-restore">
|
|
|
|
<term><command>iptables-restore</command></term>
|
|
|
|
<listitem>
|
|
|
|
<para>is used to restore IP Tables from data
|
|
|
|
specified on STDIN. Use I/O redirection provided by your
|
2010-03-07 07:42:24 +08:00
|
|
|
shell to read from a file. It is a symbolic link to
|
|
|
|
iptables-multi.</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
<indexterm zone="iptables iptables-restore">
|
|
|
|
<primary sortas="b-iptables-restore">iptables-restore</primary>
|
|
|
|
</indexterm>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry id="iptables-save">
|
|
|
|
<term><command>iptables-save</command></term>
|
|
|
|
<listitem>
|
|
|
|
<para>is used to dump the contents of an IP Table
|
|
|
|
in easily parseable format to STDOUT. Use I/O-redirection
|
2010-03-07 07:42:24 +08:00
|
|
|
provided by your shell to write to a file. It is a symbolic link to
|
|
|
|
iptables-multi.</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
<indexterm zone="iptables iptables-save">
|
|
|
|
<primary sortas="b-iptables-save">iptables-save</primary>
|
|
|
|
</indexterm>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2007-08-02 22:50:17 +08:00
|
|
|
<varlistentry id="iptables-xml">
|
|
|
|
<term><command>iptables-xml</command></term>
|
|
|
|
<listitem>
|
|
|
|
<para>is used to convert the output of
|
|
|
|
<command>iptables-save</command> to an XML format. Using the
|
|
|
|
<filename>iptables.xslt</filename> stylesheet converts the XML
|
2010-03-07 07:42:24 +08:00
|
|
|
back to the format of <command>iptables-restore</command>.
|
|
|
|
It is a symbolic link to iptables-multi.</para>
|
2007-08-02 22:50:17 +08:00
|
|
|
<indexterm zone="iptables iptables-xml">
|
|
|
|
<primary sortas="b-iptables-xml">iptables-xml</primary>
|
|
|
|
</indexterm>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<varlistentry id="ip6tables">
|
2010-03-07 07:42:24 +08:00
|
|
|
<term><command>ip6tables*</command></term>
|
2005-05-14 19:01:30 +08:00
|
|
|
<listitem>
|
2010-03-07 07:42:24 +08:00
|
|
|
<para>are a set of commands for IPV6 that parallel the iptables
|
|
|
|
commands above. All of these commands are symbolic
|
|
|
|
links to ip6tables-multi.</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
<indexterm zone="iptables ip6tables">
|
|
|
|
<primary sortas="b-ip6tables">ip6tables</primary>
|
|
|
|
</indexterm>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
</variablelist>
|
|
|
|
|
|
|
|
</sect2>
|
2004-06-10 13:47:11 +08:00
|
|
|
|
2002-07-08 04:28:42 +08:00
|
|
|
</sect1>
|