[b4b71892] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[ff769b8c] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
---|
[b4b71892] | 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
| 7 | <!ENTITY iptables-download-http "http://www.iptables.org/files/iptables-&iptables-version;.tar.bz2">
|
---|
| 8 | <!ENTITY iptables-download-ftp "ftp://ftp.netfilter.org/pub/iptables/iptables-&iptables-version;.tar.bz2">
|
---|
[7c5f2a8] | 9 | <!ENTITY iptables-md5sum "86d88455520cfdc56fd7ae27897a80a4">
|
---|
| 10 | <!ENTITY iptables-size "176 KB">
|
---|
| 11 | <!ENTITY iptables-buildsize "4.8 MB">
|
---|
| 12 | <!ENTITY iptables-time "0.2 SBU">
|
---|
[b4b71892] | 13 | ]>
|
---|
| 14 |
|
---|
[1d602a9d] | 15 | <sect1 id="iptables" xreflabel="iptables-&iptables-version;">
|
---|
[71072bbe] | 16 | <?dbhtml filename="iptables.html"?>
|
---|
| 17 |
|
---|
| 18 | <sect1info>
|
---|
| 19 | <othername>$LastChangedBy$</othername>
|
---|
| 20 | <date>$Date$</date>
|
---|
| 21 | </sect1info>
|
---|
| 22 |
|
---|
| 23 | <title>Iptables-&iptables-version;</title>
|
---|
| 24 |
|
---|
| 25 | <indexterm zone="iptables">
|
---|
| 26 | <primary sortas="a-Iptables">Iptables</primary>
|
---|
| 27 | </indexterm>
|
---|
| 28 |
|
---|
| 29 | <sect2 role="package">
|
---|
| 30 | <title>Introduction to Iptables</title>
|
---|
| 31 |
|
---|
| 32 | <para>The next part of this chapter deals with firewalls. The principal
|
---|
| 33 | firewall tool for Linux, as of the 2.4 kernel series, is
|
---|
| 34 | <application>iptables</application>. It replaces
|
---|
| 35 | <application>ipchains</application> from the 2.2 series and
|
---|
| 36 | <application>ipfwadm</application> from the 2.0 series. You will need to
|
---|
| 37 | install <application>iptables</application> if you intend on using any
|
---|
| 38 | form of a firewall.</para>
|
---|
| 39 |
|
---|
| 40 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 41 | <itemizedlist spacing="compact">
|
---|
| 42 | <listitem>
|
---|
| 43 | <para>Download (HTTP): <ulink url="&iptables-download-http;"/></para>
|
---|
| 44 | </listitem>
|
---|
| 45 | <listitem>
|
---|
| 46 | <para>Download (FTP): <ulink url="&iptables-download-ftp;"/></para>
|
---|
| 47 | </listitem>
|
---|
| 48 | <listitem>
|
---|
| 49 | <para>Download MD5 sum: &iptables-md5sum;</para>
|
---|
| 50 | </listitem>
|
---|
| 51 | <listitem>
|
---|
| 52 | <para>Download size: &iptables-size;</para>
|
---|
| 53 | </listitem>
|
---|
| 54 | <listitem>
|
---|
| 55 | <para>Estimated disk space required: &iptables-buildsize;</para>
|
---|
| 56 | </listitem>
|
---|
| 57 | <listitem>
|
---|
| 58 | <para>Estimated build time: &iptables-time;</para>
|
---|
| 59 | </listitem>
|
---|
| 60 | </itemizedlist>
|
---|
[b4b71892] | 61 |
|
---|
| 62 | </sect2>
|
---|
| 63 |
|
---|
[71072bbe] | 64 | <sect2 role="kernel" id='iptables-kernel'>
|
---|
| 65 | <title>Kernel Configuration</title>
|
---|
[b4b71892] | 66 |
|
---|
[71072bbe] | 67 | <para>A firewall in Linux is accomplished through a portion of the
|
---|
| 68 | kernel called netfilter. The interface to netfilter is
|
---|
| 69 | <application>iptables</application>. To use it, the appropriate
|
---|
| 70 | kernel configuration parameters are found in Device Drivers ->
|
---|
| 71 | Networking Support -> Networking Options ->
|
---|
| 72 | Network Packet Filtering -> IP: Netfilter Configuration.</para>
|
---|
[f8962fe] | 73 |
|
---|
[71072bbe] | 74 | <indexterm zone="iptables iptables-kernel">
|
---|
| 75 | <primary sortas="d-iptables">Iptables</primary>
|
---|
| 76 | </indexterm>
|
---|
[48ecffe8] | 77 |
|
---|
[71072bbe] | 78 | </sect2>
|
---|
[48ecffe8] | 79 |
|
---|
[71072bbe] | 80 | <sect2 role="installation">
|
---|
| 81 | <title>Installation of Iptables</title>
|
---|
[48ecffe8] | 82 |
|
---|
[71072bbe] | 83 | <note>
|
---|
| 84 | <para>Installation of <application>iptables</application> will fail
|
---|
| 85 | if raw kernel headers are found in <filename
|
---|
| 86 | class='directory'>/usr/src/linux</filename> either as actual files
|
---|
| 87 | or a symlink. As of the Linux 2.6 kernel series, this directory
|
---|
| 88 | should no longer exist because appropriate headers were installed
|
---|
[0bc6cf76] | 89 | from the <application>Linux-Libc-Headers</application> package during
|
---|
| 90 | the base LFS installation.</para>
|
---|
[71072bbe] | 91 |
|
---|
| 92 | <para>For some non-x86 architectures, the raw kernel headers may be
|
---|
| 93 | required. In that case, add the environment variable
|
---|
| 94 | <envar>KERNEL_DIR=/usr/src/linux</envar> to the make commands below.</para>
|
---|
| 95 | </note>
|
---|
| 96 |
|
---|
| 97 | <para>Install <application>iptables</application> by running the following
|
---|
| 98 | commands:</para>
|
---|
| 99 |
|
---|
| 100 | <screen><userinput>make PREFIX=/usr LIBDIR=/lib BINDIR=/sbin</userinput></screen>
|
---|
| 101 |
|
---|
| 102 | <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 103 |
|
---|
| 104 | <screen role="root"><userinput>make PREFIX=/usr LIBDIR=/lib BINDIR=/sbin install</userinput></screen>
|
---|
| 105 |
|
---|
| 106 | </sect2>
|
---|
| 107 |
|
---|
| 108 | <sect2 role="commands">
|
---|
| 109 | <title>Command Explanations</title>
|
---|
| 110 |
|
---|
| 111 | <para><parameter>PREFIX=/usr LIBDIR=/lib BINDIR=/sbin</parameter>:
|
---|
| 112 | Compiles and installs <application>iptables</application> libraries
|
---|
| 113 | into <filename class="directory">/lib</filename>, binaries into
|
---|
| 114 | <filename class="directory">/sbin</filename> and the remainder into
|
---|
| 115 | the <filename class="directory">/usr</filename> hierarchy instead of
|
---|
| 116 | <filename class="directory">/usr/local</filename>. Firewalls are
|
---|
| 117 | generally activated during the boot process and
|
---|
| 118 | <filename class="directory">/usr</filename> may not be mounted at
|
---|
| 119 | that time.</para>
|
---|
| 120 |
|
---|
| 121 | </sect2>
|
---|
| 122 |
|
---|
| 123 | <sect2 role="configuration">
|
---|
| 124 | <title>Configuring Iptables</title>
|
---|
| 125 |
|
---|
| 126 | <para>Introductory instructions for configuring your firewall are
|
---|
| 127 | presented in the next section: <xref linkend='fw-firewall'/></para>
|
---|
| 128 |
|
---|
| 129 | <sect3 id="iptables-init">
|
---|
| 130 | <title>Boot Script</title>
|
---|
| 131 |
|
---|
| 132 | <para>To set up the iptables firewall at boot, install the
|
---|
| 133 | <filename>/etc/rc.d/init.d/iptables</filename> init script included
|
---|
| 134 | in the <xref linkend="intro-important-bootscripts"/> package.</para>
|
---|
| 135 |
|
---|
| 136 | <indexterm zone="iptables iptables-init">
|
---|
| 137 | <primary sortas="f-iptables">iptables</primary>
|
---|
| 138 | </indexterm>
|
---|
| 139 |
|
---|
| 140 | <screen role="root"><userinput>make install-iptables</userinput></screen>
|
---|
| 141 |
|
---|
| 142 | </sect3>
|
---|
| 143 |
|
---|
| 144 | </sect2>
|
---|
| 145 |
|
---|
| 146 | <sect2 role="content">
|
---|
| 147 | <title>Contents</title>
|
---|
| 148 |
|
---|
| 149 | <segmentedlist>
|
---|
| 150 | <segtitle>Installed Programs</segtitle>
|
---|
| 151 | <segtitle>Installed Libraries</segtitle>
|
---|
| 152 | <segtitle>Installed Directory</segtitle>
|
---|
| 153 |
|
---|
| 154 | <seglistitem>
|
---|
| 155 | <seg>iptables, iptables-restore, iptables-save and ip6tables</seg>
|
---|
| 156 | <seg>libip6t_*.so and libipt_*.so</seg>
|
---|
| 157 | <seg>/lib/iptables</seg>
|
---|
| 158 | </seglistitem>
|
---|
| 159 | </segmentedlist>
|
---|
| 160 |
|
---|
| 161 | <variablelist>
|
---|
| 162 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 163 | <?dbfo list-presentation="list"?>
|
---|
| 164 | <?dbhtml list-presentation="table"?>
|
---|
| 165 |
|
---|
| 166 | <varlistentry id="iptables-prog">
|
---|
| 167 | <term><command>iptables</command></term>
|
---|
| 168 | <listitem>
|
---|
| 169 | <para>is used to set up, maintain, and inspect the tables of
|
---|
| 170 | IP packet filter rules in the Linux kernel.</para>
|
---|
| 171 | <indexterm zone="iptables iptables-prog">
|
---|
| 172 | <primary sortas="b-iptables">iptables</primary>
|
---|
| 173 | </indexterm>
|
---|
| 174 | </listitem>
|
---|
| 175 | </varlistentry>
|
---|
| 176 |
|
---|
| 177 | <varlistentry id="iptables-restore">
|
---|
| 178 | <term><command>iptables-restore</command></term>
|
---|
| 179 | <listitem>
|
---|
| 180 | <para>is used to restore IP Tables from data
|
---|
| 181 | specified on STDIN. Use I/O redirection provided by your
|
---|
| 182 | shell to read from a file.</para>
|
---|
| 183 | <indexterm zone="iptables iptables-restore">
|
---|
| 184 | <primary sortas="b-iptables-restore">iptables-restore</primary>
|
---|
| 185 | </indexterm>
|
---|
| 186 | </listitem>
|
---|
| 187 | </varlistentry>
|
---|
| 188 |
|
---|
| 189 | <varlistentry id="iptables-save">
|
---|
| 190 | <term><command>iptables-save</command></term>
|
---|
| 191 | <listitem>
|
---|
| 192 | <para>is used to dump the contents of an IP Table
|
---|
| 193 | in easily parseable format to STDOUT. Use I/O-redirection
|
---|
| 194 | provided by your shell to write to a file.</para>
|
---|
| 195 | <indexterm zone="iptables iptables-save">
|
---|
| 196 | <primary sortas="b-iptables-save">iptables-save</primary>
|
---|
| 197 | </indexterm>
|
---|
| 198 | </listitem>
|
---|
| 199 | </varlistentry>
|
---|
| 200 |
|
---|
| 201 | <varlistentry id="ip6tables">
|
---|
| 202 | <term><command>ip6tables</command></term>
|
---|
| 203 | <listitem>
|
---|
| 204 | <para>is used to set up, maintain, and inspect the tables of
|
---|
| 205 | IPv6 packet filter rules in the Linux kernel. Several different
|
---|
| 206 | tables may be defined. Each table contains a number of built-in
|
---|
| 207 | chains and may also contain user-defined chains.</para>
|
---|
| 208 | <indexterm zone="iptables ip6tables">
|
---|
| 209 | <primary sortas="b-ip6tables">ip6tables</primary>
|
---|
| 210 | </indexterm>
|
---|
| 211 | </listitem>
|
---|
| 212 | </varlistentry>
|
---|
| 213 |
|
---|
| 214 | <varlistentry id="libip-iptables">
|
---|
| 215 | <term><filename class='libraryfile'>libip*.so</filename></term>
|
---|
| 216 | <listitem>
|
---|
| 217 | <para>library modules are various modules (implemented as dynamic
|
---|
| 218 | libraries) which extend the core functionality of
|
---|
| 219 | <command>iptables</command>.</para>
|
---|
| 220 | <indexterm zone="iptables libip-iptables">
|
---|
| 221 | <primary sortas="c-libip-iptables">libip*.so</primary>
|
---|
| 222 | </indexterm>
|
---|
| 223 | </listitem>
|
---|
| 224 | </varlistentry>
|
---|
| 225 |
|
---|
| 226 | </variablelist>
|
---|
| 227 |
|
---|
| 228 | </sect2>
|
---|
[b4b71892] | 229 |
|
---|
[f45b1953] | 230 | </sect1>
|
---|