[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 |
|
---|
[01cecdc2] | 39 | &lfs74_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
|
---|
| 87 | kernel configuration parameters are found in Networking Support ⇒
|
---|
| 88 | Networking Options ⇒ Network Packet Filtering Framework.
|
---|
| 89 | </para>
|
---|
[f8962fe] | 90 |
|
---|
[71072bbe] | 91 | <indexterm zone="iptables iptables-kernel">
|
---|
| 92 | <primary sortas="d-iptables">Iptables</primary>
|
---|
| 93 | </indexterm>
|
---|
[48ecffe8] | 94 |
|
---|
[71072bbe] | 95 | </sect2>
|
---|
[48ecffe8] | 96 |
|
---|
[71072bbe] | 97 | <sect2 role="installation">
|
---|
| 98 | <title>Installation of Iptables</title>
|
---|
[48ecffe8] | 99 |
|
---|
[71072bbe] | 100 | <note>
|
---|
[4591404] | 101 | <para>
|
---|
| 102 | The installation below does not include building some specialized
|
---|
| 103 | extension libraries which require the raw headers in the
|
---|
| 104 | <application>Linux</application> source code. If you wish to build the
|
---|
| 105 | additional extensions (if you aren't sure, then you probably don't), you
|
---|
| 106 | can look at the <filename>INSTALL</filename> file to see an example of
|
---|
| 107 | how to change the <parameter>KERNEL_DIR=</parameter> parameter to point
|
---|
| 108 | at the <application>Linux</application> source code. Note that if you
|
---|
| 109 | upgrade the kernel version, you may also need to recompile
|
---|
| 110 | <application>Iptables</application> and that the BLFS team has not tested
|
---|
| 111 | using the raw kernel headers.
|
---|
| 112 | </para>
|
---|
| 113 |
|
---|
| 114 | <para>
|
---|
| 115 | For some non-x86 architectures, the raw kernel headers may be
|
---|
| 116 | required. In that case, modify the <parameter>KERNEL_DIR=</parameter>
|
---|
| 117 | parameter to point at the <application>Linux</application> source
|
---|
| 118 | code.
|
---|
| 119 | </para>
|
---|
[71072bbe] | 120 | </note>
|
---|
| 121 |
|
---|
[4591404] | 122 | <para>
|
---|
| 123 | Install <application>Iptables</application> by running the following
|
---|
| 124 | commands:
|
---|
| 125 | </para>
|
---|
| 126 |
|
---|
[d6da5da] | 127 | <screen><userinput>./configure --prefix=/usr \
|
---|
[4591404] | 128 | --exec-prefix= \
|
---|
[23407e4] | 129 | --bindir=/usr/bin \
|
---|
[4591404] | 130 | --with-xtlibdir=/lib/xtables \
|
---|
| 131 | --with-pkgconfigdir=/usr/lib/pkgconfig \
|
---|
| 132 | --enable-libipq \
|
---|
| 133 | --enable-devel &&
|
---|
[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 &&
|
---|
| 142 | for file in libip4tc libip6tc libipq libiptc libxtables
|
---|
| 143 | do
|
---|
| 144 | ln -sfv ../../lib/`readlink /lib/${file}.so` /usr/lib/${file}.so &&
|
---|
| 145 | rm -v /lib/${file}.so &&
|
---|
| 146 | mv -v /lib/${file}.la /usr/lib &&
|
---|
| 147 | sed -i "s@libdir='@&/usr@g" /usr/lib/${file}.la
|
---|
| 148 | done</userinput></screen>
|
---|
[71072bbe] | 149 |
|
---|
| 150 | </sect2>
|
---|
[d40737d] | 151 |
|
---|
[71072bbe] | 152 | <sect2 role="commands">
|
---|
| 153 | <title>Command Explanations</title>
|
---|
| 154 |
|
---|
[4591404] | 155 | <para>
|
---|
| 156 | <parameter>--exec-prefix=</parameter>: Ensure all binaries and
|
---|
| 157 | libraries end up in <filename class="directory">/</filename>
|
---|
| 158 | directory tree.
|
---|
| 159 | </para>
|
---|
| 160 |
|
---|
| 161 | <para>
|
---|
[0d7900a] | 162 | <parameter>--with-xtlibdir=/lib/xtables</parameter>: Ensure all
|
---|
| 163 | <application>Iptables</application> modules are installed in the
|
---|
[4591404] | 164 | <filename class="directory">/lib/xtables</filename> directory.
|
---|
| 165 | </para>
|
---|
| 166 |
|
---|
| 167 | <para>
|
---|
| 168 | <parameter>--with-pkgconfigdir=/usr/lib/pkgconfig</parameter>:
|
---|
| 169 | Ensure all the pkgconfig files are in the standard location.
|
---|
| 170 | </para>
|
---|
| 171 |
|
---|
| 172 | <para>
|
---|
| 173 | <option>--enable-libipq</option>: This switch enables building
|
---|
| 174 | of <filename class="libraryfile">libipq.so</filename> which
|
---|
| 175 | can be used by some packages outside of BLFS.
|
---|
| 176 | </para>
|
---|
| 177 |
|
---|
| 178 | <para>
|
---|
| 179 | <option>--enable-devel</option>: This switch enables installation
|
---|
| 180 | of <application>Iptables</application> development headers that
|
---|
| 181 | can be used by some packages outside of BLFS.
|
---|
| 182 | </para>
|
---|
| 183 |
|
---|
[7801f02] | 184 | <para>
|
---|
| 185 | <option>--enable-nfsynproxy</option>: This switch enables installation
|
---|
| 186 | of <application>nfsynproxy</application> SYNPROXY configuration tool.
|
---|
| 187 | </para>
|
---|
| 188 |
|
---|
[4591404] | 189 | <para>
|
---|
[23407e4] | 190 | <command>ln -sfv ../../sbin/xtables-multi /usr/bin/iptables-xml</command>:
|
---|
| 191 | Ensure the symbolic link for <command>iptables-xml</command> is relative.
|
---|
[4591404] | 192 | </para>
|
---|
[93236c2] | 193 |
|
---|
[71072bbe] | 194 | </sect2>
|
---|
[d40737d] | 195 |
|
---|
[71072bbe] | 196 | <sect2 role="configuration">
|
---|
| 197 | <title>Configuring Iptables</title>
|
---|
| 198 |
|
---|
[4591404] | 199 | <para>
|
---|
| 200 | Introductory instructions for configuring your firewall are
|
---|
| 201 | presented in the next section: <xref linkend="fw-firewall"/>
|
---|
| 202 | </para>
|
---|
[71072bbe] | 203 |
|
---|
| 204 | <sect3 id="iptables-init">
|
---|
| 205 | <title>Boot Script</title>
|
---|
| 206 |
|
---|
[4591404] | 207 | <para>
|
---|
| 208 | To set up the iptables firewall at boot, install the
|
---|
| 209 | <filename>/etc/rc.d/init.d/iptables</filename> init script included
|
---|
| 210 | in the <xref linkend="bootscripts"/> package.
|
---|
| 211 | </para>
|
---|
[71072bbe] | 212 |
|
---|
| 213 | <indexterm zone="iptables iptables-init">
|
---|
| 214 | <primary sortas="f-iptables">iptables</primary>
|
---|
| 215 | </indexterm>
|
---|
| 216 |
|
---|
| 217 | <screen role="root"><userinput>make install-iptables</userinput></screen>
|
---|
| 218 |
|
---|
| 219 | </sect3>
|
---|
| 220 |
|
---|
| 221 | </sect2>
|
---|
| 222 |
|
---|
| 223 | <sect2 role="content">
|
---|
| 224 | <title>Contents</title>
|
---|
| 225 |
|
---|
| 226 | <segmentedlist>
|
---|
| 227 | <segtitle>Installed Programs</segtitle>
|
---|
| 228 | <segtitle>Installed Libraries</segtitle>
|
---|
[bf157fc2] | 229 | <segtitle>Installed Directories</segtitle>
|
---|
[71072bbe] | 230 |
|
---|
| 231 | <seglistitem>
|
---|
[4591404] | 232 | <seg>
|
---|
| 233 | ip6tables, ip6tables-restore, ip6tables-save, iptables, iptables-restore,
|
---|
[c8f569a] | 234 | iptables-save, iptables-xml, and xtables-multi
|
---|
[4591404] | 235 | </seg>
|
---|
| 236 | <seg>
|
---|
[c8f569a] | 237 | libip4tc.so, libip6tc.so, libipq.so, libiptc.so, and libxtables.so
|
---|
[4591404] | 238 | </seg>
|
---|
| 239 | <seg>
|
---|
| 240 | /lib/xtables and /usr/include/libiptc
|
---|
| 241 | </seg>
|
---|
[71072bbe] | 242 | </seglistitem>
|
---|
| 243 | </segmentedlist>
|
---|
| 244 |
|
---|
| 245 | <variablelist>
|
---|
| 246 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 247 | <?dbfo list-presentation="list"?>
|
---|
| 248 | <?dbhtml list-presentation="table"?>
|
---|
| 249 |
|
---|
| 250 | <varlistentry id="iptables-prog">
|
---|
| 251 | <term><command>iptables</command></term>
|
---|
| 252 | <listitem>
|
---|
[4591404] | 253 | <para>
|
---|
| 254 | is used to set up, maintain, and inspect the tables of
|
---|
| 255 | IP packet filter rules in the Linux kernel.
|
---|
| 256 | </para>
|
---|
[71072bbe] | 257 | <indexterm zone="iptables iptables-prog">
|
---|
| 258 | <primary sortas="b-iptables">iptables</primary>
|
---|
| 259 | </indexterm>
|
---|
| 260 | </listitem>
|
---|
| 261 | </varlistentry>
|
---|
| 262 |
|
---|
| 263 | <varlistentry id="iptables-restore">
|
---|
| 264 | <term><command>iptables-restore</command></term>
|
---|
| 265 | <listitem>
|
---|
[4591404] | 266 | <para>
|
---|
| 267 | is used to restore IP Tables from data specified on
|
---|
| 268 | STDIN. Use I/O redirection provided by your
|
---|
| 269 | shell to read from a file.
|
---|
| 270 | </para>
|
---|
[71072bbe] | 271 | <indexterm zone="iptables iptables-restore">
|
---|
| 272 | <primary sortas="b-iptables-restore">iptables-restore</primary>
|
---|
| 273 | </indexterm>
|
---|
| 274 | </listitem>
|
---|
| 275 | </varlistentry>
|
---|
| 276 |
|
---|
| 277 | <varlistentry id="iptables-save">
|
---|
| 278 | <term><command>iptables-save</command></term>
|
---|
| 279 | <listitem>
|
---|
[4591404] | 280 | <para>
|
---|
| 281 | is used to dump the contents of an IP Table in easily
|
---|
| 282 | parseable format to STDOUT. Use I/O-redirection
|
---|
| 283 | provided by your shell to write to a file.
|
---|
| 284 | </para>
|
---|
[71072bbe] | 285 | <indexterm zone="iptables iptables-save">
|
---|
| 286 | <primary sortas="b-iptables-save">iptables-save</primary>
|
---|
| 287 | </indexterm>
|
---|
| 288 | </listitem>
|
---|
| 289 | </varlistentry>
|
---|
| 290 |
|
---|
[6a97e97] | 291 | <varlistentry id="iptables-xml">
|
---|
| 292 | <term><command>iptables-xml</command></term>
|
---|
| 293 | <listitem>
|
---|
[4591404] | 294 | <para>
|
---|
| 295 | is used to convert the output of
|
---|
| 296 | <command>iptables-save</command> to an XML format. Using the
|
---|
| 297 | <filename>iptables.xslt</filename> stylesheet converts the XML
|
---|
| 298 | back to the format of <command>iptables-restore</command>.
|
---|
| 299 | </para>
|
---|
[6a97e97] | 300 | <indexterm zone="iptables iptables-xml">
|
---|
| 301 | <primary sortas="b-iptables-xml">iptables-xml</primary>
|
---|
| 302 | </indexterm>
|
---|
| 303 | </listitem>
|
---|
| 304 | </varlistentry>
|
---|
| 305 |
|
---|
[71072bbe] | 306 | <varlistentry id="ip6tables">
|
---|
[bf157fc2] | 307 | <term><command>ip6tables*</command></term>
|
---|
[71072bbe] | 308 | <listitem>
|
---|
[4591404] | 309 | <para>
|
---|
| 310 | are a set of commands for IPV6 that parallel the iptables
|
---|
| 311 | commands above.
|
---|
| 312 | </para>
|
---|
[71072bbe] | 313 | <indexterm zone="iptables ip6tables">
|
---|
| 314 | <primary sortas="b-ip6tables">ip6tables</primary>
|
---|
| 315 | </indexterm>
|
---|
| 316 | </listitem>
|
---|
| 317 | </varlistentry>
|
---|
| 318 |
|
---|
[7801f02] | 319 | <varlistentry id="nfsynproxy">
|
---|
| 320 | <term><command>nfsynproxy</command></term>
|
---|
| 321 | <listitem>
|
---|
| 322 | <para>
|
---|
| 323 | (optional) configuration tool. SYNPROXY target makes handling of
|
---|
| 324 | large SYN floods possible without the large performance penalties
|
---|
| 325 | imposed by the connection tracking in such cases.
|
---|
| 326 | </para>
|
---|
| 327 | <indexterm zone="iptables nfsynproxy">
|
---|
| 328 | <primary sortas="b-nfsynproxy">nfsynproxy</primary>
|
---|
| 329 | </indexterm>
|
---|
| 330 | </listitem>
|
---|
| 331 | </varlistentry>
|
---|
| 332 |
|
---|
[71072bbe] | 333 | </variablelist>
|
---|
| 334 |
|
---|
| 335 | </sect2>
|
---|
[b4b71892] | 336 |
|
---|
[f45b1953] | 337 | </sect1>
|
---|