我有一个包含所有iptable设置的文件。 我如何加载到我的服务器?

我的系统pipe理员给了我一个iptables规则的文件。 我input什么命令来加载?

我看着他做了,他做了一行! 就像… iptables> thefile.dat?

我的系统pipe理员给了我一个iptables规则的文件。 我input什么命令来加载?

iptables-restore < file-with-iptables-rules.txt 

我看着他做了,他做了一行! 就像… iptables> thefile.dat?

 iptables-save > file-with-iptables-rules.txt 

你使用iptables-restore 加载一个iptablesconfiguration文件

 iptables-restore thefile.dat 

这立即生效。 但是,对于这个设置在系统重启过程中持久的,它们必须被保存。 在大多数发行版上,这可以通过。

 /etc/init.d/iptables save 

正如在其他答案中提到的configuration可以使用保存

 iptables-save > thesavefile.dat 

该文件本身是一个文本文件 ,可以用任何文本编辑器进行编辑,然后使用iptables-restore命令重新加载到iptables中。

将iptables脚本导入到规则集中

 iptables-restore < /path/to/firewall_script