# How to add iptables as a module?

## lamekain

I wasn't bright enough to compile iptables into my kernel the first time so I tried installing it as a module. I read the module.txt in the kernel source and did: make menuconfig. I changed Networking options--->Network packet filtering (replaces ipchains)  to be installed, and Networking options---> IP: Netfilter Configuration  ---> IP tables support (required for filtering/masq/NAT) to be modularized.

then I did what modules.txt told me. I booted the machine and the kernel worked, but my module didn't. When I typed insmod ip_tables I got this: 

Using /lib/modules/2.4.20-gentoo-r8/kernel/net/ipv4/netfilter/ip_tables.o

/lib/modules/2.4.20-gentoo-r8/kernel/net/ipv4/netfilter/ip_tables.o: unresolved symbol nf_unregister_sockopt

/lib/modules/2.4.20-gentoo-r8/kernel/net/ipv4/netfilter/ip_tables.o: unresolved symbol nf_register_sockopt

What can I do?

----------

## dsd

the userspace "iptables" does a great job at loading modules when needed. if i were you i'd just "emerge iptables" and continue as normal, and deal with any errors if/when you encounter them that way

----------

## lamekain

I'm not sure we are talking about the same thing here(I am a n00b so I might be wrong), but my problem is that I did emerge iptables(without problems), I just can't get it working in my kernel. 

 *Quote:*   

> the userspace "iptables" does a great job at loading modules when needed

 

Do you mean running the "iptables" command does a great job? I emerged gtk-iptables to control iptables with a gui. running gtk-iptables gives me this:

root@mylly / # gtk-iptables

/lib/modules/2.4.20-gentoo-r8/kernel/net/ipv4/netfilter/ip_tables.o: unresolved symbol nf_unregister_sockopt

/lib/modules/2.4.20-gentoo-r8/kernel/net/ipv4/netfilter/ip_tables.o: unresolved symbol nf_register_sockopt

/lib/modules/2.4.20-gentoo-r8/kernel/net/ipv4/netfilter/ip_tables.o: insmod /lib/modules/2.4.20-gentoo-r8/kernel/net/ipv4/netfilter/ip_tables.o failed

/lib/modules/2.4.20-gentoo-r8/kernel/net/ipv4/netfilter/ip_tables.o: insmod ip_tables failed

iptables v1.2.8: can't initialize iptables table `filter': iptables who? (do you need to insmod?)

Perhaps iptables or your kernel needs to be upgraded.

That is why I'm trying to install iptables as a module for the kernel, without success..

help?

----------

## FreeFly42

If you emerged iptables before recompiling your kernel you might try emerging it again.

----------

## lamekain

Hi, I did this: booted with the kernel that does support iptables as a module, and emerged iptables. Emerging went ok. Then I rebooted again(using the same kernel), just to be safe... and ran modprobe ip_tables and got the same reply as last time... didn't work. When I emerge the iptables-module, do I have to 'make modules' and 'make modules_install' again? Should I add the module somewhere like in modules.autoload?

----------

## lamekain

I think I got it working.. I installed it the same time with ALSA, and now it only complains about the lack of rules(which I will generate with the script..).

After getting ALSA and iptables to work, I ran into a new problem: eth0 has gone missing... I wanted to go back to the starting position so I emerged the original gentoo-sources and used genkernel.. Now Gnome doesn't start anymore --> https://forums.gentoo.org/viewtopic.php?p=673097

Anyway, thanks for your help.. I just hope I get Gnome working without unnecessary violence.   :Confused: 

----------

## FreeFly42

Make sure you have the dependencies correct in your init process.  ip tables probably requires a net provider (if it loads after the net provider it may unload it, then not reload it, which may be why you've lost eth0).   Gnome doesn't seem to start happily when there is no net provider either, make sure you have lo booting and hard-code an entry in your hosts file for your local box.  Without a hard-coded entry for my local machine I periodically had strange problems with Gnome, cups, etc, which were fully resolved by the hosts file.

Good luck!

----------

## lundi

 *lamekain wrote:*   

> I wasn't bright enough to compile iptables into my kernel the first time so I tried installing it as a module. I read the module.txt in the kernel source and did: make menuconfig. I changed Networking options--->Network packet filtering (replaces ipchains)  to be installed, and Networking options---> IP: Netfilter Configuration  ---> IP tables support (required for filtering/masq/NAT) to be modularized.
> 
> then I did what modules.txt told me. I booted the machine and the kernel worked, but my module didn't. When I typed insmod ip_tables I got this: 
> 
> Using /lib/modules/2.4.20-gentoo-r8/kernel/net/ipv4/netfilter/ip_tables.o
> ...

 

hi, how did resolve the problem? I meet the same problem with yours. I have compiled kernel and emerge iptables many times. Thanks for help.

----------

## lamekain

Yep, I solved it.

First you need configure your kernel sources. Like this:

```
cd /usr/src/linux

make menuconfig
```

This should bring up a kernel configuration screen. You should select as modules(by pressing m) the things I mentioned in the first post and most the things in the IP: Netfilter Configuration which are not experimental. Also you don't need the ipchains support and a few more thingies that have a (read help)-text after them (sorry I can't check which ones, I'm stuck to a Window$ computer   :Crying or Very sad:  ).

Then after you have configured your kernel you do the following commands:

```
make dep

make clean

make bzImage

make modules

make modules_install     #you have to be root for this one

emerge iptables             #bring the iptables module up

####bring all other modules you need for your box. e.g nvidia-kernel, if you have a nvidia graphics card

mount /boot

cd /usr/src/linux/arch/i386/boot

cp bzImage /boot            #copy the bzImage you made with make bzImage

####configure lilo in /etc/lilo.conf

/sbin/lilo 

####reboot

```

----------

## lundi

Thanks. I also sloved it. Because the config you said I selected originally. My solution is backup .config file then do make rmproper. And then complie kernel again.

----------

## BeppeSqualo

I've got the same problem on my gentoo-box 

I think this is caused by a bad kernel configuration.

 *lamekain wrote:*   

>  Also you don't need the ipchains support 
> 
> 

 

How can I do this? I can't find any ipchains support in networking configuration menu.

Can you send me your net configuration in the /usr/src/linux/.config file ?

tx

BeppeSqualo

----------

## dlambeth

If your installing from the live CD, just add iptables into the kernel before your build it. So if you use genkernel, just type in the command:

genkernel --config

This will give you kernel module options and look for neworking options and then iptables. There are several options (new) so just try to select the default options or the ones your familiar with. If you don't know, just make sure you don't select the (experimental) or the (read help) options.

Hope I could assist.

----------

