个人工具
登录
查看“IptablesHowTo”的源代码 - Ubuntu中文
页面
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“IptablesHowTo”的源代码
来自Ubuntu中文
←
IptablesHowTo
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
==== Using iptables-save/restore to test rules 使用iptables-save/restore测试规则 ==== If you edit your iptables beyond this tutorial, you may want to use the <code><nowiki>iptables-save</nowiki></code> and <code><nowiki>iptables-restore</nowiki></code> feature to edit and test your rules. To do this open the rules file in your favorite text editor (in this example gedit). 使用iptables-save和iptables-restore可以很方便地修改和测试防火墙规则。首先运行iptables-save将规则保存到一个文件,然后用编辑器编辑该文件。 <pre><nowiki> # iptables-save > /etc/iptables.test.rules # gedit /etc/iptables.test.rules </nowiki></pre> You will have a file that appears similiar to (following the example above): 如果您根据前面的例子建立了防火墙规则,iptables-save将产生一个类似于如下内容的文件: <pre><nowiki> # Generated by iptables-save v1.3.1 on Sun Apr 23 06:19:53 2006 *filter :INPUT ACCEPT [368:102354] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [92952:20764374] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7 -A INPUT -j DROP COMMIT # Completed on Sun Apr 23 06:19:53 2006 </nowiki></pre> Notice that these are iptables commands minus the <code><nowiki>iptable</nowiki></code> command. Feel free to edit this to file and save when complete. Then to test simply: 文件内容其实就是各种iptables命令,只不过把命令名iptables省略了。您可以随意对这个文件进行编辑,然后保存。接着使用以下命令测试修改后的规则: <pre><nowiki> # iptables-restore < /etc/iptables.test.rules </nowiki></pre> After testing, if you have not added the <code><nowiki>iptables-save</nowiki></code> command above to your <code><nowiki>/etc/network/interfaces</nowiki></code> remember not to lose your changes: 之前您如果没有在<code><nowiki>/etc/network/interfaces</nowiki></code>文件中添加<code><nowiki>iptables-save</nowiki></code>命令,那么测试之后,别忘了把您所作的修改保存起来。 <pre><nowiki> # iptables-save > /etc/iptables.up.rules </nowiki></pre>
返回至
IptablesHowTo
。