[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">
|
---|
[bf157fc2] | 9 | <!ENTITY iptables-md5sum "645941dd1f9e0ec1f74c61918d70d52f">
|
---|
| 10 | <!ENTITY iptables-size "456 KB">
|
---|
| 11 | <!ENTITY iptables-buildsize "10.5 MB">
|
---|
| 12 | <!ENTITY iptables-time "0.2 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
|
---|
[bf157fc2] | 33 | firewall tool for Linux is <application>iptables</application>. You will
|
---|
| 34 | need to install <application>iptables</application> if you intend on using
|
---|
| 35 | any form of a firewall.</para>
|
---|
[71072bbe] | 36 |
|
---|
| 37 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 38 | <itemizedlist spacing="compact">
|
---|
| 39 | <listitem>
|
---|
| 40 | <para>Download (HTTP): <ulink url="&iptables-download-http;"/></para>
|
---|
| 41 | </listitem>
|
---|
| 42 | <listitem>
|
---|
| 43 | <para>Download (FTP): <ulink url="&iptables-download-ftp;"/></para>
|
---|
| 44 | </listitem>
|
---|
| 45 | <listitem>
|
---|
| 46 | <para>Download MD5 sum: &iptables-md5sum;</para>
|
---|
| 47 | </listitem>
|
---|
| 48 | <listitem>
|
---|
| 49 | <para>Download size: &iptables-size;</para>
|
---|
| 50 | </listitem>
|
---|
| 51 | <listitem>
|
---|
| 52 | <para>Estimated disk space required: &iptables-buildsize;</para>
|
---|
| 53 | </listitem>
|
---|
| 54 | <listitem>
|
---|
| 55 | <para>Estimated build time: &iptables-time;</para>
|
---|
| 56 | </listitem>
|
---|
| 57 | </itemizedlist>
|
---|
[b4b71892] | 58 |
|
---|
[3597eb6] | 59 | <para condition="html" role="usernotes">User Notes:
|
---|
| 60 | <ulink url="&blfs-wiki;/iptables"/></para>
|
---|
| 61 |
|
---|
[ce6ccc9] | 62 | </sect2>
|
---|
[b4b71892] | 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
|
---|
[bf157fc2] | 70 | kernel configuration parameters are found in Networking Support ⇒
|
---|
| 71 | Networking Options ⇒ Network Packet Filtering Framework.</para>
|
---|
[f8962fe] | 72 |
|
---|
[71072bbe] | 73 | <indexterm zone="iptables iptables-kernel">
|
---|
| 74 | <primary sortas="d-iptables">Iptables</primary>
|
---|
| 75 | </indexterm>
|
---|
[48ecffe8] | 76 |
|
---|
[71072bbe] | 77 | </sect2>
|
---|
[48ecffe8] | 78 |
|
---|
[71072bbe] | 79 | <sect2 role="installation">
|
---|
| 80 | <title>Installation of Iptables</title>
|
---|
[48ecffe8] | 81 |
|
---|
[71072bbe] | 82 | <note>
|
---|
[ce6ccc9] | 83 | <para>The installation below does not include building some specialized
|
---|
| 84 | extension libraries which require the raw headers in the
|
---|
| 85 | <application>Linux</application> source code. If you wish to build the
|
---|
| 86 | additional extensions (if you aren't sure, then you probably don't), you
|
---|
| 87 | can look at the <filename>INSTALL</filename> file to see an example of
|
---|
| 88 | how to change the <parameter>KERNEL_DIR=</parameter> parameter to point
|
---|
| 89 | at the <application>Linux</application> source code. Note that if you
|
---|
| 90 | upgrade the kernel version, you may also need to recompile
|
---|
[cf0c010] | 91 | <application>iptables</application> and that the BLFS team has not tested
|
---|
| 92 | using the raw kernel headers.</para>
|
---|
[ce6ccc9] | 93 |
|
---|
| 94 | <!-- <para>Installation of <application>iptables</application> will fail
|
---|
[71072bbe] | 95 | if raw kernel headers are found in <filename
|
---|
| 96 | class='directory'>/usr/src/linux</filename> either as actual files
|
---|
| 97 | or a symlink. As of the Linux 2.6 kernel series, this directory
|
---|
| 98 | should no longer exist because appropriate headers were installed
|
---|
[0bc6cf76] | 99 | from the <application>Linux-Libc-Headers</application> package during
|
---|
[ce6ccc9] | 100 | the base LFS installation.</para> -->
|
---|
[fd7e0ed6] | 101 |
|
---|
[71072bbe] | 102 | <para>For some non-x86 architectures, the raw kernel headers may be
|
---|
[ce6ccc9] | 103 | required. In that case, modify the <parameter>KERNEL_DIR=</parameter>
|
---|
| 104 | parameter to point at the <application>Linux</application> source
|
---|
| 105 | code.</para>
|
---|
[71072bbe] | 106 | </note>
|
---|
| 107 |
|
---|
| 108 | <para>Install <application>iptables</application> by running the following
|
---|
| 109 | commands:</para>
|
---|
| 110 |
|
---|
[d40737d] | 111 | <screen><userinput>
|
---|
| 112 | ./configure --prefix=/usr \
|
---|
| 113 | --bindir=/sbin \
|
---|
| 114 | --sbindir=/sbin \
|
---|
| 115 | --libdir=/lib \
|
---|
| 116 | --libexecdir=/lib \
|
---|
| 117 | --with-pkgconfigdir=/usr/lib/pkgconfig &&
|
---|
[bf157fc2] | 118 | make</userinput></screen>
|
---|
[ce6ccc9] | 119 |
|
---|
| 120 | <para>This package does not come with a test suite.</para>
|
---|
[71072bbe] | 121 |
|
---|
| 122 | <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 123 |
|
---|
[bf157fc2] | 124 | <screen role="root"><userinput>make install</userinput></screen>
|
---|
[71072bbe] | 125 |
|
---|
| 126 | </sect2>
|
---|
[d40737d] | 127 |
|
---|
[71072bbe] | 128 | <sect2 role="commands">
|
---|
| 129 | <title>Command Explanations</title>
|
---|
| 130 |
|
---|
[a41f643] | 131 | <para><parameter>--bindir=/sbin</parameter>,
|
---|
[d40737d] | 132 | <parameter>--sbindir=/sbin</parameter>: Ensure all the executables go
|
---|
| 133 | in <filename class="directory">/sbin</filename>.</para>
|
---|
| 134 |
|
---|
[a41f643] | 135 | <para><parameter>--libdir=/lib</parameter>,
|
---|
| 136 | <parameter>--libexecdir=/lib</parameter>: Ensure all the libraries are
|
---|
[d40737d] | 137 | in the <filename class="directory">/lib</filename> directory tree.</para>
|
---|
| 138 |
|
---|
[a41f643] | 139 | <para><parameter>--with-pkgconfigdir=/usr/lib/pkgconfig</parameter>:
|
---|
[d40737d] | 140 | Ensure all the pkgconfig files are in the standard location.</para>
|
---|
[ce6ccc9] | 141 |
|
---|
[71072bbe] | 142 | </sect2>
|
---|
[d40737d] | 143 |
|
---|
[71072bbe] | 144 | <sect2 role="configuration">
|
---|
| 145 | <title>Configuring Iptables</title>
|
---|
| 146 |
|
---|
| 147 | <para>Introductory instructions for configuring your firewall are
|
---|
[43b1987f] | 148 | presented in the next section: <xref linkend="fw-firewall"/></para>
|
---|
[71072bbe] | 149 |
|
---|
| 150 | <sect3 id="iptables-init">
|
---|
| 151 | <title>Boot Script</title>
|
---|
| 152 |
|
---|
| 153 | <para>To set up the iptables firewall at boot, install the
|
---|
| 154 | <filename>/etc/rc.d/init.d/iptables</filename> init script included
|
---|
[5254d12] | 155 | in the <xref linkend="bootscripts"/> package.</para>
|
---|
[71072bbe] | 156 |
|
---|
| 157 | <indexterm zone="iptables iptables-init">
|
---|
| 158 | <primary sortas="f-iptables">iptables</primary>
|
---|
| 159 | </indexterm>
|
---|
| 160 |
|
---|
| 161 | <screen role="root"><userinput>make install-iptables</userinput></screen>
|
---|
| 162 |
|
---|
| 163 | </sect3>
|
---|
| 164 |
|
---|
| 165 | </sect2>
|
---|
| 166 |
|
---|
| 167 | <sect2 role="content">
|
---|
| 168 | <title>Contents</title>
|
---|
| 169 |
|
---|
| 170 | <segmentedlist>
|
---|
| 171 | <segtitle>Installed Programs</segtitle>
|
---|
| 172 | <segtitle>Installed Libraries</segtitle>
|
---|
[bf157fc2] | 173 | <segtitle>Installed Directories</segtitle>
|
---|
[71072bbe] | 174 |
|
---|
| 175 | <seglistitem>
|
---|
[a41f643] | 176 | <seg>iptables, iptables-restore, iptables-save, iptables-xml,
|
---|
| 177 | iptables-multi, ip6tables, ip6tables-restore, ip6tables-save,
|
---|
[bf157fc2] | 178 | and ip6tables-multii</seg>
|
---|
| 179 | <seg>libip4tc.so, libip6tc.so, libiptc.so, libxtables.so,
|
---|
[d40737d] | 180 | and numerous modules in /lib/xtables/</seg>
|
---|
| 181 | <seg>/lib/xtables/xtables and /usr/include/libiptc</seg>
|
---|
[71072bbe] | 182 | </seglistitem>
|
---|
| 183 | </segmentedlist>
|
---|
| 184 |
|
---|
| 185 | <variablelist>
|
---|
| 186 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 187 | <?dbfo list-presentation="list"?>
|
---|
| 188 | <?dbhtml list-presentation="table"?>
|
---|
| 189 |
|
---|
| 190 | <varlistentry id="iptables-prog">
|
---|
| 191 | <term><command>iptables</command></term>
|
---|
| 192 | <listitem>
|
---|
| 193 | <para>is used to set up, maintain, and inspect the tables of
|
---|
[a41f643] | 194 | IP packet filter rules in the Linux kernel. It is a
|
---|
[bf157fc2] | 195 | symbolic link to iptables-multi.</para>
|
---|
[71072bbe] | 196 | <indexterm zone="iptables iptables-prog">
|
---|
| 197 | <primary sortas="b-iptables">iptables</primary>
|
---|
| 198 | </indexterm>
|
---|
| 199 | </listitem>
|
---|
| 200 | </varlistentry>
|
---|
| 201 |
|
---|
| 202 | <varlistentry id="iptables-restore">
|
---|
| 203 | <term><command>iptables-restore</command></term>
|
---|
| 204 | <listitem>
|
---|
| 205 | <para>is used to restore IP Tables from data
|
---|
| 206 | specified on STDIN. Use I/O redirection provided by your
|
---|
[a41f643] | 207 | shell to read from a file. It is a symbolic link to
|
---|
[bf157fc2] | 208 | iptables-multi.</para>
|
---|
[71072bbe] | 209 | <indexterm zone="iptables iptables-restore">
|
---|
| 210 | <primary sortas="b-iptables-restore">iptables-restore</primary>
|
---|
| 211 | </indexterm>
|
---|
| 212 | </listitem>
|
---|
| 213 | </varlistentry>
|
---|
| 214 |
|
---|
| 215 | <varlistentry id="iptables-save">
|
---|
| 216 | <term><command>iptables-save</command></term>
|
---|
| 217 | <listitem>
|
---|
| 218 | <para>is used to dump the contents of an IP Table
|
---|
| 219 | in easily parseable format to STDOUT. Use I/O-redirection
|
---|
[bf157fc2] | 220 | provided by your shell to write to a file. It is a symbolic link to
|
---|
| 221 | iptables-multi.</para>
|
---|
[71072bbe] | 222 | <indexterm zone="iptables iptables-save">
|
---|
| 223 | <primary sortas="b-iptables-save">iptables-save</primary>
|
---|
| 224 | </indexterm>
|
---|
| 225 | </listitem>
|
---|
| 226 | </varlistentry>
|
---|
| 227 |
|
---|
[6a97e97] | 228 | <varlistentry id="iptables-xml">
|
---|
| 229 | <term><command>iptables-xml</command></term>
|
---|
| 230 | <listitem>
|
---|
| 231 | <para>is used to convert the output of
|
---|
| 232 | <command>iptables-save</command> to an XML format. Using the
|
---|
| 233 | <filename>iptables.xslt</filename> stylesheet converts the XML
|
---|
[bf157fc2] | 234 | back to the format of <command>iptables-restore</command>.
|
---|
| 235 | It is a symbolic link to iptables-multi.</para>
|
---|
[6a97e97] | 236 | <indexterm zone="iptables iptables-xml">
|
---|
| 237 | <primary sortas="b-iptables-xml">iptables-xml</primary>
|
---|
| 238 | </indexterm>
|
---|
| 239 | </listitem>
|
---|
| 240 | </varlistentry>
|
---|
| 241 |
|
---|
[71072bbe] | 242 | <varlistentry id="ip6tables">
|
---|
[bf157fc2] | 243 | <term><command>ip6tables*</command></term>
|
---|
[71072bbe] | 244 | <listitem>
|
---|
[bf157fc2] | 245 | <para>are a set of commands for IPV6 that parallel the iptables
|
---|
[a41f643] | 246 | commands above. All of these commands are symbolic
|
---|
[bf157fc2] | 247 | links to ip6tables-multi.</para>
|
---|
[71072bbe] | 248 | <indexterm zone="iptables ip6tables">
|
---|
| 249 | <primary sortas="b-ip6tables">ip6tables</primary>
|
---|
| 250 | </indexterm>
|
---|
| 251 | </listitem>
|
---|
| 252 | </varlistentry>
|
---|
| 253 |
|
---|
| 254 | </variablelist>
|
---|
| 255 |
|
---|
| 256 | </sect2>
|
---|
[b4b71892] | 257 |
|
---|
[f45b1953] | 258 | </sect1>
|
---|