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">
|
2018-08-01 07:23:44 +08:00
|
|
|
<!ENTITY iptables-md5sum "3874ca08438be68cd793558283df48d1">
|
|
|
|
<!ENTITY iptables-size "664 KB">
|
|
|
|
<!ENTITY iptables-buildsize "17 MB">
|
2018-02-05 05:44:44 +08:00
|
|
|
<!ENTITY iptables-time "0.1 SBU">
|
2004-06-10 13:47:11 +08:00
|
|
|
]>
|
|
|
|
|
2012-08-13 23:17:23 +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>
|
|
|
|
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
2013-03-16 20:11:58 +08:00
|
|
|
The next part of this chapter deals with firewalls. The principal
|
2012-08-13 23:17:23 +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
|
|
|
|
2018-02-22 07:57:03 +08:00
|
|
|
&lfs82_checked;
|
2011-12-07 07:38:54 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<bridgehead renderas="sect3">Package Information</bridgehead>
|
|
|
|
<itemizedlist spacing="compact">
|
|
|
|
<listitem>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
Download (HTTP): <ulink url="&iptables-download-http;"/>
|
|
|
|
</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
Download (FTP): <ulink url="&iptables-download-ftp;"/>
|
|
|
|
</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
Download MD5 sum: &iptables-md5sum;
|
|
|
|
</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
Download size: &iptables-size;
|
|
|
|
</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
Estimated disk space required: &iptables-buildsize;
|
|
|
|
</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
Estimated build time: &iptables-time;
|
|
|
|
</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
2013-03-16 20:11:58 +08:00
|
|
|
|
2015-12-20 02:51:32 +08:00
|
|
|
<bridgehead renderas="sect3">Iptables Dependencies</bridgehead>
|
|
|
|
|
|
|
|
<bridgehead renderas="sect4">Optional</bridgehead>
|
|
|
|
<para role="optional">
|
|
|
|
<ulink url="http://www.netfilter.org/projects/nftables/index.html">nftables</ulink>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
2006-04-11 02:38:22 +08:00
|
|
|
<para condition="html" role="usernotes">User Notes:
|
2012-08-13 23:17:23 +08:00
|
|
|
<ulink url="&blfs-wiki;/iptables"/>
|
|
|
|
</para>
|
2007-02-08 03:59:33 +08:00
|
|
|
</sect2>
|
2004-06-10 13:47:11 +08:00
|
|
|
|
2012-08-13 23:17:23 +08:00
|
|
|
<sect2 role="kernel" id="iptables-kernel">
|
2005-05-14 19:01:30 +08:00
|
|
|
<title>Kernel Configuration</title>
|
2004-06-10 13:47:11 +08:00
|
|
|
|
2012-08-13 23:17:23 +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
|
2014-12-06 18:58:17 +08:00
|
|
|
kernel configuration parameters are found in:
|
2012-08-13 23:17:23 +08:00
|
|
|
</para>
|
2005-03-11 11:40:05 +08:00
|
|
|
|
2014-12-06 18:58:17 +08:00
|
|
|
<screen><literal>[*] Networking support ---> [CONFIG_NET]
|
|
|
|
Networking Options --->
|
|
|
|
[*] Network packet filtering framework (Netfilter) ---> [CONFIG_NETFILTER]</literal></screen>
|
|
|
|
|
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>
|
2012-08-13 23:17:23 +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
|
|
|
|
<application>Iptables</application> and that the BLFS team has not tested
|
|
|
|
using the raw kernel headers.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
For some non-x86 architectures, the raw kernel headers may be
|
|
|
|
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>
|
|
|
|
|
2018-08-01 07:23:44 +08:00
|
|
|
<para>
|
|
|
|
Disable libebt/libarp extensions if
|
|
|
|
<ulink url="http://www.netfilter.org/projects/nftables/index.html">nftables</ulink>
|
|
|
|
is not installed to prevent a build failure:
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<screen><userinput>ded -i -e '/libebt_/s/^/#/' \
|
|
|
|
-e '/libarpt_/s/^/#/' extensions/GNUmakefile.in
|
|
|
|
</userinput></screen>
|
|
|
|
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
Install <application>Iptables</application> by running the following
|
|
|
|
commands:
|
|
|
|
</para>
|
|
|
|
|
2015-12-20 02:51:32 +08:00
|
|
|
<screen><userinput>./configure --prefix=/usr \
|
|
|
|
--sbindir=/sbin \
|
|
|
|
--disable-nftables \
|
|
|
|
--enable-libipq \
|
2015-02-21 04:02:49 +08:00
|
|
|
--with-xtlibdir=/lib/xtables &&
|
2010-03-07 07:42:24 +08:00
|
|
|
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>
|
|
|
|
|
2011-12-07 07:38:54 +08:00
|
|
|
<screen role="root"><userinput>make install &&
|
2013-01-06 04:58:22 +08:00
|
|
|
ln -sfv ../../sbin/xtables-multi /usr/bin/iptables-xml &&
|
2015-02-21 04:02:49 +08:00
|
|
|
|
2013-12-26 08:01:25 +08:00
|
|
|
for file in ip4tc ip6tc ipq iptc xtables
|
2013-01-06 04:58:22 +08:00
|
|
|
do
|
2013-12-26 08:01:25 +08:00
|
|
|
mv -v /usr/lib/lib${file}.so.* /lib &&
|
|
|
|
ln -sfv ../../lib/$(readlink /usr/lib/lib${file}.so) /usr/lib/lib${file}.so
|
2013-01-06 04:58:22 +08:00
|
|
|
done</userinput></screen>
|
2005-05-14 19:01:30 +08:00
|
|
|
|
|
|
|
</sect2>
|
2010-03-07 08:34:03 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<sect2 role="commands">
|
|
|
|
<title>Command Explanations</title>
|
|
|
|
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
2015-12-21 02:43:13 +08:00
|
|
|
<parameter>--disable-nftables</parameter>: This switch disables building
|
2016-06-05 13:57:10 +08:00
|
|
|
nftables compat. Omit this switch if you have installed nftables.
|
2012-08-13 23:17:23 +08:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2015-12-20 02:51:32 +08:00
|
|
|
<parameter>--enable-libipq</parameter>: This switch enables building
|
2012-08-13 23:17:23 +08:00
|
|
|
of <filename class="libraryfile">libipq.so</filename> which
|
|
|
|
can be used by some packages outside of BLFS.
|
|
|
|
</para>
|
|
|
|
|
2015-12-20 02:51:32 +08:00
|
|
|
<para>
|
|
|
|
<parameter>--with-xtlibdir=/lib/xtables</parameter>: Ensure all
|
|
|
|
<application>Iptables</application> modules are installed in the
|
|
|
|
<filename class="directory">/lib/xtables</filename> directory.
|
|
|
|
</para>
|
|
|
|
|
2013-11-23 21:27:02 +08:00
|
|
|
<para>
|
|
|
|
<option>--enable-nfsynproxy</option>: This switch enables installation
|
|
|
|
of <application>nfsynproxy</application> SYNPROXY configuration tool.
|
|
|
|
</para>
|
|
|
|
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
2013-01-06 04:58:22 +08:00
|
|
|
<command>ln -sfv ../../sbin/xtables-multi /usr/bin/iptables-xml</command>:
|
2013-12-26 08:01:25 +08:00
|
|
|
Ensure the symbolic link for <command>iptables-xml</command> is relative.
|
2012-08-13 23:17:23 +08:00
|
|
|
</para>
|
2011-12-07 07:38:54 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
</sect2>
|
2010-03-07 08:34:03 +08:00
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
<sect2 role="configuration">
|
|
|
|
<title>Configuring Iptables</title>
|
|
|
|
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
Introductory instructions for configuring your firewall are
|
|
|
|
presented in the next section: <xref linkend="fw-firewall"/>
|
|
|
|
</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
|
|
|
|
<sect3 id="iptables-init">
|
2016-06-05 13:57:10 +08:00
|
|
|
<title><phrase revision="sysv">Boot Script</phrase>
|
|
|
|
<phrase revision="systemd">Systemd Unit</phrase></title>
|
2005-05-14 19:01:30 +08:00
|
|
|
|
2016-06-05 13:57:10 +08:00
|
|
|
<para revision="sysv">
|
2012-08-13 23:17:23 +08:00
|
|
|
To set up the iptables firewall at boot, install the
|
|
|
|
<filename>/etc/rc.d/init.d/iptables</filename> init script included
|
2016-06-05 13:57:10 +08:00
|
|
|
in the <xref linkend="bootscripts"/> package.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para revision="systemd">
|
|
|
|
To set up the iptables firewall at boot, install the
|
|
|
|
<filename>iptables.service</filename> unit included in the
|
|
|
|
<xref linkend="systemd-units"/> package.
|
2012-08-13 23:17:23 +08:00
|
|
|
</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>
|
2012-08-13 23:17:23 +08:00
|
|
|
<seg>
|
|
|
|
ip6tables, ip6tables-restore, ip6tables-save, iptables, iptables-restore,
|
2015-06-26 03:12:50 +08:00
|
|
|
iptables-save, iptables-xml, nfsynproxy (optional) and xtables-multi
|
2012-08-13 23:17:23 +08:00
|
|
|
</seg>
|
|
|
|
<seg>
|
2013-08-08 09:08:32 +08:00
|
|
|
libip4tc.so, libip6tc.so, libipq.so, libiptc.so, and libxtables.so
|
2012-08-13 23:17:23 +08:00
|
|
|
</seg>
|
|
|
|
<seg>
|
|
|
|
/lib/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>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
is used to set up, maintain, and inspect the tables of
|
|
|
|
IP packet filter rules in the Linux kernel.
|
|
|
|
</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>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
is used to restore IP Tables from data specified on
|
|
|
|
STDIN. Use I/O redirection provided by your
|
|
|
|
shell to read from a file.
|
|
|
|
</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>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
is used to dump the contents of an IP Table in easily
|
|
|
|
parseable format to STDOUT. Use I/O-redirection
|
|
|
|
provided by your shell to write to a file.
|
|
|
|
</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>
|
2012-08-13 23:17:23 +08:00
|
|
|
<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
|
|
|
|
back to the format of <command>iptables-restore</command>.
|
|
|
|
</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>
|
2012-08-13 23:17:23 +08:00
|
|
|
<para>
|
|
|
|
are a set of commands for IPV6 that parallel the iptables
|
|
|
|
commands above.
|
|
|
|
</para>
|
2005-05-14 19:01:30 +08:00
|
|
|
<indexterm zone="iptables ip6tables">
|
|
|
|
<primary sortas="b-ip6tables">ip6tables</primary>
|
|
|
|
</indexterm>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2013-11-23 21:27:02 +08:00
|
|
|
<varlistentry id="nfsynproxy">
|
|
|
|
<term><command>nfsynproxy</command></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
(optional) configuration tool. SYNPROXY target makes handling of
|
|
|
|
large SYN floods possible without the large performance penalties
|
|
|
|
imposed by the connection tracking in such cases.
|
|
|
|
</para>
|
|
|
|
<indexterm zone="iptables nfsynproxy">
|
|
|
|
<primary sortas="b-nfsynproxy">nfsynproxy</primary>
|
|
|
|
</indexterm>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2015-06-26 03:12:50 +08:00
|
|
|
<varlistentry id="xtables-multi">
|
|
|
|
<term><command>xtables-multi</command></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
is a binary that behaves according to the name it is called by.
|
|
|
|
</para>
|
|
|
|
<indexterm zone="iptables xtables-multi">
|
|
|
|
<primary sortas="b-xtables-multi">xtables-multi</primary>
|
|
|
|
</indexterm>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2005-05-14 19:01:30 +08:00
|
|
|
</variablelist>
|
|
|
|
|
|
|
|
</sect2>
|
2004-06-10 13:47:11 +08:00
|
|
|
|
2002-07-08 04:28:42 +08:00
|
|
|
</sect1>
|