已加载的 iptables 模块列表
有没有方便的方法来显示加载的 iptables 模块列表?我可以通过列出 /lib/iptables/
(或 /lib64/iptables/
)目录来显示已安装的模块,但我需要活动模块列表。
Is there any convenient way to show loaded iptables module list? I can show installed modules by listing /lib/iptables/
(or /lib64/iptables/
) directory but I need active modules list.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
加载的 iptables 模块可以在 /proc/net/ip_tables_matches proc 文件系统条目中找到。
在 PHP 中,我可以通过加载和分解文件内容来访问加载的 iptables 模块:
当然,它需要安装 proc 文件系统(大多数 GNU Linux 发行版默认安装它)
Loaded iptables modules can be found in /proc/net/ip_tables_matches proc filesystem entry.
In PHP I can access the loaded iptables modules by loading and exploding file contents:
Of course it requires proc filesystem to be mounted (Most GNU Linux distros mount it by default)
查看以下目录(根据您的内核版本进行替换):
您可以使用以下方式加载模块(删除目录中列出的
.ko
):或者,您可以确保它在启动时加载将其添加到:
这似乎没有很好的记录。
Take a look in the following directory (replace per your kernel version):
You can load the module using (dropping the
.ko
as listed in the directory):Alternatively, you can ensure it's loaded at boot by adding it to:
This seems to be poorly documented.
尝试此操作以快速概述系统上存在的 netfilter 模块,这里是用于粘贴的一行:
再次为了可读性,添加了换行符:
文件名将以黄色显示,从中您可以猜测有问题的模块是否存在。描述和依赖项是下面接下来的两行。
这不会涵盖所有内容(因为这太容易了,ofc)。仅手动查找模块,看看它们是否存在,即可为您提供 100% 准确的信息。
如果您的系统上存在模块,则在帮助文本的末尾,您将获得一些有关如何使用它的信息:
如果您的系统上不存在该模块:
Try this for a fast overview on the netfilter modules present on your system, here a one-liner for pasting:
Again for readability, with added newlines:
Filename will appear in yellow, from which you can guess if the module in question exists or not. Description and dependencies are the next two lines below.
This will not cover everything (because this would be too easy, ofc). Only looking up the modules manually, to see if they exist, gives you 100% accurate information.
If a module exists on your system, at the end of the help text you will get some info on how to use it:
It the module is not present on your system:
这是一篇非常旧的帖子,但我们开始吧:
显示已加载模块的列表,我认为大多数与 iptables 相关......
/proc/net/ip_tables_matches
不显示模块(至少在 RHEL 6 中不显示)This is a really old post but here we go:
shows a list of loaded modules, which I think most are related to iptables...
/proc/net/ip_tables_matches
doesn't show modules (at least not in RHEL 6)正如 Gonio 建议 lsmod 列出所有加载的内核模块,但 grepping “ip” 不会为您提供所有 iptables 模块。
我宁愿使用
,但我不确定该列表是否完整。
As Gonio has suggested lsmod lists all loaded kernel modules, but grepping "ip" won't give you all iptables modules.
I would rather use
and still, I'm not sure the list will be complete.
作为替代方法,也可以使用 Python 脚本来完成此操作。
首先确保您有 iptc 库。
sudo pip install --upgrade python-iptables
(假设Python3是你的版本)
As an alternative method, this can also be done with a Python script.
First make sure you have the iptc library.
sudo pip install --upgrade python-iptables
(Assuming Python3 is your version)