解决iptables-restore导入报错 iptables-restore: unable to initialize table ‘security

2018-08-23 07:10:54 7172


加条iptables规则,我直接将原来的iptables规则的备份文件拖到windows下编辑,编辑完成后之后sftp传上去,接着用 iptables-restore < iptables-rules.bak 。结果iptables有如下报错,提示以下错误:
FATAL: Module ip_tables not found.
iptables-restore: unable to initialize table ‘security
Error occurred at line: 2
Try `iptables-restore -h’ or ‘iptables-restore –help’ for more information.
提示iptables某个表不能初始化。我看了第二行,还真没看出错误来。
分析过程:因为在使用iptables-restore命令前,还有一个完整的,好的iptables备份文件 iptables 。我试着将这个规则文件导入iptables就没有提示
FATAL: Module ip_tables not found.
: iptables-restore: unable to initialize table ‘security
Error occurred at line: 2
Try `iptables-restore -h’ or ‘iptables-restore –help’ for more information.
但是,一旦导入我这修改后的文件就提示报错。可是,肉眼真没看到哪有有语法上的或者单词上的错误。最后,只能猜测是下是不是文件格式不对。我将修改后的文件改成Unix格式,然后重新上传,导入,就没有任何问题了。成功解决报错。
还有可能就是你在windows下编辑的时候,多了很多其他的不必要的字符。所以,建议还是在linux下更改规则文件。

提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: