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