[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">
|
---|
[7801f02] | 9 | <!ENTITY iptables-md5sum "536d048c8e8eeebcd9757d0863ebb0c0">
|
---|
| 10 | <!ENTITY iptables-size "536 KB">
|
---|
| 11 | <!ENTITY iptables-buildsize "15 MB">
|
---|
[5129caa] | 12 | <!ENTITY iptables-time "0.2 SBU">
|
---|
[b4b71892] | 13 | ]>
|
---|
| 14 |
|
---|
[4591404] | 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 |
|
---|
[4591404] | 32 | <para>
|
---|
[d6da5da] | 33 | The next part of this chapter deals with firewalls. The principal
|
---|
[4591404] | 34 | firewall tool for Linux is <application>Iptables</application>. You will
|
---|
| 35 | need to install <application>Iptables</application> if you intend on using
|
---|
| 36 | any form of a firewall.
|
---|
| 37 | </para>
|
---|
[71072bbe] | 38 |
|
---|
[04f35fe3] | 39 | &lfs77_checked;
|
---|
[93236c2] | 40 |
|
---|
[71072bbe] | 41 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 42 | <itemizedlist spacing="compact">
|
---|
| 43 | <listitem>
|
---|
[4591404] | 44 | <para>
|
---|
| 45 | Download (HTTP): <ulink url="&iptables-download-http;"/>
|
---|
| 46 | </para>
|
---|
[71072bbe] | 47 | </listitem>
|
---|
| 48 | <listitem>
|
---|
[4591404] | 49 | <para>
|
---|
| 50 | Download (FTP): <ulink url="&iptables-download-ftp;"/>
|
---|
| 51 | </para>
|
---|
[71072bbe] | 52 | </listitem>
|
---|
| 53 | <listitem>
|
---|
[4591404] | 54 | <para>
|
---|
| 55 | Download MD5 sum: &iptables-md5sum;
|
---|
| 56 | </para>
|
---|
[71072bbe] | 57 | </listitem>
|
---|
| 58 | <listitem>
|
---|
[4591404] | 59 | <para>
|
---|
| 60 | Download size: &iptables-size;
|
---|
| 61 | </para>
|
---|
[71072bbe] | 62 | </listitem>
|
---|
| 63 | <listitem>
|
---|
[4591404] | 64 | <para>
|
---|
| 65 | Estimated disk space required: &iptables-buildsize;
|
---|
| 66 | </para>
|
---|
[71072bbe] | 67 | </listitem>
|
---|
| 68 | <listitem>
|
---|
[4591404] | 69 | <para>
|
---|
| 70 | Estimated build time: &iptables-time;
|
---|
| 71 | </para>
|
---|
[71072bbe] | 72 | </listitem>
|
---|
| 73 | </itemizedlist>
|
---|
[d6da5da] | 74 |
|
---|
[3597eb6] | 75 | <para condition="html" role="usernotes">User Notes:
|
---|
[4591404] | 76 | <ulink url="&blfs-wiki;/iptables"/>
|
---|
| 77 | </para>
|
---|
[ce6ccc9] | 78 | </sect2>
|
---|
[b4b71892] | 79 |
|
---|
[4591404] | 80 | <sect2 role="kernel" id="iptables-kernel">
|
---|
[71072bbe] | 81 | <title>Kernel Configuration</title>
|
---|
[b4b71892] | 82 |
|
---|
[4591404] | 83 | <para>
|
---|
| 84 | A firewall in Linux is accomplished through a portion of the
|
---|
| 85 | kernel called netfilter. The interface to netfilter is
|
---|
| 86 | <application>Iptables</application>. To use it, the appropriate
|
---|
[38155d1] | 87 | kernel configuration parameters are found in:
|
---|
[4591404] | 88 | </para>
|
---|
[f8962fe] | 89 |
|
---|
[38155d1] | 90 | <screen><literal>[*] Networking support ---> [CONFIG_NET]
|
---|
| 91 | Networking Options --->
|
---|
| 92 | [*] Network packet filtering framework (Netfilter) ---> [CONFIG_NETFILTER]</literal></screen>
|
---|
| 93 |
|
---|
[71072bbe] | 94 | <indexterm zone="iptables iptables-kernel">
|
---|
| 95 | <primary sortas="d-iptables">Iptables</primary>
|
---|
| 96 | </indexterm>
|
---|
[48ecffe8] | 97 |
|
---|
[71072bbe] | 98 | </sect2>
|
---|
[48ecffe8] | 99 |
|
---|
[71072bbe] | 100 | <sect2 role="installation">
|
---|
| 101 | <title>Installation of Iptables</title>
|
---|
[48ecffe8] | 102 |
|
---|
[71072bbe] | 103 | <note>
|
---|
[4591404] | 104 | <para>
|
---|
| 105 | The installation below does not include building some specialized
|
---|
| 106 | extension libraries which require the raw headers in the
|
---|
| 107 | <application>Linux</application> source code. If you wish to build the
|
---|
| 108 | additional extensions (if you aren't sure, then you probably don't), you
|
---|
| 109 | can look at the <filename>INSTALL</filename> file to see an example of
|
---|
| 110 | how to change the <parameter>KERNEL_DIR=</parameter> parameter to point
|
---|
| 111 | at the <application>Linux</application> source code. Note that if you
|
---|
| 112 | upgrade the kernel version, you may also need to recompile
|
---|
| 113 | <application>Iptables</application> and that the BLFS team has not tested
|
---|
| 114 | using the raw kernel headers.
|
---|
| 115 | </para>
|
---|
| 116 |
|
---|
| 117 | <para>
|
---|
| 118 | For some non-x86 architectures, the raw kernel headers may be
|
---|
| 119 | required. In that case, modify the <parameter>KERNEL_DIR=</parameter>
|
---|
| 120 | parameter to point at the <application>Linux</application> source
|
---|
| 121 | code.
|
---|
| 122 | </para>
|
---|
[71072bbe] | 123 | </note>
|
---|
| 124 |
|
---|
[4591404] | 125 | <para>
|
---|
| 126 | Install <application>Iptables</application> by running the following
|
---|
| 127 | commands:
|
---|
| 128 | </para>
|
---|
| 129 |
|
---|
[04f35fe3] | 130 | <screen><userinput>./configure --prefix=/usr \
|
---|
| 131 | --sbindir=/sbin \
|
---|
| 132 | --enable-libipq \
|
---|
| 133 | --with-xtlibdir=/lib/xtables &&
|
---|
[bf157fc2] | 134 | make</userinput></screen>
|
---|
[ce6ccc9] | 135 |
|
---|
| 136 | <para>This package does not come with a test suite.</para>
|
---|
[71072bbe] | 137 |
|
---|
| 138 | <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 139 |
|
---|
[93236c2] | 140 | <screen role="root"><userinput>make install &&
|
---|
[23407e4] | 141 | ln -sfv ../../sbin/xtables-multi /usr/bin/iptables-xml &&
|
---|
[04f35fe3] | 142 |
|
---|
[5ae7a99] | 143 | for file in ip4tc ip6tc ipq iptc xtables
|
---|
[23407e4] | 144 | do
|
---|
[5ae7a99] | 145 | mv -v /usr/lib/lib${file}.so.* /lib &&
|
---|
| 146 | ln -sfv ../../lib/$(readlink /usr/lib/lib${file}.so) /usr/lib/lib${file}.so
|
---|
[23407e4] | 147 | done</userinput></screen>
|
---|
[71072bbe] | 148 |
|
---|
| 149 | </sect2>
|
---|
[d40737d] | 150 |
|
---|
[71072bbe] | 151 | <sect2 role="commands">
|
---|
| 152 | <title>Command Explanations</title>
|
---|
| 153 |
|
---|
[4591404] | 154 | <para>
|
---|
[0d7900a] | 155 | <parameter>--with-xtlibdir=/lib/xtables</parameter>: Ensure all
|
---|
| 156 | <application>Iptables</application> modules are installed in the
|
---|
[4591404] | 157 | <filename class="directory">/lib/xtables</filename> directory.
|
---|
| 158 | </para>
|
---|
| 159 |
|
---|
| 160 | <para>
|
---|
| 161 | <option>--enable-libipq</option>: This switch enables building
|
---|
| 162 | of <filename class="libraryfile">libipq.so</filename> which
|
---|
| 163 | can be used by some packages outside of BLFS.
|
---|
| 164 | </para>
|
---|
| 165 |
|
---|
[7801f02] | 166 | <para>
|
---|
| 167 | <option>--enable-nfsynproxy</option>: This switch enables installation
|
---|
| 168 | of <application>nfsynproxy</application> SYNPROXY configuration tool.
|
---|
| 169 | </para>
|
---|
| 170 |
|
---|
[4591404] | 171 | <para>
|
---|
[23407e4] | 172 | <command>ln -sfv ../../sbin/xtables-multi /usr/bin/iptables-xml</command>:
|
---|
[5ae7a99] | 173 | Ensure the symbolic link for <command>iptables-xml</command> is relative.
|
---|
[4591404] | 174 | </para>
|
---|
[93236c2] | 175 |
|
---|
[71072bbe] | 176 | </sect2>
|
---|
[d40737d] | 177 |
|
---|
[71072bbe] | 178 | <sect2 role="configuration">
|
---|
| 179 | <title>Configuring Iptables</title>
|
---|
| 180 |
|
---|
[4591404] | 181 | <para>
|
---|
| 182 | Introductory instructions for configuring your firewall are
|
---|
| 183 | presented in the next section: <xref linkend="fw-firewall"/>
|
---|
| 184 | </para>
|
---|
[71072bbe] | 185 |
|
---|
| 186 | <sect3 id="iptables-init">
|
---|
| 187 | <title>Boot Script</title>
|
---|
| 188 |
|
---|
[4591404] | 189 | <para>
|
---|
| 190 | To set up the iptables firewall at boot, install the
|
---|
| 191 | <filename>/etc/rc.d/init.d/iptables</filename> init script included
|
---|
| 192 | in the <xref linkend="bootscripts"/> package.
|
---|
| 193 | </para>
|
---|
[71072bbe] | 194 |
|
---|
| 195 | <indexterm zone="iptables iptables-init">
|
---|
| 196 | <primary sortas="f-iptables">iptables</primary>
|
---|
| 197 | </indexterm>
|
---|
| 198 |
|
---|
| 199 | <screen role="root"><userinput>make install-iptables</userinput></screen>
|
---|
| 200 |
|
---|
| 201 | </sect3>
|
---|
| 202 |
|
---|
| 203 | </sect2>
|
---|
| 204 |
|
---|
| 205 | <sect2 role="content">
|
---|
| 206 | <title>Contents</title>
|
---|
| 207 |
|
---|
| 208 | <segmentedlist>
|
---|
| 209 | <segtitle>Installed Programs</segtitle>
|
---|
| 210 | <segtitle>Installed Libraries</segtitle>
|
---|
[bf157fc2] | 211 | <segtitle>Installed Directories</segtitle>
|
---|
[71072bbe] | 212 |
|
---|
| 213 | <seglistitem>
|
---|
[4591404] | 214 | <seg>
|
---|
| 215 | ip6tables, ip6tables-restore, ip6tables-save, iptables, iptables-restore,
|
---|
[c8f569a] | 216 | iptables-save, iptables-xml, and xtables-multi
|
---|
[4591404] | 217 | </seg>
|
---|
| 218 | <seg>
|
---|
[c8f569a] | 219 | libip4tc.so, libip6tc.so, libipq.so, libiptc.so, and libxtables.so
|
---|
[4591404] | 220 | </seg>
|
---|
| 221 | <seg>
|
---|
| 222 | /lib/xtables and /usr/include/libiptc
|
---|
| 223 | </seg>
|
---|
[71072bbe] | 224 | </seglistitem>
|
---|
| 225 | </segmentedlist>
|
---|
| 226 |
|
---|
| 227 | <variablelist>
|
---|
| 228 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 229 | <?dbfo list-presentation="list"?>
|
---|
| 230 | <?dbhtml list-presentation="table"?>
|
---|
| 231 |
|
---|
| 232 | <varlistentry id="iptables-prog">
|
---|
| 233 | <term><command>iptables</command></term>
|
---|
| 234 | <listitem>
|
---|
[4591404] | 235 | <para>
|
---|
| 236 | is used to set up, maintain, and inspect the tables of
|
---|
| 237 | IP packet filter rules in the Linux kernel.
|
---|
| 238 | </para>
|
---|
[71072bbe] | 239 | <indexterm zone="iptables iptables-prog">
|
---|
| 240 | <primary sortas="b-iptables">iptables</primary>
|
---|
| 241 | </indexterm>
|
---|
| 242 | </listitem>
|
---|
| 243 | </varlistentry>
|
---|
| 244 |
|
---|
| 245 | <varlistentry id="iptables-restore">
|
---|
| 246 | <term><command>iptables-restore</command></term>
|
---|
| 247 | <listitem>
|
---|
[4591404] | 248 | <para>
|
---|
| 249 | is used to restore IP Tables from data specified on
|
---|
| 250 | STDIN. Use I/O redirection provided by your
|
---|
| 251 | shell to read from a file.
|
---|
| 252 | </para>
|
---|
[71072bbe] | 253 | <indexterm zone="iptables iptables-restore">
|
---|
| 254 | <primary sortas="b-iptables-restore">iptables-restore</primary>
|
---|
| 255 | </indexterm>
|
---|
| 256 | </listitem>
|
---|
| 257 | </varlistentry>
|
---|
| 258 |
|
---|
| 259 | <varlistentry id="iptables-save">
|
---|
| 260 | <term><command>iptables-save</command></term>
|
---|
| 261 | <listitem>
|
---|
[4591404] | 262 | <para>
|
---|
| 263 | is used to dump the contents of an IP Table in easily
|
---|
| 264 | parseable format to STDOUT. Use I/O-redirection
|
---|
| 265 | provided by your shell to write to a file.
|
---|
| 266 | </para>
|
---|
[71072bbe] | 267 | <indexterm zone="iptables iptables-save">
|
---|
| 268 | <primary sortas="b-iptables-save">iptables-save</primary>
|
---|
| 269 | </indexterm>
|
---|
| 270 | </listitem>
|
---|
| 271 | </varlistentry>
|
---|
| 272 |
|
---|
[6a97e97] | 273 | <varlistentry id="iptables-xml">
|
---|
| 274 | <term><command>iptables-xml</command></term>
|
---|
| 275 | <listitem>
|
---|
[4591404] | 276 | <para>
|
---|
| 277 | is used to convert the output of
|
---|
| 278 | <command>iptables-save</command> to an XML format. Using the
|
---|
| 279 | <filename>iptables.xslt</filename> stylesheet converts the XML
|
---|
| 280 | back to the format of <command>iptables-restore</command>.
|
---|
| 281 | </para>
|
---|
[6a97e97] | 282 | <indexterm zone="iptables iptables-xml">
|
---|
| 283 | <primary sortas="b-iptables-xml">iptables-xml</primary>
|
---|
| 284 | </indexterm>
|
---|
| 285 | </listitem>
|
---|
| 286 | </varlistentry>
|
---|
| 287 |
|
---|
[71072bbe] | 288 | <varlistentry id="ip6tables">
|
---|
[bf157fc2] | 289 | <term><command>ip6tables*</command></term>
|
---|
[71072bbe] | 290 | <listitem>
|
---|
[4591404] | 291 | <para>
|
---|
| 292 | are a set of commands for IPV6 that parallel the iptables
|
---|
| 293 | commands above.
|
---|
| 294 | </para>
|
---|
[71072bbe] | 295 | <indexterm zone="iptables ip6tables">
|
---|
| 296 | <primary sortas="b-ip6tables">ip6tables</primary>
|
---|
| 297 | </indexterm>
|
---|
| 298 | </listitem>
|
---|
| 299 | </varlistentry>
|
---|
| 300 |
|
---|
[7801f02] | 301 | <varlistentry id="nfsynproxy">
|
---|
| 302 | <term><command>nfsynproxy</command></term>
|
---|
| 303 | <listitem>
|
---|
| 304 | <para>
|
---|
| 305 | (optional) configuration tool. SYNPROXY target makes handling of
|
---|
| 306 | large SYN floods possible without the large performance penalties
|
---|
| 307 | imposed by the connection tracking in such cases.
|
---|
| 308 | </para>
|
---|
| 309 | <indexterm zone="iptables nfsynproxy">
|
---|
| 310 | <primary sortas="b-nfsynproxy">nfsynproxy</primary>
|
---|
| 311 | </indexterm>
|
---|
| 312 | </listitem>
|
---|
| 313 | </varlistentry>
|
---|
| 314 |
|
---|
[71072bbe] | 315 | </variablelist>
|
---|
| 316 |
|
---|
| 317 | </sect2>
|
---|
[b4b71892] | 318 |
|
---|
[f45b1953] | 319 | </sect1>
|
---|