<?xml version='1.0' encoding='ISO-8859-1'?>

<!DOCTYPE article PUBLIC '-//OASIS//DTD DocBook XML V4.1.2//EN' 'http://www.docbook.org/xml/4.1.2/docbookx.dtd'>
<!--<!DOCTYPE article PUBLIC '-//OASIS//DTD DocBook XML V4.1.2//EN' "file:/usr/share/sgml/docbook/xml-dtd-4.1.2-1.0-22.1/docbookx.dtd">-->


<!-- how does it work? = theoretical, cookbook = practical -->

<article>

<articleinfo>

<title>The Official netfilter/iptables FAQ</title>

<authorgroup>
	<author>
		<firstname>Tarek W.</firstname>
		<surname>Said</surname>
		<authorblurb>
			<para>
			<email>tarek@iptables.org</email>
			</para>
		</authorblurb>
		<contrib>Current FAQ maintainer</contrib>
	</author>
	<author>
		<firstname>Harald</firstname>
		<surname>Welte</surname>
		<authorblurb>
			<para>
		<email>laforge@netfilter.org</email>
			</para>
		</authorblurb>
		<contrib>Original FAQ maintainer</contrib>
	</author>
</authorgroup>

<pubdate>Version $Revision: 577 $, $Date: 2004-04-16 22:48:52 +0200 (vie, 16 abr 2004) $</pubdate>

<abstract>
	<para>
	This document contains the Frequently Asked Questions as encountered on the netfilter
	mailing lists.
	Please check the section entitled "<link linkend="uratf" endterm="uratf.title"/>" for more
	information.
	</para>
</abstract>

</articleinfo>

<!-- "General Questions" section - begin -->
<section>
	<title>General Questions</title>
	<!-- second-level section - begin -->
	<section>
		<title>About netfilter &amp; iptables</title>
		<section>
			<!--tarek-->
			<title>What is netfilter?</title>
			<para>
			Please read the section entitled "What is netfilter/iptables?" on the
			<ulink url="http://netfilter.org/">homepage</ulink>.
			</para>
			<para>
			Simplifying somewhat, netfilter is the kernel part of the magic that is
			iptables-based firewalling, NAT and IP accounting.
			</para>
		</section>
		<section>
			<!--tarek-->
			<title>What is iptables?</title>
			<para>
			Please read the section entitled "What is netfilter/iptables?" on the
			<ulink url="http://netfilter.org/">homepage</ulink>.
			</para>
			<para>
			Expanding on that, iptables comes in two manifestations: the first is in
			kernelspace, it consists of groups of related tables (filter, nat, mangle, ...)
			which respectively house chains similar in function (in filter's case: INPUT,
			OUTPUT and FORWARD, the function being packet filtering). The second is the
			userspace binary which is used to manipulate rules in the kernelspace chains.
			</para>
		</section>
		<section>
			<!--tarek-->
			<title>Who is in charge?</title>
			<para>
			Otherwise known as the Coreteam, they are an elite few intent on proving to the
			general public that Linux can and is providing solid and production-grade
			firewalling capabilities.
			</para>
			<para>
			These omnipotent divinities came to be known as:
			<itemizedlist>
				<listitem>
					<para>
					<ulink url="mailto:laforge@netfilter.org">Harald Welte</ulink> (Chairman)
					</para>
				</listitem>
				<listitem>
					<para>
					<ulink url="mailto:kadlec@netfilter.org">Jozsef Kadlecsik</ulink>
					</para>
				</listitem>
				<listitem>
					<para>
					<ulink url="mailto:gandalf@netfilter.org">Martin Josefsson</ulink>
					</para>
				</listitem>
				<listitem>
					<para>
					<ulink url="mailto:kaber@netfilter.org">Patrick McHardy</ulink>
					</para>
				</listitem>
			</itemizedlist>
			</para>
			<para>
			For more information, check the
			<ulink url="http://netfilter.org/about.html#coreteam">Coreteam</ulink> section
			on the <ulink url="http://netfilter.org/">homepage</ulink>.
			</para>
		</section>
	</section>
	<!-- second-level section - begin -->
	<section id="uratf">
		<title id="uratf.title">About this FAQ</title>
		<section>
			<!--tarek-->
			<title>Where can I get the latest version of this FAQ?</title>
			<para>
			The latest published version of this FAQ is available on the netfilter
			<ulink url="http://netfilter.org/">homepage</ulink>, it can be found
			<ulink url="http://netfilter.org/documentation/index.html#documentation-faq">here</ulink>.
			</para>
			<para>
			However, for the most up-to-date content, you may wish to view the CVS sources
			<ulink url="http://cvs.netfilter.org/documentation/FAQ/">here</ulink>.
			</para>
		</section>
		<section>
			<!--tarek-->
			<title>How is this FAQ organized?</title>
			<para>
			The stucture is pretty intuitive and straight-forward (I hope).
			</para>
			<para>
			The "<link linkend="ur" endterm="ur.title"/>" subsection is more granular than others:
			<itemizedlist>
				<listitem>
					<para>
					"<link linkend="urhdiw" endterm="urhdiw.title"/>" contains tips on how to
					implement tasks
					</para>
				</listitem>
				<listitem>
					<para>
					"<link linkend="urwdiw" endterm="urwdiw.title"/>" explains why some tasks
					cannot be implemented with netfilter/iptables
					</para>
				</listitem>
				<listitem>
					<para>
					"<link linkend="urem" endterm="urem.title"/>" covers specific runtime error
					messages
					</para>
				</listitem>
				<listitem>
					<para>
					"<link linkend="urapo" endterm="urapo.title"/>" offers tricks that can
					improve your experience with netfilter/iptables
					</para>
				</listitem>
				<listitem>
					<para>
					"<link linkend="urcb" endterm="urcb.title"/>" lists hands-on steps to
					implementing a specific task
					</para>
				</listitem>
			</itemizedlist>
			</para>
		</section>
		<section>
			<!--tarek-->
			<title>How can I contribute to this FAQ?</title>
			<para>
			Any submissions regarding this FAQ should be sent to the
			<ulink url="mailto:faqmaster@iptables.org">FAQ maintainer</ulink>.
			</para>
			<para>
			Any suggestions pertaining to this FAQ are welcome, whether addressing an issue
			concerning structure or content. I also encourage you to notify me about any
			questions you feel should be covered in this FAQ and are missing.
			</para>
		</section>
	</section>
</section>

<!-- "End-User Questions" section - begin -->
<section>
	<title>End-User Questions</title>
	<!-- second-level section - begin -->
	<section>
		<title>Getting &amp; Building</title>
		<!-- third-level section - begin -->
		<section>
			<title>Getting</title>
			<section>
				<!--harald-->
				<title>Where can I get netfilter/iptables?</title>
				<para>
				Netfilter and IPtables are integrated in the Linux 2.4.x kernel series.
				Please obtain a recent kernel from <ulink url="http://www.kernel.org/">www.kernel.org</ulink> or one of its mirrors.
				</para>
				<para>
				The userspace tool 'iptables' is available at the netfilter homepage or on one of the mirrors at
				<ulink url="http://www.netfilter.org/">www.netfilter.org/</ulink>,
				<ulink url="http://www.iptables.org/">www.iptables.org/</ulink>.
				<ulink url="http://www.at.netfilter.org/" >www.at.netfilter.org</ulink>,
				<ulink url="http://www.cn.netfilter.org/">www.cn.netfilter.org</ulink>.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Is there a backport of netfilter to Linux 2.2?</title>
				<para>
				No, there currently is none. But if anybody wants to start, it shouldn't
				be too difficult because of the clean interface to the network stack.
				</para>
				<para>
				Please inform us about any work in this area.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Where can I find ipnatctl and more information about it?</title>
				<para>
				ipnatctl was used to set up your NAT rules from userspace in a very 
				early development revision of netfilter during the 2.3.x kernels.
				It is no longer needed, thus no longer available. All of its
				functionality is provided by iptables itself. Have a look at the
				NAT HOWTO on the Netfilter homepage.
				</para>
			</section>
		</section>
		<!-- third-level section - begin -->
		<section>
			<title>Building</title>
			<section>
				<!--harald-->
				<title>What is this patch-o-matic all about and how do I use it?</title>
				<para>
				The 2.4.x kernels is a stable release, so we can't just submit our
				current development into the mainstream kernel.  All our code is 
				developed and tested in netfilter patch-o-matic first.  If you
				want to use any of the bleeding-edge netfilter functions, you may have
				to apply one or more of the patches from patch-o-matic.   You can find
				patch-o-matic in the latest iptables package (or of course CVS), to be
				downloaded from the netfilter homepage.
				</para>
				<para>
				patch-o-matic now has three different options:
				<itemizedlist>
					<listitem>
						<para>
						make pending-patches
						</para>
					</listitem>
					<listitem>
						<para>
						make most-of-pom
						</para>
					</listitem>
					<listitem>
						<para>
						make patch-o-matic
						</para>
					</listitem>
				</itemizedlist>
				</para>
				<para>
				The first one is just to make sure all important bugfixes (which have
				been submitted to the kernel maintainers anyway) are applied to your kernel.
				The second `most-of-pom` additionally prompts you for all new features which
				can be applied without conflict.  The third option `patch-o-matic` is for
				real experts who want to see all the patches - but be aware, they might
				conflict which each other.
				</para>
				<para>
				patch-o-matic has a neat user interface.  Just enter
				</para>
				<para>
				<screen>
				make most-of-pom (or pending-patches or patch-o-matic, see above)
				</screen>
				</para>
				<para>
				or, if your kernel tree is not in <literal remap="tt">/usr/src/linux</literal> then use
				</para>
				<para>
				<screen>
				make KERNEL_DIR={your-kernel-dir} most-of-pom
				</screen>
				</para>
				<para>
				in the top directory of the iptables-package.  patch-o-matic checks
				for each of the patches if it would apply against the kernel source
				you have installed.  If a patch would apply, you will see a little
				prompt, where you can ask for more information about this patch, apply
				the patch, skip to the next one, ...
				</para>
				<para>
				For more information about patch-o-matic, please see the netfilter
				extensions HOWTO, to be found at
				<ulink url="http://www.netfilter.org/documentation/index.html#HOWTO">
				www.netfilter.org/documentation/index.html#HOWTO</ulink>
				</para>
			</section>
			<section>
				<!--harald-->
				<title>I cannot compile iptables-1.1.1 with kernel &#62;= 2.4.0-test4</title>
				<para>
				This is a known issue. The mechanism for the detection which patches 
				to apply is broken. Try using "make build" instead of "make".
				</para>
				<para>
				Better solution: Upgrade to iptables-1.1.2 or later
				</para>
			</section>
			<section>
				<!--harald-->
				<title>I cannot compile iptables 1.1.0 with recent kernels (&#62;= 2.3.99-pre8)</title>
				<para>
				Internal structures in iptables have changed. Upgrade to iptables &#62;= 1.1.1
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Some patch-o-matic patches from iptables &#62;= 1.2.1a don't work with kernel &#62;= 2.4.4</title>
				<para>
				Please use a recent iptables release.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>ipt_BALANCE, ip_nat_ftp, ip_nat_irc, ipt_SAME, ipt_NETMAP don't compile</title>
				<para>
				Most likely you are experiencing compile problems with a function called
				<literal remap="tt">ip_nat_setup_info</literal>. 
				</para>
				<para>
				If you are using iptables &lt;= 1.2.2, you <emphasis remap="bf">NEED</emphasis> to apply the
				`dropped-table' and `ftp-fixes' patches.
				</para>
				<para>
				If you are using iptables &#62; 1.2.2 or recent CVS, please <emphasis remap="bf">don't</emphasis> apply
				the 'dropped-table', as it is incompatible with BALANCE, NETMAP, irc-nat,
				SAME and talk-nat.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>I'm using Alan Cox' 2.4.x-acXX series kernel and I experience problems</title>
				<para>
				The netfilter core team bases development on Linus' kernel tree, so using the
				-ac series is on your own risk.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>ERROR: Invalid option KERNEL_DIR=/usr/src/linux-2.4.19</title>
				<para>
				I bet you are trying to run something like :
				<screen>
				# ./runme pending KERNEL_DIR=/usr/src/linux-2.4.19
				</screen>
				</para>
				<para>
				But bash/sh is not like make, and a variable cannot be passed as a parameter.
				You have to set the variable before you run the runme script :
				</para>
				<para>
				<screen>
				# KERNEL_DIR=/usr/src/linux-2.4.19 ./runme pending
				</screen>
				</para>
			</section>
		</section>
	</section>
	<!-- second-level section - begin -->
	<section id="ur">
		<title id="ur.title">Running</title>
		<!-- third-level section - begin -->
		<section id="urhdiw">
			<title id="urhdiw.title">How Does It Work?</title>
			<section>
				<!--tarek-->
				<title>I use the ROUTE target and connections are no longer NAT'ed, what's
				going on? I use the ROUTE target and I can't see the packet in any other rule
				or chain, what's going on?</title>
				<para>
				The default behavior of the ROUTE target in addition to its expected function is
				to directly deliver the packet to the routing code.
				</para>
				<para>
				However, this can be modified to make the packet continue traversing other
				rules or chains by using the <option>--continue</option> argument.
				</para>
			</section>
			<section>
				<!--tarek-->
				<title>What's the difference between the SNAT &amp; MASQUERADE targets?</title>
				<para>
				The MASQUERADE target is identical to the SNAT one in the sense that it
				modifies the ip source address of packets leaving through an interface,
				however, MASQUERADE dynamically uses the address bound to that interface and
				also drops the connections when that interface goes down.
				</para>
			</section>
			<section>
				<!--tarek-->
				<title>How do I interpret MAC address entries in my logs? Why do my logs
				reflect a 7-byte long MAC address?</title>
				<para>
				The first 6 bytes form the source MAC address, the following 6 bytes form the
				destination MAC address and the remaining two bytes describe the protocol
				(most commonly 00:08 which is IP Over Ethernet).
				</para>
			</section>
			<section>
				<!--tarek-->
				<title>How do I match against hostnames?</title>
				<para>
				Whether you hear answers in the positive or the negative, it is important to note
				that rules in kernelspace can never have hostnames anywhere. Some of you
				might ask, how is this possible when it is perfectly legal to use hostnames as
				arguments to the iptables userspace binary. The answer to this is that ip
				resolution happens at the time the iptables command is issued and the ip is
				injected into the kernelspace rule.
				</para>
				<para>
				A simpler answer to this FAQ is that you can use hostnames as arguments but
				it is not terribly secure as DNS records shouldn't be trusted and hostnames with
				multiple IPs (or aliases) will not be correctly represented in such a rule.
				</para>
				<para>
				A solution to this problem is to have a script fetch the IPs of a hostname and
				inject the rule(s). In the case of a hostname with multiple IPs, possibly group
				the IPs inside a user-defined chain and take the appropriate action against
				them. Explaining this further is beyond the scope of this FAQ, however, you
				might like to read the following <link linkend="mnci">FAQ</link>.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>How does SNAT to multiple addresses work?</title>
				<para>
				Netfilter tries to mangle as little as possible. So if we have a freshly-
				rebooted machine, and somebody behind the SNAT box opens a connection
				with local port 1234, the netfilter box only mangles the IP address and
				the port stays the same. 
				</para>
				<para>
				As soon as somebody else opens another connection
				with the same source port, netfilter would have to mangle IP and port if
				it only has a single IP for SNAT. 
				</para>
				<para>
				But if there are more than one available, it <emphasis remap="bf">again</emphasis> only has to
				mangle the IP part.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>How do I list all tracked / masqueraded connections, similar to 'ipchains -L -M' in 2.2.x ?</title>
				<para>
				There is a file in the proc-filesystem, which is called <literal remap="tt">/proc/net/ip_conntrack</literal>. You can print the output of this file using
				</para>
				<para>
				<screen>
				cat /proc/net/ip_conntrack
				</screen>
				</para>
			</section>
			<section>
				<!--harald-->
				<title>How do I list all available IP tables?</title>
				<para>
				All available IP tables are listed with
				<screen>
				cat /proc/net/ip_tables_names
				</screen>
				</para>
			</section>
			<section>
				<!--harald-->
				<title>I'm unable to use netfilter in combination with the Linux bridging code</title>
				<para>
				So you want to build a completely transparent firewall?  Great idea! 
				As of kernel 2.4.16, you still need to patch your kernel with an extra
				patch to get this running.  You can find it at
				<ulink url="http://bridge.sourceforge.net/">http://bridge.sourceforge.net/</ulink>.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Why does the connection tracking system track UNREPLIED connections with a high timeout?</title>
				<para>
				First, check if you are running a 2.4.20 kernel.  If yes, please apply
				immediately the patch from <ulink url="https://bugzilla.netfilter.org/cgi-bin/bugzilla/showattachment.cgi?attach_id=8" >https://bugzilla.netfilter.org/cgi-bin/bugzilla/showattachment.cgi?attach_id=8</ulink>! The 2.4.20 kernel did contain a bug resulting in lots of bogus UNREPLIED conntrack entries (see <ulink url="https://bugzilla.netfilter.org/cgi-bin/bugzilla/show_bug.cgi?id=56">https://bugzilla.netfilter.org/cgi-bin/bugzilla/show_bug.cgi?id=56</ulink>).
				</para>
				<para>
				So you have read /proc/net/ip_conntrack and found UNREPLIED entries with a very high timer (can be up to five days) and are wondering why we want to waste conntrack entries with UNREPLIED entries (which are obviously not connections)?
				</para>
				<para>
				The answer is easy: UNREPLIED entries are temporary entries, i.e. as soon as we
				run out of connection tracking entries (we reach
				/proc/sys/net/ipv4/ip_conntrack_max), we delete old UNREPLIED entries.  In other words: instead of having empty conntrack entries, we'd rather keep some maybe useful information in them until we really need them.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Why isn't the 'iptables -C' (--check) option implemented?</title>
				<para>
				Well, first of all, we're lazy ;).  To be honest, implementing a check option
				is almost impossible as soon as you start to do stateful firewalling.
				Traditional stateless firewalling bases it's decision just on information
				present in the packets header.  But with connection tracking (and '-m state'
				based rules), the outcome of the filtering decision depends on header+payload,
				as well as header+payload of previous packets within this connection.
				</para>
			</section>
		</section>
		<!-- third-level section - begin -->
		<section id="urwdiw">
			<title id="urwdiw.title">Why Doesn't It Work?</title>
			<section>
				<!--tarek-->
				<title>Does iptables provide UPnP&trade;?</title>
				<para>
				UPnP&trade; is not a networking protocol, it is a group of services which form an
				Internet Gateway Device (IGD for short),  as such, iptables should not provide
				similar functionality. However it can coexist with one.
				</para>
				<para>
				One implementation of the specification for Linux is available
				<ulink url="http://linux-igd.sf.net">here</ulink>.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>How do I stop worm XYZ with netfilter ?</title>
				<para>
				The short answer is you cannot do that properly with netfilter. Most of the worms are using
				a legitimate high level protocol (i.e. HTTP, SMTP(i.e VB script attached in email), or any exploit
				of a vulnerability found in the daemon handling the protocol). By high level protocol, we mean above TCP/IP.
				As iptables does not understand these high level protocols, it's almost impossible to filter
				part of them out properly. For that you need application filtering proxies.
				</para>
				<para>
				Please do not use the string match from patch-o-matic instead of application proxy filtering.
				It would be defeated anytime by fragmented packets (i.e. an HTTP request split on two TCP packets),
				by IDS evasion techniques, etc... you have been warned!
				The string match is useful but for different purposes.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Is there an ICQ conntrack/NAT helper module?</title>
				<para>
				If you are used to masquerading on a Linux 2.2 box, you always used the
				ip_masq_icq module in order to get direct client-to-client ICQ working.
				</para>
				<para>
				Nobody re-implemented this module for netfilter, because the ICQ protocol
				is too ugly :) But I guess it's just a matter of time until one is available.
				</para>
				<para>
				Rusty once pointed out that only modules for protocols with at least one
				free client and one free server are going to get integrated into the main
				netfilter distribution. As for ICQ, there are only free clients, so it
				doesn't match this criteria. (free as in freedom, not in free beer, i.e.
				RMS' definition)
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Where did the ip_masq_vdolive / ip_masq_quake / ... modules go?</title>
				<para>
				Some of them are not required, and some haven't been ported to
				netfilter yet.  Netfilter does full connection tracking even for UDP,
				and has a policy of trying to disturb the packets at little as
				possible, so sometimes things `just work'.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Can iptables/ip6tables do IPv6 NAT?</title>
				<para>
				No, the NAT core does not support any kind of IPv6 or IPv6/IPv4 NAT.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Are there any plans to support SIP?</title>
				<para>
				The SIP (Session Initiation Protocol) is quite complex, especially getting it
				acrosss firewalls and NAT devices.  The initial proposal was a proxy
				communicating over FCP (Firewall Control Protocol) with the packet filter.  Now
				an IETF MIDCOM working group has been founded, ... meanwhile, people want to
				use SIP.
				</para>
				<para>
				The netfilter/iptables team has currently no resources to implement SIP
				conntrack/NAT support, but we're always open for sponsors :)
				</para>
			</section>
			<section>
				<!--harald-->
				<title>Does netfilter/iptables support failover/HA?</title>
				<para>
				The answer is a clear 'yes' and 'no'.
				</para>
				<para>
				If you are thinking about a full failover, while all the state
				information is preserved: <emphasis remap="bf">Not really</emphasis>.  Doing state synchronization
				between multiple nodes is a difficult process.  Harald (of the netfilter core
				team) has published a paper about this, but not yet found any sponsor to fund
				the development.  Meanwhile, you can try to use our 'connection pickup'
				feature, which &lsqb;after a failover] tries to pick up already established
				connections: <emphasis remap="bf">Might be sufficient depending on the requirements</emphasis>.
				</para>
				<para>
				If you do NAT and want to preserve your NAT mappings: <emphasis remap="bf">No</emphasis>.
				</para>
				<para>
				If you do statless packet filtering: <emphasis remap="bf">Yes</emphasis>
				</para>
			</section>
			<section>
				<!--harald-->
				<title>The IRC module is unable to handle DCC RESUME</title>
				<para>
				Well, that's half the truth.  Only the NAT module is unable to handle
				them.  If you just use firewalling without NAT it should work fine.
				Patches welcome.
				</para>
			</section>
		</section>
		<!-- third-level section - begin -->
		<section id="urem">
			<title id="urem.title">Error Messages</title>
			<section>
				<!--tarek-->
				<title>I am getting "MASQUERADE: Route sent us somewhere else." and/or
				"MASQUERADE: No route: Rusty's brain broke!", what does this mean?</title>
				<para>
				Short answer is try SNAT or easy up on the routing magic you're doing.
				</para>
				<para>
				Longer answer is that you're probably using the MASQUERADE target with some
				source-based routing which is making netfilter and the routing code expect different
				outgoing interfaces and MASQUERADE is behaving itself and reporting the issue.
				</para>
				<para>
				This is being worked on. For more information, please consult
				<ulink url="https://bugzilla.netfilter.org/cgi-bin/bugzilla/show_bug.cgi?id=144">this</ulink>
				bugzilla entry and
				<ulink url="http://lists.netfilter.org/pipermail/netfilter-devel/2004-January/013687.html">this</ulink>
				thread on the netfilter-devel mailing list.
				</para>
			</section>
			<section>
				<!--harald-->
				<title>ip_conntrack: maximum limit of XXX entries exceeded</title>
				<para>
				If you notice the following message in syslog, it looks like the conntrack
				database doesn't have enough entries for your environment. Connection
				tracking by default handles up to a certain number of simultaneous connections.
				This number is dependent on you system's maximum memory size (at 64MB: 4096,
				128MB: 8192, ...). 
				</para>
				<para>
				You can easily increase the number of maximal tracked connections, but be 
				aware that each tracked connection eats about 350 bytes of non-swappable 
				kernel memory!
				</para>
				<para>
				To increase this limit to e.g. 8192, type:
				</para>
				<para>
				<screen>
				echo "8192" &#62; /proc/sys/net/ipv4/ip_conntrack_max
				</screen>
				</para>
				<para>
				To optimize performance, please also raise the number of hash buckets by using
				the <literal remap="tt">hashsize</literal> module loadtime parameter of the <literal remap="tt">ip_conntrack.o</literal>
				module. Please note that due to the nature of the current hashing algorithm, an
				even hash bucket count (and esp. values of the power of two) are a bad choice.
                </para>
                <para>
                Example (with 1023 buckets):
                <screen>
                modprobe ip_conntrack hashsize=1023
                </screen>
                </para>
            </section>
            <section>
                <!--harald-->
				<title>NAT: X dropping untracked packet Y Z aaa.aaa.aaa.aaa -&#62; 224.bbb.bbb.bbb</title>
                <para>
                This message is printed by the NAT code, because multicast packets are hitting
                the NAT table, and connection tracking doesn't handle multicast packets right 
                now. In case you have no idea what multicast is, or don't need it at all, use:
                <screen>
                iptables -t mangle -I PREROUTING -j DROP -d 224.0.0.0/8
                </screen>
                </para>
            </section>
            <section>
                <!--harald-->
				<title>NAT: X dropping untracked packet Y Z aaa.aaa.aaa.aaa -&#62; bbb.bbb.bbb.bbb</title>
                <para>
                My syslog or my console shows the message:
                <screen>
                NAT: X dropping untracked packet Y Z aaa.aaa.aaa.aaa -&#62; bbb.bbb.bbb.bbb
                </screen>
                </para>
                <para>
                This message is printed by the NAT code. It drops packets, because in order to
                do NAT it has to have valid connection tracking information. This message is
                printed for all packets for which connection tracking was unable to determine
                conntrack information.
                </para>
                <para>
                Possible reasons are:
                <itemizedlist>
                    <listitem>
                        <para>
                        maximum limit of entries in the conntrack database reached
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        couldn't determine inverted tuple (multicast, broadcast)
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        kmem_cache_alloc fails (out of memory)
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        reply on unconfirmed connection
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        multicast packet (please see previous question)
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        icmp packet too short
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        icmp is fragmented
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        icmp checksum wrong
                        </para>
                    </listitem>
                </itemizedlist>
                </para>
                <para>
                If you want to have a more detailed logging of these packets (i.e. if
                you suspect it are remote probe / scanning packets), use the following
                rule:
                <screen>
                iptables -t mangle -A PREROUTING -j LOG -m state --state INVALID
                </screen>
                </para>
                <para>
                And yes, you have to put the rule in the mangle table, because the
                packets get dropped by the NAT code before they reach the filter
                table.
                </para>
            </section>
            <section>
                <!--harald-->
				<title>ip_conntrack: max number of expected connections N of M reached for aaa.aaa.aaa.aaa -&#62; bbb.bbb.bbb.bbb</title>
                <para>
                My sylog or console regularly shows messages like:
                <screen>
                ip_conntrack: max number of expected connections N of M reached for aaa.aaa.aaa.aaa -&#62; bbb.bbb.bbb.bbb
                </screen>
                </para>
                <para>
                This is normally nothing to worry about, especially if <literal remap="tt">N</literal> and
                <literal remap="tt">M</literal> are <literal remap="tt">1</literal>, and the message is followed by <literal remap="tt">, reusing</literal>.
                In particular versions of the linux kernel (2.4.19&lt;=x&lt;=2.4.21-pre3), this
                message was printed for FTP - And in fact this can happen during normal FTP
                operation.  
                </para>
                <para>
                With upcoming kernel versions (&gt;=2.4.21-pre4) this message is no longer
                printed to not confuse the user.  If you still receive messages like this,
                contact the <ulink url="http://lists.netfilter.org/mailman/listinfo/netfilter-devel">http://lists.netfilter.org/mailman/listinfo/netfilter-devel</ulink> mailinglist.
                </para>
            </section>
            <section>
                <!--harald-->
				<title>iptables-save / iptables-restore from iptables-1.2 segfaults</title>
                <para>
                Known Bug.  Please update to latest CVS or use iptables &#62;= 1.2.1 as 
                soon as it is available.
                </para>
            </section>
            <section>
                <!--harald-->
				<title>kernel logs: Out of window data xxx</title>
                <para>
                You use the tcp-window-tracking patch from patch-o-matic, which code keeps
                track the acceptable packets for the allowed TCP streams according to the
                sequence/acknowledgement numbers, segment sizes, etc of the packets. When
                it detects that one of the packets is not acceptable (out of the window),
                it marks it as INVALID and prints the message above.
                </para>
                <para>
                Newer versions logs the packet and exactly what condition failed for it:
                <itemizedlist>
                    <listitem>
                        <para>
                        ACK is under the lower bound (possibly overly delayed ACK)
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        ACK is over the upper bound (ACKed data has never seen yet)
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        SEQ is under the lower bound (retransmitted already ACKed data)
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                        SEQ is over the upper bound (over the window of the receiver)
                        </para>
                    </listitem>
                </itemizedlist>
                </para>
                <para>
                Also, in newer versions the logging can completely be suppressed via
                sysctl
                <screen>
                echo 0 &#62; /proc/sys/net/ipv4/netfilter/ip_ct_tcp_log_out_of_window
                </screen>
                </para>
            </section>
            <section>
                <!--harald-->
				<title>Why can't i use the REJECT target in PREROUTING chains?</title>
                <para>
                The REJECT target is for filtering. The filter table has got the
                INPUT/OUPUT/FORWARD chains, therfore the REJECT target can only be used in
                those chains (and sub-chains, naturally).
                </para>
                <para>
                Netfilter users do not filter packets in the nat or mangle tables.
                </para>
            </section>
            <section>
                <!--harald-->
				<title>'iptables: Invalid argument' after kernel update (nat table)</title>
                <para>
                You have just upgraded your kernel and suddenly some of the commands
                (especially in the 'nat' table), and you experience something like:
                <screen>
                # iptables -A POSTROUTING -t nat -o ppp0 -j MASQUERADE
                iptables: Invalid argument
                </screen>
                </para>
                <para>
                This happens when the structure size between kernel and userspace changes.
                You will need to recompile the iptables userspace program using the include
                files of your new kernel.  This only happens if you (or the vendor of your
                kernel) has applied some patches either only to  the old or only to the new
                kernel.   It is not supposed to happen between vanilla kernel.org kernels. If
                it does, please inform the netfilter-devel mailinglist.
                </para>
            </section>
        </section>
        <!-- third-level section - begin -->
        <section id="urapo">
            <title id="urapo.title">Added Performance &amp; Optimization</title>
            <section>
                <!--harald-->
				<title>iptables -L takes a very long time to display the rules</title>
                <para>
                This is because iptables does a DNS lookup for each IP address. As each
                rule consists out of two addresses, the worst case is two DNS lookups per
                rule.
                </para>
                <para>
                The problem is, if you use private IP addresses (like 10.x.x.x or 192.168.x.x),
                DNS is unable to resolve a hostname and times out. The sum of all these 
                timeouts may be _very_ long, depending on your ruleset.
                </para>
                <para>
                Please use the -n (numeric) option for iptables in order to prevent it from
                making reverse DNS lookups.
                </para>
            </section>
            <section>
                <!--harald-->
				<title>How do I stop the LOG target from logging to my console?</title>
                <para>
                You have to configure your syslogd and/or klogd appropriately:
                The LOG target logs to facility kern at priority warning (4).
                See the syslogd.conf manpage to learn more about facilities and priorities.
                </para>
                <para>
                By default, all kernel messages at priority more severe than debug (7)
                are sent to the console. If you raise that to 4, instead of 7, you will
                make the LOG messages no longer appear on the console.
                </para>
                <para>
                Be aware that this might also suppress other important messages from 
                appearing on the console (does not affect syslog).
                </para>
            </section>
        </section>
        <!-- third-level section - begin -->
        <section id="urcb">
            <title id="urcb.title">Cookbook</title>
            <section>
            	<!--tarek-->
            	<title>How do I forward a local connection (originating from a local
            	process)?</title>
            	<para>
            	This can be accomplished in two steps:
            	</para>
            	<para>
            	First of all, you have to make sure your kernel supports this by having
            	<literal remap="tt">IP_NF_NAT_LOCAL</literal>
            	(<literal remap="tt">Local NAT support</literal>) enabled.
            	</para>
            	<para>
            	Then you would use the DNAT target exactly as you would in
            	<literal remap="tt">nat</literal>'s <literal remap="tt">PREROUTING</literal>,
            	only, in <literal remap="tt">nat</literal>'s
            	<literal remap="tt">OUTPUT</literal>.
            	</para>
            </section>
			<section>
				<!--tarek-->
				<title>My iptables-based gateway only allows me to access a few websites, how
				can I solve this? I try to initiate a tcp connection through my iptables-based
				gateway and it dies after a very short time, what gives?</title>
				<para>
				The following command on the gateway should set things straight:
				<screen>
				# iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
				</screen>
				</para>
				<para>
				For further info, please consult the <literal remap="tt">iptables(8)</literal>
				man page and the TCPMSS target section.
				</para>
			</section>
            <!--tarek-->
			<section id="mnci">
				<title id="mnci.title">How do I match against multiple, non-consecutive IP
				addresses in one rule?</title>
				<para>
				This answer will be often referred to to illustrate procedures to solve
				similar problems so I'm going to elaborate as much as I can considering this
				is a FAQ.
				</para>
				<para>
				This cannot be accomplished with one rule. However, as with most similar
				questions, the answer is to create a user-defined chain:
				</para>
				<para>
				Say you want you have an elaborate set of matches and a target which should
				apply to that set of IPs (or any other criterion), we'll assume you're worried
				about the maintainability of your rules and you might wish to change the
				target later on so we'll call the target TARGETX where TARGETX could either be
				a built-in target or a user-defined chain.
				</para>
				<para>
				We first setup and have rules which only match the dynamic part of the rules,
				the IP addresses here:
				</para>
				<screen>
				# iptables -N matchGroup
				# iptables -A matchGroup -s &lt;IP1&gt; -j TARGETX
				# iptables -A matchGroup -s &lt;IP2&gt; -j TARGETX
				# iptables -A matchGroup -s &lt;IP3&gt; -j TARGETX
				# ...
				</screen>
				<para>
				Then, we activate the user-defined chain by pointing to it from the parent
				chain (let's call it CHAINX) where we originally intended the rule with
				multiple IPs (or any other criterion) to be, as follows:
				</para>
				<screen>
				# iptables -A CHAINX &lt;elaborate set of matches here&gt; -j matchGroup
				</screen>
				<para>
				That's all folks! Remember that this is just a demonstration, as detailed as
				suitable within the confines of this FAQ, improvements can be made
				depending on specific setups.
				</para>
			</section>
            <section>
                <!--harald-->
				<title>How do I use the LOG target / How can i LOG and DROP?</title>
                <para>
                The LOG target is what we call a "non-terminating target", i.e. it doesn't 
                terminate the packets rule traversal.  If you use the LOG target, the packet
                will be logged, and rule traversal continues at the next rule.
                </para>
                <para>
                So how do I log and drop at the same time? Nothing easier than that, you
                create a custom chain which contains the two rules:
                </para>
                <para>
                <screen>
                iptables -N logdrop
                iptables -A logdrop -j LOG
                iptables -A logdrop -j DROP
                </screen>
                </para>
                <para>
                Now everytime you want to log and drop a packet, you can easily use a
                "-j logdrop".
                </para>
            </section>
            <section>
                <!--harald-->
				<title>How do I build a transparent proxy using squid and iptables?</title>
                <para>
                First, of course, you need a suitable DNAT or REDIRECT rule. Use REDIRECT
                only if squid is running on the NAT box itself. Example:
                <screen>
                iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 192.168.22.33:3128
                </screen>
                </para>
                <para>
                After that, you have to configure squid appropriately. We can only give
                short notes here, please refer to the squid documentation for further details.
                </para>
                <para>
                The squid.conf for Squid 2.3 needs to be something like the following:
                <screen>
                http_port 3128
                httpd_accel_host virtual
                httpd_accel_port 80
                httpd_accel_with_proxy  on
                httpd_accel_uses_host_header on
                </screen>
                Squid 2.4 needs an <emphasis remap="bf">additional</emphasis> line added:
                </para>
                <para>
                <screen>
                httpd_accel_single_host off
                </screen>
                </para>
            </section>
        </section>
    </section>
</section>


<!-- "Developer" section - begin -->
<section>
    <title>Developer Questions</title>
    <!-- second-level section - begin -->
    <section>
        <title>How Does It Work?</title>
        <!-- third-level section - begin -->
        <section>
            <!--harald-->
			<title>I don't understand how to use the QUEUE target from userspace</title>
            <para>
            A library called libipq is provided for userspace packet handling.
            There is now documentation for this in the form of man pages.  You
            need to build and install the iptables development components:
            <screen>
            make install-devel
            </screen>
            </para>
            <para>
            then see libipq(3).
            </para>
            <para>
            You may also be interested in the Perl bindings for libipq, Perlipq at:
            <ulink url="http://www.intercode.com.au/jmorris/perlipq/">http://www.intercode.com.au/jmorris/perlipq/</ulink>.  The binding itself
            is an example of using the library.
            </para>
            <para>
            Other code examples include:
            </para>
            <para>
            <itemizedlist>
                <listitem>
                    <para>
                    testsuite/tools/intercept.c from netfilter CVS
                    </para>
                </listitem>
                <listitem>
                    <para>
                    ipqmpd (see <ulink url="http://www.gnumonks.org/projects/">http://www.gnumonks.org/projects/</ulink>)
                    </para>
                </listitem>
                <listitem>
                    <para>
                    nfqtest, part of netfilter-tools (see <ulink url="http://www.gnumonks.org/projects/">http://www.gnumonks.org/projects/</ulink>)
                    </para>
                </listitem>
                <listitem>
                    <para>
                    Jerome Etienne's WAN simulator (see <ulink url="http://www.off.net/~jme/">http://www.off.net/~jme/</ulink>)
                    </para>
                </listitem>
            </itemizedlist>
            </para>
        </section>
        <section>
            <!--harald-->
			<title>I want to contribute some code, but have no idea what to do</title>
            <para>
            The netfilter core-team keeps a TODO list where it lists all the desired
            changes / new features. You can retrieve this list via anonymous CVS,
            instructions are on the netfilter Homepage. Alternatively you can also go
            to <ulink url="http://cvs.netfilter.org/cgi-bin/cvsweb/netfilter/TODO/">
            http://cvs.netfilter.org/cgi-bin/cvsweb/netfilter/TODO/</ulink> using
            CVSweb.
            </para>
        </section>
        <section>
            <!--harald-->
			<title>I've fixed a bug or written an extension. How do I contribute it?</title>
            <para>
            If you want to publish it, please send it to the netfilter-devel mailinglist.
            Subscription instructions are at <ulink url="http://lists.netfilter.org/mailman/listinfo/netfilter-devel/">http://lists.netfilter.org/mailman/listinfo/netfilter-devel/</ulink>. 
            </para>
            <para>
            The correct way of sending a patch is the following :
            <itemizedlist>
                <listitem>
                    <para>
                     Subject starting with <emphasis remap="bf">[PATCH]</emphasis>
                    </para>
                </listitem>
                <listitem>
                    <para>
                     Included straight in the body of the message, not MIME'd.
                    </para>
                </listitem>
                <listitem>
                    <para>
                    a cvs-checkin/Changelog entry outside the diff.
                    </para>
                </listitem>
                <listitem>
                    <para>
                     `diff -u old new' form, from outside root directory (ie. can be applied with -p1 when sitting in the untarred dir.
                    </para>
                </listitem>
            </itemizedlist>
            </para>
            <para>
            If you wrote a new extension, or added some new options to an old extension, it's usually
            a good idea to also update the netfilter-extension-HOWTO to include that new extension/functionality description.
            Additionally, it will draw more users to your extension, and will allow you to get more feedback in general.
            </para>
        </section>
    </section>
    <!-- second-level section - begin -->
    <section>
        <title>Why Doesn't It Work?</title>
        <!-- third-level section - begin -->
        <section>
            <!--harald-->
			<title>Is there an C/C++ API for adding/removing rules?</title>
            <para>
            The answer unfortunately is: No.
            </para>
            <para>
            Now you might think 'but what about libiptc?'.  As has been pointed out
            numerous times on the mailinglist(s), libiptc was _NEVER_ meant to be used as a
            public interface.  We don't guarantee a stable interface, and it is planned to
            remove it in the next incarnation of linux packet filtering.  libiptc is way
            too low-layer to be used reasonably anyway.
            </para>
            <para>
            We are well aware that there is a fundamental lack for such an API, and we
            are working on improving that situation. Until then, it is recommended to
            either use system() or open a pipe into stdin of iptables-restore.  The latter
            will give you a way better performance.
            </para>
        </section>
    </section>
    <!-- second-level section - begin -->
    <section>
        <title>Error Messages</title>
        <!-- third-level section - begin -->
        <section>
            <!--harald-->
			<title>My libipq application says "Failed to received netlink message: No buffer space available"</title>
            <para>
            This means that the kernel-side Netlink socket buffer ran out of space; the userspace
            application is not able to handle the amount of data being delivered from the kernel.
            </para>
            <para>
            <quote><emphasis>Is it possible to make those kernel buffers bigger so that I don't run into this problem?</emphasis>
            </quote>
            </para>
            <para>
            Yes, these are standard Netlink sockets, and you can tune their receive 
            buffer sizes via /proc/sys/net/core, sysctl, or use the SO_RCVBUF socket
            option on the file descriptor. 
            </para>
            <para>
            You can also try ensuring that your application is reading any received data as
            quickly as possible.  If you don't need the entire packet, try copying less
            data to userspace (see ipq_set_mode(3)).
            </para>
        </section>
    </section>
</section>
</article>
