Configuring kernel options and installing packages
Configuring networking options
Start by running the kernel configuration menu as usual.
lisa ~ # cd /usr/src/linux
lisa linux # make menuconfig
Now navigate to the Networking Options menu, find the Netfilter option as shown
below and enable it.
Networking options | - Network packet filtering framework (Netfilter) --->
| |
Ensure that network packet filtering debugging is disabled as shown below.
Network packet filtering framework (Netfilter) | - Network packet filtering framework (Netfilter)
- Network packet filtering debugging
- Advanced netfilter configuration
- Core Netfilter Configuration --->
- IP virtual server support
- IP: Netfilter Configuration --->
| -
- CONFIG_NETFILTER_DEBUG
- CONFIG_NETFILTER_ADVANCED
-
- CONFIG_IP_VS
-
|
Configuring core Netfilter options
We can now configure the core Netfilter components that we require. Depending on your
security policy and firewall application you may need to include some extra components
or, if they are not required, exclude some components.

If you intend to follow all the steps in this guide then you will need to include at least
the components listed below.
Configuring IP Netfilter options
Once the core Netfilter components have been configured we can proceed with configuration of
the IP specific components of the Netfilter framework. As before you may need to include
some extra components or, if they are not required, exclude some components depending on
your security policy and the intended application of your firewall.

If you intend to follow all the steps in this guide then you will need to include at least
the components listed below.
IP: Netfilter Configuration- [*]
- [*]
- [ ]
- [*]
- [*]
- [ ]
- [ ]
- [ ]
- [*]
- [*]
- [*]
- [ ]
- [*]
- [*]
- [*]
- [*]
- [ ]
- [*]
- [ ]
- [ ]
- [ ]
- [ ]
- [ ]
| - IPv4 connection tracking support (required for NAT)
- proc/sysctl compatibility with old connection tracking
- IP Userspace queueing via NETLINK (OBSOLETE)
- IP tables support (required for filtering/masq/NAT)
- "addrtype"address type match support
- "ah" match support
- "ecn" match support
- "ttl" match support
- Packet filtering
- LOG target support
- ULOG target support (OBSOLETE)
- Full NAT
- MASQUERADE target support
- NETMAP target support
- REDIRECT target support
- Basic SNMP-ALG support
- Packet mangling
- CLUSTERIP target support
- ECN target support
- TTL target support
- raw table support (required for NOTRACK/TRACE)
- ARP tables support
| - CONFIG_NF_CONNTRACK_IPV4
- CONFIG_NF_CONNTRACK_PROC_COMPAT
- CONFIG_IP_NF_QUEUE
- CONFIG_IP_NF_IPTABLES
- CONFIG_IP_NF_MATCH_ADDRTYPE
- CONFIG_IP_NF_MATCH_AH
- CONFIG_IP_NF_MATCH_ECN
- CONFIG_IP_NF_MATCH_TTL
- CONFIG_IP_NF_FILTER
- CONFIG_IP_NF_TARGET_REJECT
- CONFIG_IP_NF_TARGET_LOG
- CONFIG_IP_NF_TARGET_ULOG
- CONFIG_NF_NAT
- CONFIG_IP_NF_TARGET_MASQUERADE
- CONFIG_IP_NF_TARGET_NETMAP
- CONFIG_IP_NF_TARGET_REDIRECT
- CONFIG_NF_NAT_SNMP_BASIC
- CONFIG_IP_NF_MANGLE
- CONFIG_IP_NF_TARGET_CLUSTERIP
- CONFIG_IP_NF_TARGET_ECN
- CONFIG_IP_NF_TARGET_TTL
- CONFIG_IP_NF_RAW
- CONFIG_IP_NF_ARPTABLES
|
Building and installing the kernel
With the kernel configuration completed all that remains is to build and install
the new kernel in the usual way.

If you have built the Netfilter or iptables
modules as loadable kernel modules then you will have to ensure that they are loaded
before continuing. The easiest method is to add them to the
/etc/modules.autoload.d/kernel-2.6 file so they will be automatically loaded when
the system starts, and thus when the system is restarted with the new kernel.
Installing the userspace tools
As usual with Gentoo installation of the userspace tools is trivial. Simply emerge
the iptables package and add iptables
to the default run-level as shown below.
lisa ~ # emerge iptables
lisa ~ # rc-update add iptables default

If you have built the Netfilter components into the kernel, instead of compiling them as
loadable modules, you can add iptables to the boot run-level and have it start before the
net scripts.