Using iptables in android

2,866 views
Skip to first unread message

Alpha Jin

unread,
Jan 29, 2010, 3:22:23 AM1/29/10
to Android Linux Kernel Development
I just wanted to use iptables in android

So I enable NETFILTER in kernel, and build the kernel.

But when I typed "iptables -L" in adb shell.
It always promoted:

iptables v1.3.7: can't initialize iptables table `filter': iptables
who? (do you
need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

Does anyone know what the problem?

thanks!

Markus Fritsche

unread,
Jan 29, 2010, 8:10:56 PM1/29/10
to Android Linux Kernel Development

On 29 Jan., 09:22, Alpha Jin <alphali...@gmail.com> wrote:
> I just wanted to use iptables in android
>
> So I enable NETFILTER in kernel, and build the kernel.
>
> But when I typed "iptables -L" in adb shell.
> It always promoted:
>
> iptables v1.3.7: can't initialize iptables table `filter': iptables
> who? (do you
>  need to insmod?)

The dependencies aren't that great... for intance, to do basic
tethering you'll need:


insmod /system/libmodules/nf_conntrack.ko
insmod /system/libmodules/nf_conntrack_ipv4.ko
insmod /system/libmodules/nf_nat.ko
insmod /system/libmodules/x_tables.ko
insmod /system/libmodules/ip_tables.ko
insmod /system/libmodules/xt_multiport.ko
insmod /system/libmodules/iptable_filter.ko
insmod /system/libmodules/iptable_nat.ko
insmod /system/libmodules/ipt_MASQUERADE.ko
insmod /system/libmodules/xt_state.ko

Alpha Jin

unread,
Jan 31, 2010, 8:52:26 PM1/31/10
to android...@googlegroups.com
I don't understand, could you please describe it in details?

Thanks!


2010/1/30 Markus Fritsche <fritsch...@googlemail.com>



--
Best regards,
Alpha


nfsnfs chen

unread,
Feb 1, 2010, 4:18:34 AM2/1/10
to android...@googlegroups.com

I think CONFIG_NETFILTER needs to be set in your kernel config.


--
Best regards,
nfsnfs

Markus Fritsche

unread,
Feb 1, 2010, 4:42:46 AM2/1/10
to android...@googlegroups.com
Alpha Jin <alphalilin <at> gmail.com> writes:

> I don't understand, could you please describe it in details?Thanks!

Those are the modules which are needed to setup the filter table. The
corresponding .config entries:

CONFIG_NETFILTER=y
CONFIG_NETFILTER_ADVANCED=y

#
# Core Netfilter Configuration
#
CONFIG_NF_CONNTRACK=m
CONFIG_NF_CONNTRACK_MARK=y
CONFIG_NETFILTER_XTABLES=m
CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
CONFIG_NETFILTER_XT_MATCH_STATE=m

#
# IP: Netfilter Configuration
#
CONFIG_NF_CONNTRACK_IPV4=m
CONFIG_NF_CONNTRACK_PROC_COMPAT=y
CONFIG_IP_NF_IPTABLES=m
CONFIG_IP_NF_FILTER=m
CONFIG_NF_NAT=m
CONFIG_NF_NAT_NEEDED=y
CONFIG_IP_NF_TARGET_MASQUERADE=m


Reply all
Reply to author
Forward
0 new messages