[af8e1cb5] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
| 7 | <!ENTITY iptables-download-http "http://www.netfilter.org/projects/iptables/files/iptables-&iptables-version;.tar.bz2">
|
---|
| 8 | <!ENTITY iptables-download-ftp "ftp://ftp.netfilter.org/pub/iptables/iptables-&iptables-version;.tar.bz2">
|
---|
| 9 | <!ENTITY iptables-md5sum "536d048c8e8eeebcd9757d0863ebb0c0">
|
---|
| 10 | <!ENTITY iptables-size "536 KB">
|
---|
| 11 | <!ENTITY iptables-buildsize "15 MB">
|
---|
| 12 | <!ENTITY iptables-time "0.2 SBU">
|
---|
| 13 | ]>
|
---|
| 14 |
|
---|
| 15 | <sect1 id="iptables" xreflabel="Iptables-&iptables-version;">
|
---|
| 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>
|
---|
| 33 | The next part of this chapter deals with firewalls. The principal
|
---|
| 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>
|
---|
| 38 |
|
---|
[fa36572] | 39 | &lfs76_checked;
|
---|
[af8e1cb5] | 40 |
|
---|
| 41 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 42 | <itemizedlist spacing="compact">
|
---|
| 43 | <listitem>
|
---|
| 44 | <para>
|
---|
| 45 | Download (HTTP): <ulink url="&iptables-download-http;"/>
|
---|
| 46 | </para>
|
---|
| 47 | </listitem>
|
---|
| 48 | <listitem>
|
---|
| 49 | <para>
|
---|
| 50 | Download (FTP): <ulink url="&iptables-download-ftp;"/>
|
---|
| 51 | </para>
|
---|
| 52 | </listitem>
|
---|
| 53 | <listitem>
|
---|
| 54 | <para>
|
---|
| 55 | Download MD5 sum: &iptables-md5sum;
|
---|
| 56 | </para>
|
---|
| 57 | </listitem>
|
---|
| 58 | <listitem>
|
---|
| 59 | <para>
|
---|
| 60 | Download size: &iptables-size;
|
---|
| 61 | </para>
|
---|
| 62 | </listitem>
|
---|
| 63 | <listitem>
|
---|
| 64 | <para>
|
---|
| 65 | Estimated disk space required: &iptables-buildsize;
|
---|
| 66 | </para>
|
---|
| 67 | </listitem>
|
---|
| 68 | <listitem>
|
---|
| 69 | <para>
|
---|
| 70 | Estimated build time: &iptables-time;
|
---|
| 71 | </para>
|
---|
| 72 | </listitem>
|
---|
| 73 | </itemizedlist>
|
---|
| 74 |
|
---|
| 75 | <para condition="html" role="usernotes">User Notes:
|
---|
| 76 | <ulink url="&blfs-wiki;/iptables"/>
|
---|
| 77 | </para>
|
---|
| 78 | </sect2>
|
---|
| 79 |
|
---|
| 80 | <sect2 role="kernel" id="iptables-kernel">
|
---|
| 81 | <title>Kernel Configuration</title>
|
---|
| 82 |
|
---|
| 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>
|
---|
| 90 |
|
---|
| 91 | <indexterm zone="iptables iptables-kernel">
|
---|
| 92 | <primary sortas="d-iptables">Iptables</primary>
|
---|
| 93 | </indexterm>
|
---|
| 94 |
|
---|
| 95 | </sect2>
|
---|
| 96 |
|
---|
| 97 | <sect2 role="installation">
|
---|
| 98 | <title>Installation of Iptables</title>
|
---|
| 99 |
|
---|
| 100 | <note>
|
---|
| 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>
|
---|
| 120 | </note>
|
---|
| 121 |
|
---|
| 122 | <para>
|
---|
| 123 | Install <application>Iptables</application> by running the following
|
---|
| 124 | commands:
|
---|
| 125 | </para>
|
---|
| 126 |
|
---|
| 127 | <screen><userinput>./configure --prefix=/usr \
|
---|
| 128 | --sbindir=/sbin \
|
---|
| 129 | --with-xtlibdir=/lib/xtables \
|
---|
| 130 | --enable-libipq &&
|
---|
| 131 | make</userinput></screen>
|
---|
| 132 |
|
---|
| 133 | <para>This package does not come with a test suite.</para>
|
---|
| 134 |
|
---|
| 135 | <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 136 |
|
---|
| 137 | <screen role="root"><userinput>make install &&
|
---|
| 138 | ln -sfv ../../sbin/xtables-multi /usr/bin/iptables-xml &&
|
---|
| 139 | for file in ip4tc ip6tc ipq iptc xtables
|
---|
| 140 | do
|
---|
| 141 | mv -v /usr/lib/lib${file}.so.* /lib &&
|
---|
| 142 | ln -sfv ../../lib/$(readlink /usr/lib/lib${file}.so) /usr/lib/lib${file}.so
|
---|
| 143 | done</userinput></screen>
|
---|
| 144 |
|
---|
| 145 | </sect2>
|
---|
| 146 |
|
---|
| 147 | <sect2 role="commands">
|
---|
| 148 | <title>Command Explanations</title>
|
---|
| 149 |
|
---|
| 150 | <para>
|
---|
| 151 | <parameter>--with-xtlibdir=/lib/xtables</parameter>: Ensure all
|
---|
| 152 | <application>Iptables</application> modules are installed in the
|
---|
| 153 | <filename class="directory">/lib/xtables</filename> directory.
|
---|
| 154 | </para>
|
---|
| 155 |
|
---|
| 156 | <para>
|
---|
| 157 | <option>--enable-libipq</option>: This switch enables building
|
---|
| 158 | of <filename class="libraryfile">libipq.so</filename> which
|
---|
| 159 | can be used by some packages outside of BLFS.
|
---|
| 160 | </para>
|
---|
| 161 |
|
---|
| 162 | <para>
|
---|
| 163 | <option>--enable-nfsynproxy</option>: This switch enables installation
|
---|
| 164 | of <application>nfsynproxy</application> SYNPROXY configuration tool.
|
---|
| 165 | </para>
|
---|
| 166 |
|
---|
| 167 | <para>
|
---|
| 168 | <command>ln -sfv ../../sbin/xtables-multi /usr/bin/iptables-xml</command>:
|
---|
| 169 | Ensure the symbolic link for <command>iptables-xml</command> is relative.
|
---|
| 170 | </para>
|
---|
| 171 |
|
---|
| 172 | </sect2>
|
---|
| 173 |
|
---|
| 174 | <sect2 role="configuration">
|
---|
| 175 | <title>Configuring Iptables</title>
|
---|
| 176 |
|
---|
| 177 | <para>
|
---|
| 178 | Introductory instructions for configuring your firewall are
|
---|
| 179 | presented in the next section: <xref linkend="fw-firewall"/>
|
---|
| 180 | </para>
|
---|
| 181 |
|
---|
| 182 | <sect3 id="iptables-init">
|
---|
| 183 | <title>Systemd Units</title>
|
---|
| 184 |
|
---|
| 185 | <para>
|
---|
| 186 | To set up the <application>Iptables</application> firewall at boot,
|
---|
| 187 | install the systemd unit from the <xref linkend="bootscripts"/>
|
---|
| 188 | package by running the following command as the
|
---|
| 189 | <systemitem class="username">root</systemitem> user:
|
---|
| 190 | </para>
|
---|
| 191 |
|
---|
| 192 | <indexterm zone="iptables iptables-init">
|
---|
| 193 | <primary sortas="f-iptables">iptables</primary>
|
---|
| 194 | </indexterm>
|
---|
| 195 |
|
---|
| 196 | <screen role="root"><userinput>make install-iptables</userinput></screen>
|
---|
| 197 |
|
---|
| 198 | </sect3>
|
---|
| 199 |
|
---|
| 200 | </sect2>
|
---|
| 201 |
|
---|
| 202 | <sect2 role="content">
|
---|
| 203 | <title>Contents</title>
|
---|
| 204 |
|
---|
| 205 | <segmentedlist>
|
---|
| 206 | <segtitle>Installed Programs</segtitle>
|
---|
| 207 | <segtitle>Installed Libraries</segtitle>
|
---|
| 208 | <segtitle>Installed Directories</segtitle>
|
---|
| 209 |
|
---|
| 210 | <seglistitem>
|
---|
| 211 | <seg>
|
---|
| 212 | ip6tables, ip6tables-restore, ip6tables-save, iptables, iptables-restore,
|
---|
| 213 | iptables-save, iptables-xml, and xtables-multi
|
---|
| 214 | </seg>
|
---|
| 215 | <seg>
|
---|
| 216 | libip4tc.so, libip6tc.so, libipq.so, libiptc.so, and libxtables.so
|
---|
| 217 | </seg>
|
---|
| 218 | <seg>
|
---|
| 219 | /lib/xtables and /usr/include/libiptc
|
---|
| 220 | </seg>
|
---|
| 221 | </seglistitem>
|
---|
| 222 | </segmentedlist>
|
---|
| 223 |
|
---|
| 224 | <variablelist>
|
---|
| 225 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 226 | <?dbfo list-presentation="list"?>
|
---|
| 227 | <?dbhtml list-presentation="table"?>
|
---|
| 228 |
|
---|
| 229 | <varlistentry id="iptables-prog">
|
---|
| 230 | <term><command>iptables</command></term>
|
---|
| 231 | <listitem>
|
---|
| 232 | <para>
|
---|
| 233 | is used to set up, maintain, and inspect the tables of
|
---|
| 234 | IP packet filter rules in the Linux kernel.
|
---|
| 235 | </para>
|
---|
| 236 | <indexterm zone="iptables iptables-prog">
|
---|
| 237 | <primary sortas="b-iptables">iptables</primary>
|
---|
| 238 | </indexterm>
|
---|
| 239 | </listitem>
|
---|
| 240 | </varlistentry>
|
---|
| 241 |
|
---|
| 242 | <varlistentry id="iptables-restore">
|
---|
| 243 | <term><command>iptables-restore</command></term>
|
---|
| 244 | <listitem>
|
---|
| 245 | <para>
|
---|
| 246 | is used to restore IP Tables from data specified on
|
---|
| 247 | STDIN. Use I/O redirection provided by your
|
---|
| 248 | shell to read from a file.
|
---|
| 249 | </para>
|
---|
| 250 | <indexterm zone="iptables iptables-restore">
|
---|
| 251 | <primary sortas="b-iptables-restore">iptables-restore</primary>
|
---|
| 252 | </indexterm>
|
---|
| 253 | </listitem>
|
---|
| 254 | </varlistentry>
|
---|
| 255 |
|
---|
| 256 | <varlistentry id="iptables-save">
|
---|
| 257 | <term><command>iptables-save</command></term>
|
---|
| 258 | <listitem>
|
---|
| 259 | <para>
|
---|
| 260 | is used to dump the contents of an IP Table in easily
|
---|
| 261 | parseable format to STDOUT. Use I/O-redirection
|
---|
| 262 | provided by your shell to write to a file.
|
---|
| 263 | </para>
|
---|
| 264 | <indexterm zone="iptables iptables-save">
|
---|
| 265 | <primary sortas="b-iptables-save">iptables-save</primary>
|
---|
| 266 | </indexterm>
|
---|
| 267 | </listitem>
|
---|
| 268 | </varlistentry>
|
---|
| 269 |
|
---|
| 270 | <varlistentry id="iptables-xml">
|
---|
| 271 | <term><command>iptables-xml</command></term>
|
---|
| 272 | <listitem>
|
---|
| 273 | <para>
|
---|
| 274 | is used to convert the output of
|
---|
| 275 | <command>iptables-save</command> to an XML format. Using the
|
---|
| 276 | <filename>iptables.xslt</filename> stylesheet converts the XML
|
---|
| 277 | back to the format of <command>iptables-restore</command>.
|
---|
| 278 | </para>
|
---|
| 279 | <indexterm zone="iptables iptables-xml">
|
---|
| 280 | <primary sortas="b-iptables-xml">iptables-xml</primary>
|
---|
| 281 | </indexterm>
|
---|
| 282 | </listitem>
|
---|
| 283 | </varlistentry>
|
---|
| 284 |
|
---|
| 285 | <varlistentry id="ip6tables">
|
---|
| 286 | <term><command>ip6tables*</command></term>
|
---|
| 287 | <listitem>
|
---|
| 288 | <para>
|
---|
| 289 | are a set of commands for IPV6 that parallel the iptables
|
---|
| 290 | commands above.
|
---|
| 291 | </para>
|
---|
| 292 | <indexterm zone="iptables ip6tables">
|
---|
| 293 | <primary sortas="b-ip6tables">ip6tables</primary>
|
---|
| 294 | </indexterm>
|
---|
| 295 | </listitem>
|
---|
| 296 | </varlistentry>
|
---|
| 297 |
|
---|
| 298 | <varlistentry id="nfsynproxy">
|
---|
| 299 | <term><command>nfsynproxy</command></term>
|
---|
| 300 | <listitem>
|
---|
| 301 | <para>
|
---|
| 302 | (optional) configuration tool. SYNPROXY target makes handling of
|
---|
| 303 | large SYN floods possible without the large performance penalties
|
---|
| 304 | imposed by the connection tracking in such cases.
|
---|
| 305 | </para>
|
---|
| 306 | <indexterm zone="iptables nfsynproxy">
|
---|
| 307 | <primary sortas="b-nfsynproxy">nfsynproxy</primary>
|
---|
| 308 | </indexterm>
|
---|
| 309 | </listitem>
|
---|
| 310 | </varlistentry>
|
---|
| 311 |
|
---|
| 312 | </variablelist>
|
---|
| 313 |
|
---|
| 314 | </sect2>
|
---|
| 315 |
|
---|
| 316 | </sect1>
|
---|