增加“iptables”的详细程度并确定基于 CentOS 的服务器上的日志记录位置?

yll*_*ate 3 iptables centos pound clearos

在基于 CentOS 的发行版 (ClearOS 6.2.x) 上,英镑反向代理不再正确引导流量,这里有一个奇怪的问题。

我相信这是一个iptables问题或其他原因,因为我看不到任何东西甚至表明我的/var/log/messages/var/log/system.

我怎样才能增加iptables日志记录的详细程度并验证它发生了什么(就记录数据保存位置的确定性而言)?

Eri*_*ric 5

以下是我过去为打开 iptables 日志记录而采取的一般步骤。

Modify Logging
- sudo vi /etc/syslog.conf
- kern.warning /var/log/iptables.log
 - sudo /sbin/service syslog restart
 - sudo vi /etc/logrotate.d/syslog
- If this file is already there, add /var/log/iptables.log to the first line
- If the file is not there, add it:
Run Code Online (Sandbox Code Playgroud)
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron /var/log/iptables.log {
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}
Run Code Online (Sandbox Code Playgroud)
Implement firewall rules
• sudo vi /etc/sysconfig/iptables.script
• sudo chmod 700 /etc/sysconfig/iptables.script
• sudo /etc/sysconfig/iptables.script
Run Code Online (Sandbox Code Playgroud)

在我的 iptables 脚本中,我在顶部有所有通用的允许规则,然后在底部有一些特定的日志记录规则。下面是几个例子。

# Log dropped traffic
/sbin/iptables -A INPUT -j LOG -m limit --limit 10/m --log-level 4 --log-prefix "Dropped Traffic: "
# Log outbound traffic for anything not equal private ip ranges (this is defined in some previous rules)
/sbin/iptables -A OUTPUT -j LOG -m limit --limit 10/m --log-level 4 --log-prefix "Outbound Traffic: "
# Log traffic that doesn't hit a rule above (stuff that may be blocked in the future)
/sbin/iptables -A INPUT -j LOG -m limit --limit 10/m --log-level 4 --log-prefix "Potentially Dropped Traffic: "
Run Code Online (Sandbox Code Playgroud)

显然,你可以用它做很多事情。是一些通用信息的好链接。