我遇到了启用 SECMARK 扩展的问题。 我使用的是带有 Linux 4.4.60 内核的 OpenWRT 操作系统。 我已根据此来源连接了 config-4.4.60 中的所有依赖项: [https://www.kernelconfig.io/config_netfilter_xt_target_secmark?q=&kernelversion=4.4.60&arch=x86] 但操作系统上未启用 SECMARK 扩展,我无法创建 iptable。
我添加了以下依赖项:
CONFIG_NETWORK_SECMARK=y
CONFIG_NF_CONNTRACK=y
CONFIG_NF_CONNTRACK_SECMARK=y
CONFIG_NETFILTER_XTABLES=y
CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
CONFIG_NETFILTER_XT_TARGET_SECMARK=y
之后,我编译了图像并得到了以下结果:
$ ls build_dir/target-*/linux-*/linux-4.4.60/net/netfilter | grep SECMARK
xt_CONNSECMARK.c
xt_CONNSECMARK.o
xt_SECMARK.c
xt_SECMARK.o
$ find -name libxt_SECMARK.so
./target-*/linux-*/iptables-1.8.3/ipkg-install/usr/lib/iptables/libxt_SECMARK.so
./target-*/linux-*/iiptables-1.8.3/extensions/libxt_SECMARK.so
$ grep -rn SECMARK staging_dir/target-***/pkginfo/
staging_dir/target-***/pkginfo/kernel.provides:259:xt_CONNSECMARK.ko
staging_dir/target-***/pkginfo/kernel.provides:261:xt_SECMARK.ko
之后,我启动了OpenWRT镜像,上面没有SECMARK:
/# lsmod | grep SECMARK
/# modprobe xt_SECMARK
failed to find a module named xt_SECMARK
/# iptables -t mangle -A OUTPUT -j SECMARK
iptables v1.8.3 (legacy): Couldn't load target SECMARK':No such file or directory
Try iptables -h' or 'iptables --help' for more information.
/# ls /usr/lib/iptables | grep SECMARK
/# ls /lib/modules/4.4.60 | grep SECMARK
然后我在网上搜索了更多信息,发现我仍然需要连接SELinux。我添加了以下依赖项:
CONFIG_NF_TABLES=y
CONFIG_NF_CONNTRACK=y
CONFIG_NETFILTER_XTABLES=y
CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
CONFIG_NETFILTER_XT_TARGET_SECMARK=y
CONFIG_NETWORK_SECMARK=y
CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
CONFIG_NETFILTER_XTABLES=y
CONFIG_NFT_QUEUE=y
CONFIG_NFT_COMPAT=y
CONFIG_NF_TABLES_ARP=y
CONFIG_NF_TABLES_BRIDGE=y
CONFIG_NF_LOG_BRIDGE=y
但这也不起作用。我得到了与之前相同的结果。
重新启动计算机,可能会有所帮助