iptables:没有该名称的链/目标/匹配

iptables:没有该名称的链/目标/匹配
root@OpenWrt:/man/ipk# iptables -I FORWARD -m string --algo bm --string "instagram" -j DROP
iptables: No chain/target/match by that name.
root@OpenWrt:/man/ipk#

有人能解释一下为什么这不起作用吗?

答案1

这取决于 netfilter 字符串模块是否已编译到内核中,或者是否已编译为模块。几年前,由于“string”模块可能占用大量 CPU,因此默认情况下 Ubuntu 内核不提供该模块。最近几年(我不记得具体是什么时候)默认情况下,它作为模块可用。检查 Ubuntu 内核的方法是在内核配置模块中搜索它。示例:

doug@s17:~$ uname -a
Linux s17 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
doug@s17:~$ grep -i NETFILTER_XT_MATCH_STRING /boot/config-4.15.0-36-generic
CONFIG_NETFILTER_XT_MATCH_STRING=m

因此,它作为模块存在于我的系统中。并且命令对我来说加载得很好:

doug@s17:~$ sudo iptables -I FORWARD -m string --algo bm --string "instagram" -j DROP
doug@s17:~$ sudo iptables -v -x -n -L
Chain INPUT (policy ACCEPT 210 packets, 15763 bytes)
    pkts      bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
    pkts      bytes target     prot opt in     out     source               destination
       0        0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            STRING match  "instagram" ALGO name bm TO 65535

Chain OUTPUT (policy ACCEPT 141 packets, 36585 bytes)
    pkts      bytes target     prot opt in     out     source               destination

相关内容