[b4b71892] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[6732c094] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[b4b71892] | 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
[baf47952] | 7 | <!ENTITY iptables-download-http "http://www.netfilter.org/projects/iptables/files/iptables-&iptables-version;.tar.bz2">
|
---|
[b4b71892] | 8 | <!ENTITY iptables-download-ftp "ftp://ftp.netfilter.org/pub/iptables/iptables-&iptables-version;.tar.bz2">
|
---|
[6a97e97] | 9 | <!ENTITY iptables-md5sum "0a9209f928002e5eee9cdff8fef4d4b3">
|
---|
| 10 | <!ENTITY iptables-size "169 KB">
|
---|
| 11 | <!ENTITY iptables-buildsize "4.0 MB">
|
---|
[ce6ccc9] | 12 | <!ENTITY iptables-time "0.1 SBU">
|
---|
[b4b71892] | 13 | ]>
|
---|
| 14 |
|
---|
[fd680fb] | 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 |
|
---|
[3597eb6] | 62 | <para condition="html" role="usernotes">User Notes:
|
---|
| 63 | <ulink url="&blfs-wiki;/iptables"/></para>
|
---|
| 64 |
|
---|
[ce6ccc9] | 65 | </sect2>
|
---|
[b4b71892] | 66 |
|
---|
[71072bbe] | 67 | <sect2 role="kernel" id='iptables-kernel'>
|
---|
| 68 | <title>Kernel Configuration</title>
|
---|
[b4b71892] | 69 |
|
---|
[71072bbe] | 70 | <para>A firewall in Linux is accomplished through a portion of the
|
---|
| 71 | kernel called netfilter. The interface to netfilter is
|
---|
| 72 | <application>iptables</application>. To use it, the appropriate
|
---|
[32739af] | 73 | kernel configuration parameters are found in Networking ⇒
|
---|
[9f12e36] | 74 | Networking Options ⇒ Network Packet Filtering ⇒
|
---|
[32739af] | 75 | Core Netfilter Configuration (and) IP: Netfilter Configuration.</para>
|
---|
[f8962fe] | 76 |
|
---|
[71072bbe] | 77 | <indexterm zone="iptables iptables-kernel">
|
---|
| 78 | <primary sortas="d-iptables">Iptables</primary>
|
---|
| 79 | </indexterm>
|
---|
[48ecffe8] | 80 |
|
---|
[71072bbe] | 81 | </sect2>
|
---|
[48ecffe8] | 82 |
|
---|
[71072bbe] | 83 | <sect2 role="installation">
|
---|
| 84 | <title>Installation of Iptables</title>
|
---|
[48ecffe8] | 85 |
|
---|
[71072bbe] | 86 | <note>
|
---|
[ce6ccc9] | 87 | <para>The installation below does not include building some specialized
|
---|
| 88 | extension libraries which require the raw headers in the
|
---|
| 89 | <application>Linux</application> source code. If you wish to build the
|
---|
| 90 | additional extensions (if you aren't sure, then you probably don't), you
|
---|
| 91 | can look at the <filename>INSTALL</filename> file to see an example of
|
---|
| 92 | how to change the <parameter>KERNEL_DIR=</parameter> parameter to point
|
---|
| 93 | at the <application>Linux</application> source code. Note that if you
|
---|
| 94 | upgrade the kernel version, you may also need to recompile
|
---|
[cf0c010] | 95 | <application>iptables</application> and that the BLFS team has not tested
|
---|
| 96 | using the raw kernel headers.</para>
|
---|
[ce6ccc9] | 97 |
|
---|
| 98 | <!-- <para>Installation of <application>iptables</application> will fail
|
---|
[71072bbe] | 99 | if raw kernel headers are found in <filename
|
---|
| 100 | class='directory'>/usr/src/linux</filename> either as actual files
|
---|
| 101 | or a symlink. As of the Linux 2.6 kernel series, this directory
|
---|
| 102 | should no longer exist because appropriate headers were installed
|
---|
[0bc6cf76] | 103 | from the <application>Linux-Libc-Headers</application> package during
|
---|
[ce6ccc9] | 104 | the base LFS installation.</para> -->
|
---|
[fd7e0ed6] | 105 |
|
---|
[71072bbe] | 106 | <para>For some non-x86 architectures, the raw kernel headers may be
|
---|
[ce6ccc9] | 107 | required. In that case, modify the <parameter>KERNEL_DIR=</parameter>
|
---|
| 108 | parameter to point at the <application>Linux</application> source
|
---|
| 109 | code.</para>
|
---|
[71072bbe] | 110 | </note>
|
---|
| 111 |
|
---|
| 112 | <para>Install <application>iptables</application> by running the following
|
---|
| 113 | commands:</para>
|
---|
| 114 |
|
---|
[6a97e97] | 115 | <screen><userinput>sed -i 's/name="$node/name="node/' iptables.xslt &&
|
---|
| 116 | make LIBDIR=/lib KERNEL_DIR=/usr</userinput></screen>
|
---|
[ce6ccc9] | 117 |
|
---|
| 118 | <para>This package does not come with a test suite.</para>
|
---|
[71072bbe] | 119 |
|
---|
| 120 | <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 121 |
|
---|
[8008a55] | 122 | <screen role="root"><userinput>make PREFIX=/usr LIBDIR=/lib BINDIR=/sbin \
|
---|
[6a97e97] | 123 | MANDIR=/usr/share/man install &&
|
---|
| 124 | install -v -m644 iptables.xslt /lib/iptables</userinput></screen>
|
---|
[71072bbe] | 125 |
|
---|
| 126 | </sect2>
|
---|
| 127 |
|
---|
| 128 | <sect2 role="commands">
|
---|
| 129 | <title>Command Explanations</title>
|
---|
| 130 |
|
---|
[6a97e97] | 131 | <para><command>sed -i 's/name="$node/name="node/' iptables.xslt</command>:
|
---|
| 132 | This corrects a syntax error in the XSLT stylesheet for use with
|
---|
| 133 | <command>iptables-xml</command>.</para>
|
---|
| 134 |
|
---|
[71072bbe] | 135 | <para><parameter>PREFIX=/usr LIBDIR=/lib BINDIR=/sbin</parameter>:
|
---|
[6a97e97] | 136 | Compiles and installs <application>iptables</application> modules
|
---|
[71072bbe] | 137 | into <filename class="directory">/lib</filename>, binaries into
|
---|
| 138 | <filename class="directory">/sbin</filename> and the remainder into
|
---|
| 139 | the <filename class="directory">/usr</filename> hierarchy instead of
|
---|
| 140 | <filename class="directory">/usr/local</filename>. Firewalls are
|
---|
| 141 | generally activated during the boot process and
|
---|
| 142 | <filename class="directory">/usr</filename> may not be mounted at
|
---|
| 143 | that time.</para>
|
---|
| 144 |
|
---|
[ce6ccc9] | 145 | <para><parameter>KERNEL_DIR=/usr</parameter>: This parameter is used to
|
---|
| 146 | point at the sanitized kernel headers in
|
---|
| 147 | <filename class='directory'>/usr</filename> and not use the raw kernel
|
---|
| 148 | headers in <filename class='directory'>/usr/src/linux</filename>.</para>
|
---|
| 149 |
|
---|
[71072bbe] | 150 | </sect2>
|
---|
| 151 |
|
---|
| 152 | <sect2 role="configuration">
|
---|
| 153 | <title>Configuring Iptables</title>
|
---|
| 154 |
|
---|
| 155 | <para>Introductory instructions for configuring your firewall are
|
---|
[43b1987f] | 156 | presented in the next section: <xref linkend="fw-firewall"/></para>
|
---|
[71072bbe] | 157 |
|
---|
| 158 | <sect3 id="iptables-init">
|
---|
| 159 | <title>Boot Script</title>
|
---|
| 160 |
|
---|
| 161 | <para>To set up the iptables firewall at boot, install the
|
---|
| 162 | <filename>/etc/rc.d/init.d/iptables</filename> init script included
|
---|
[5254d12] | 163 | in the <xref linkend="bootscripts"/> package.</para>
|
---|
[71072bbe] | 164 |
|
---|
| 165 | <indexterm zone="iptables iptables-init">
|
---|
| 166 | <primary sortas="f-iptables">iptables</primary>
|
---|
| 167 | </indexterm>
|
---|
| 168 |
|
---|
| 169 | <screen role="root"><userinput>make install-iptables</userinput></screen>
|
---|
| 170 |
|
---|
| 171 | </sect3>
|
---|
| 172 |
|
---|
| 173 | </sect2>
|
---|
| 174 |
|
---|
| 175 | <sect2 role="content">
|
---|
| 176 | <title>Contents</title>
|
---|
| 177 |
|
---|
| 178 | <segmentedlist>
|
---|
| 179 | <segtitle>Installed Programs</segtitle>
|
---|
| 180 | <segtitle>Installed Libraries</segtitle>
|
---|
| 181 | <segtitle>Installed Directory</segtitle>
|
---|
| 182 |
|
---|
| 183 | <seglistitem>
|
---|
[6a97e97] | 184 | <seg>iptables, iptables-restore, iptables-save, iptables-xml and
|
---|
| 185 | ip6tables</seg>
|
---|
[71072bbe] | 186 | <seg>libip6t_*.so and libipt_*.so</seg>
|
---|
| 187 | <seg>/lib/iptables</seg>
|
---|
| 188 | </seglistitem>
|
---|
| 189 | </segmentedlist>
|
---|
| 190 |
|
---|
| 191 | <variablelist>
|
---|
| 192 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 193 | <?dbfo list-presentation="list"?>
|
---|
| 194 | <?dbhtml list-presentation="table"?>
|
---|
| 195 |
|
---|
| 196 | <varlistentry id="iptables-prog">
|
---|
| 197 | <term><command>iptables</command></term>
|
---|
| 198 | <listitem>
|
---|
| 199 | <para>is used to set up, maintain, and inspect the tables of
|
---|
| 200 | IP packet filter rules in the Linux kernel.</para>
|
---|
| 201 | <indexterm zone="iptables iptables-prog">
|
---|
| 202 | <primary sortas="b-iptables">iptables</primary>
|
---|
| 203 | </indexterm>
|
---|
| 204 | </listitem>
|
---|
| 205 | </varlistentry>
|
---|
| 206 |
|
---|
| 207 | <varlistentry id="iptables-restore">
|
---|
| 208 | <term><command>iptables-restore</command></term>
|
---|
| 209 | <listitem>
|
---|
| 210 | <para>is used to restore IP Tables from data
|
---|
| 211 | specified on STDIN. Use I/O redirection provided by your
|
---|
| 212 | shell to read from a file.</para>
|
---|
| 213 | <indexterm zone="iptables iptables-restore">
|
---|
| 214 | <primary sortas="b-iptables-restore">iptables-restore</primary>
|
---|
| 215 | </indexterm>
|
---|
| 216 | </listitem>
|
---|
| 217 | </varlistentry>
|
---|
| 218 |
|
---|
| 219 | <varlistentry id="iptables-save">
|
---|
| 220 | <term><command>iptables-save</command></term>
|
---|
| 221 | <listitem>
|
---|
| 222 | <para>is used to dump the contents of an IP Table
|
---|
| 223 | in easily parseable format to STDOUT. Use I/O-redirection
|
---|
| 224 | provided by your shell to write to a file.</para>
|
---|
| 225 | <indexterm zone="iptables iptables-save">
|
---|
| 226 | <primary sortas="b-iptables-save">iptables-save</primary>
|
---|
| 227 | </indexterm>
|
---|
| 228 | </listitem>
|
---|
| 229 | </varlistentry>
|
---|
| 230 |
|
---|
[6a97e97] | 231 | <varlistentry id="iptables-xml">
|
---|
| 232 | <term><command>iptables-xml</command></term>
|
---|
| 233 | <listitem>
|
---|
| 234 | <para>is used to convert the output of
|
---|
| 235 | <command>iptables-save</command> to an XML format. Using the
|
---|
| 236 | <filename>iptables.xslt</filename> stylesheet converts the XML
|
---|
[60db080] | 237 | back to the format of <command>iptables-restore</command>.</para>
|
---|
[6a97e97] | 238 | <indexterm zone="iptables iptables-xml">
|
---|
| 239 | <primary sortas="b-iptables-xml">iptables-xml</primary>
|
---|
| 240 | </indexterm>
|
---|
| 241 | </listitem>
|
---|
| 242 | </varlistentry>
|
---|
| 243 |
|
---|
[71072bbe] | 244 | <varlistentry id="ip6tables">
|
---|
| 245 | <term><command>ip6tables</command></term>
|
---|
| 246 | <listitem>
|
---|
| 247 | <para>is used to set up, maintain, and inspect the tables of
|
---|
| 248 | IPv6 packet filter rules in the Linux kernel. Several different
|
---|
| 249 | tables may be defined. Each table contains a number of built-in
|
---|
| 250 | chains and may also contain user-defined chains.</para>
|
---|
| 251 | <indexterm zone="iptables ip6tables">
|
---|
| 252 | <primary sortas="b-ip6tables">ip6tables</primary>
|
---|
| 253 | </indexterm>
|
---|
| 254 | </listitem>
|
---|
| 255 | </varlistentry>
|
---|
| 256 |
|
---|
| 257 | <varlistentry id="libip-iptables">
|
---|
| 258 | <term><filename class='libraryfile'>libip*.so</filename></term>
|
---|
| 259 | <listitem>
|
---|
| 260 | <para>library modules are various modules (implemented as dynamic
|
---|
| 261 | libraries) which extend the core functionality of
|
---|
| 262 | <command>iptables</command>.</para>
|
---|
| 263 | <indexterm zone="iptables libip-iptables">
|
---|
| 264 | <primary sortas="c-libip-iptables">libip*.so</primary>
|
---|
| 265 | </indexterm>
|
---|
| 266 | </listitem>
|
---|
| 267 | </varlistentry>
|
---|
| 268 |
|
---|
| 269 | </variablelist>
|
---|
| 270 |
|
---|
| 271 | </sect2>
|
---|
[b4b71892] | 272 |
|
---|
[f45b1953] | 273 | </sect1>
|
---|