个人工具
登录
查看“IptablesHowTo”的源代码 - Ubuntu中文
页面
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“IptablesHowTo”的源代码
来自Ubuntu中文
←
IptablesHowTo
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
==== More detailed Logging 关于日志记录的更多细节 ==== For further detail in your syslog you may want create an additional Chain. This will be a very brief example of my /etc/iptables.up.rules showing how I setup my iptables to log to syslog: 您可以创建额外的规则链,以便在syslog中作更加详细的记录。以下是我/etc/iptables.up.rules文件中的一个简单例子: <pre><nowiki> # Generated by iptables-save v1.3.1 on Sun Apr 23 05:32:09 2006 *filter :INPUT ACCEPT [273:55355] :FORWARD ACCEPT [0:0] :LOGNDROP - [0:0] :OUTPUT ACCEPT [92376:20668252] -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 -j LOGNDROP -A LOGNDROP -p tcp -m limit --limit 5/min -j LOG --log-prefix "Denied TCP: " --log-level 7 -A LOGNDROP -p udp -m limit --limit 5/min -j LOG --log-prefix "Denied UDP: " --log-level 7 -A LOGNDROP -p icmp -m limit --limit 5/min -j LOG --log-prefix "Denied ICMP: " --log-level 7 -A LOGNDROP -j DROP COMMIT # Completed on Sun Apr 23 05:32:09 2006 </nowiki></pre> Note a new CHAIN called <code><nowiki>LOGNDROP</nowiki></code> at the top of the file. Also, the standard <code><nowiki>DROP</nowiki></code> at the bottom of the INPUT chain is replaceed with <code><nowiki>LOGNDROP</nowiki></code> and add protocol descriptions so it makes sense looking at the log. Lastly we drop the traffic at the end of the <code><nowiki>LOGNDROP</nowiki></code> chain. The following gives some idea of what is happening: * <code><nowiki>--limit</nowiki></code> sets the number of times to log the same rule to syslog * <code><nowiki>--log-prefix "Denied..."</nowiki></code> adds a prefix to make finding in the syslog easier * <code><nowiki>--log-level 7</nowiki></code> sets the syslog level to informational (see man syslog for more detail, but you can probably leave this) 可以看到,文件前面多了一条名为<code><nowiki>LOGNDROP</nowiki></code>的规则链。此外,INPUT链最后一条规则中的<code><nowiki>DROP</nowiki></code>被<code><nowiki>LONGDROP</nowiki></code>替代。并且在后面我添加了一些内容来描述报文所使用的协议,这可以让记录更容易理解。最后,在<code><nowiki>LOGNDROP</nowiki></code>链的末尾,报文被丢弃。 * <code><nowiki>--limit</nowiki></code> 对由此规则引发的记录事件的频率进行限制。 * <code><nowiki>--log-prefix "Denied..."</nowiki></code> 在每条记录前加上一个前缀,以便查找。 * <code><nowiki>--log-level 7</nowiki></code> 将记录的详细程度设为“informational”等级(详情请见man syslog,您也可以直接使用此处的设置)。
返回至
IptablesHowTo
。