Android iptables error: iptables-save and iptables-restore not working

I have compiled Linux for android emulator with full netfilter functionality. And I got the iptables binary after building the android from the source.

When I click this binary code on the emulator

I can successfully execute commands like below.

iptables -L
iptables -F
iptables -A INPUT -s www.google.com -j DROP 

with this error:

# # iptables -L
getsockopt for multiport failed strangely: No such file or directory
getsockopt for multiport failed strangely: No such file or directory
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
# 

and

# iptables -A INPUT -s www.google.com -j DROP
getsockopt for multiport failed strangely: No such file or directory
getsockopt for multiport failed strangely: No such file or directory
FIX ME! implement getgrnam() bionic/libc/bionic/stubs.c:344

but at least the above teams that they work!

but when i try

iptables-save     or
iptables-restore

I get an error

iptables-save: not found

In my configuration file

CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m

what is the problem..?? and how can I enable the full iptables functionality in Android and how can I safely save the current active iptables rules and reload them the next time I reboot.

please, help. thank!

+5
2

, Android.mk, iptables-save, iptables-retore. Android 4.0.3.


#----------------------------------------------------------------
# iptables-save


include $(CLEAR_VARS)

LOCAL_C_INCLUDES:= \
    $(LOCAL_PATH)/../include/

LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
LOCAL_CFLAGS+=-DALL_INCLUSIVE
LOCAL_CFLAGS+=-DXTABLES_INTERNAL
# Accommodate arm-eabi-4.4.3 tools that don't set __ANDROID__
LOCAL_CFLAGS+=-D__ANDROID__

LOCAL_SRC_FILES:= \
    iptables-save.c iptables.c xshared.c

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE:=iptables-save

LOCAL_STATIC_LIBRARIES := \
    libext \
    libext4 \
    libip4tc \
    libxtables

include $(BUILD_EXECUTABLE)


#----------------------------------------------------------------
# iptables-restore


include $(CLEAR_VARS)

LOCAL_C_INCLUDES:= \
    $(LOCAL_PATH)/../include/

LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
LOCAL_CFLAGS+=-DALL_INCLUSIVE
LOCAL_CFLAGS+=-DXTABLES_INTERNAL
# Accommodate arm-eabi-4.4.3 tools that don't set __ANDROID__
LOCAL_CFLAGS+=-D__ANDROID__

LOCAL_SRC_FILES:= \
    iptables-restore.c iptables.c xshared.c

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE:=iptables-restore

LOCAL_STATIC_LIBRARIES := \
    libext \
    libext4 \
    libip4tc \
    libxtables

include $(BUILD_EXECUTABLE)

+1

iptables-save iptables-restore Android.

Android.mk $mydroid/external/iptables/ . iptables-save.c iptables-restore.c .

, iptables-save - Android.mk. iptables-restore:

#
# Build iptables-save
#

include $(CLEAR_VARS)

LOCAL_C_INCLUDES:= \
    $(LOCAL_PATH)/include/ \
    $(KERNEL_HEADERS)

LOCAL_CFLAGS:=-DNO_SHARED_LIBS
LOCAL_CFLAGS+=-DIPTABLES_VERSION=\"1.3.7\"

LOCAL_SRC_FILES:= \
    iptables-save.c 

LOCAL_MODULE_TAGS:=debug
LOCAL_MODULE:=iptables-save

LOCAL_STATIC_LIBRARIES := \
    libiptc \
    libext

include $(BUILD_EXECUTABLE)
+2

All Articles