项目场景:
DEVICE: RK3399
KERNEL: Linux 4.4.189
OS: Ubuntu 18.04.6
问题描述
业务应用开发人员反馈在使用开源框架时,iptables产生了如上错误。
原因分析:
iptables 命令运行报错,初步分析是由于该环境下的iptalbes不支持comment,而该程序中调用了i-m comment --comment,所以产生了报错。
解决方案:
方案一、不使用comment,即在使用iptables时删除掉-m comment --comment,不建议。
方案二、修改内核配置支持iptables comment
- 修改内核配置,设置CONFIG_NETFILTER_XT_MATCH_COMMENT=m
- 编译内核modules,在kernel/net/netfilter下得到xt_comment.ko
- 上传xt_comment.ko到目标环境,insmod xt_comment.ko,此问题解决。
注:CONFIG_NETFILTER_XT_MATCH_COMMENT依赖下面红色标记的内核选项
Symbol: NETFILTER_XT_MATCH_COMMENT [=n] │
│ Type : tristate │
│ Prompt: “comment” match support │
│ Location: │
│ -> Networking support (NET [=y]) │
│ -> Networking options │
│ -> Network packet filtering framework (Netfilter) (NETFILTER [=y]) │
│ -> Core Netfilter Configuration │
│ (1) -> Netfilter Xtables support (required for ip_tables) (NETFILTER_XTABLES [=y]) │
│ Defined at net/netfilter/Kconfig:1003 │
│ Depends on: NET
[=y] && INET
[=y] && NETFILTER
[=y] && NETFILTER_XTABLES
[=y] && NETFILTER_ADVANCED
[=y]
参考链接
https://cateee.net/lkddb/web-lkddb/NETFILTER_XT_MATCH_COMMENT.html
https://github.com/garywill/linux-router/issues/18