gpt4 book ai didi

android - android : iptables-save and iptables-restore not working 中的 iptables 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:59:16 56 4
gpt4 key购买 nike

我已经为启用了完整 netfilter 功能的 android 模拟器编译了 Linux。从源代码构建 android 后得到一个 iptables 二进制文件。

当我将这个二进制文件推送到模拟器时

我可以成功执行如下命令。

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

出现此错误:

# # 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
#

# 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

但至少上面的命令是有效的!

但是当我尝试

iptables-save     or
iptables-restore

我收到错误提示

iptables-save: not found

在我的配置文件中

CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m

有什么问题……??以及如何在 android 中启用完整的 iptables 功能,或者如何安全地保存当前 Activity 的 iptables 规则并在下次重启时重新加载它们。

请帮忙。谢谢!

最佳答案

iptables-saveiptables-restore 二进制文件不是由默认的 Android 系统 makefile 构建的。

您需要将规则添加到 $mydroid/external/iptables/ 中的 Android.mk 文件以构建它们。源文件 iptables-save.ciptables-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)

关于android - android : iptables-save and iptables-restore not working 中的 iptables 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5541983/

56 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com