iptables日志级别:warning的含义

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
whaha
帖子: 104
注册时间: 2016-07-08 17:43
系统: debian8

iptables日志级别:warning的含义

#1

帖子 whaha » 2017-02-06 21:38

0 debug –有调式信息的,日志信息最多
1 info –一般信息的日志,最常用
2 notice –最具有重要性的普通条件的信息
3 warning –警告级别
4 err –错误级别,阻止某个功能或者模块不能正常工作的信息
5 crit –严重级别,阻止整个系统或者整个软件不能正常工作的信息
6 alert –需要立刻修改的信息
7 emerg –内核崩溃等严重信息

这个是iptables的8个级别。

sudo iptables -A INPUT -p tcp --sport 80 -j LOG --log-level 4
这么设置好了,以后,sudo service rsyslog restart

点击几个网页后,
cat /var/log/iptables.log (我将iptables日志专门存放了)

Feb 6 21:01:39 hwy kernel: [16609.411694] IN=eth0 OUT= MAC=e0:30:40:50:60:70:f8:32:e4:96:96:b4:08:00 SRC=198.252.206.25
DST=192.168.1.176 LEN=239 TOS=0x04 PREC=0x00 TTL=45 ID=3269 DF PROTO=TCP SPT=80 DPT=47699 SEQ=2734110881 ACK=1779183241 WINDOW=57 RES=0x00 ACK FIN URGP=0
Feb 6 21:01:41 hwy kernel: [16611.413402] IN=eth0 OUT= MAC=e0:30:40:50:60:70:f8:32:e4:96:96:b4:08:00 SRC=198.252.206.25
DST=192.168.1.176 LEN=239 TOS=0x04 PREC=0x00 TTL=45 ID=15115 DF PROTO=TCP SPT=80 DPT=47697 SEQ=1519714542 ACK=3252168617 WINDOW=57 RES=0x00 ACK FIN URGP=0

这意味着什么?
本机和远端的连接出了什么问题?
有人意图攻击我?
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: iptables日志级别:warning的含义

#2

帖子 astolia » 2017-02-06 22:18

是有人攻击你,是一个在ubuntu中文论坛上id为whaha的人在对你发动精神攻击
说明白点就是你自己瞎疑神疑鬼,也不去查查手册,看看--log-level参数到底是在做什么用

你这人每次来问问题得到解答后,都完全没有回应,连基本的礼仪都不懂。就别想让我来告诉你那个参数真正的用处了。
whaha
帖子: 104
注册时间: 2016-07-08 17:43
系统: debian8

Re: iptables日志级别:warning的含义

#3

帖子 whaha » 2017-02-07 13:19

所谓警告,应该是这个时候进行一些修复性的工作,应该还可以把系统恢复到正常状态中来,系统应该可以继续运行下去。

所谓错误,就是说可以进行一些修复性的工作,但无法确定系统会正常的工作下去,系统在以后的某个阶段,很可能会因为当前的这个问题,导致一个无法修复的错误(例如宕机),但也可能一直工作到停止也不出现严重问题。

所谓Fatal,那就是相当严重的了,可以肯定这种错误已经无法修复,并且如果系统继续运行下去的话,可以肯定必然会越来越乱。这时候采取的最好的措施不是试图将系统状态恢复到正常,而是尽可能地保留系统有效数据并停止运行。

查了一些资料,仍旧不懂
whaha
帖子: 104
注册时间: 2016-07-08 17:43
系统: debian8

Re: iptables日志级别:warning的含义

#4

帖子 whaha » 2017-02-07 13:46

ALL : All levels including custom levels.

Trace : developing only, can be used to follow the program execution.

Debug : developing only, for debugging purpose.

Info : Production optionally, Course grained (rarely written informations), I use it to print that a configuration is initialized, a long running import job is starting and ending

Warn : Production, simple application error or unexpected behaviour. Application can continue. warn for example in case of bad login attemps, unexpected data during import jobs

Error : Production, application error/exception but application can continue. Part of the application is probably not working.

Fatal : Production, fatal application error/exception,application cannot continue, for example database is down.

Off : Do not log at all.

找到类似这样的材料,读懂了,也没有得到答案
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: iptables日志级别:warning的含义

#5

帖子 astolia » 2017-02-07 16:36

我上面是叫你去查“--log-level参数”的意思,不是叫你去查“--log-level的参数”。
另外我叫你查的“手册”,是指manual pages,也就是著名的man命令。而不是叫你在网上瞎搜

代码: 全选

man iptables
里面没有提到--log-level参数,但最后SEE ALSO提到了iptables-extensions(8),那就

代码: 全选

man 8 iptables-extensions
搜一下--log-level就找到这么一段

代码: 全选

  LOG
       Turn on kernel logging of matching packets.  When this option is set for a rule, the Linux kernel  will
       print  some  information  on  all matching packets (like most IP/IPv6 header fields) via the kernel log
       (where it can be read with dmesg(1) or read in the syslog).

       This is a "non-terminating target", i.e. rule traversal continues at the next rule.  So if you want  to
       LOG  the packets you refuse, use two separate rules with the same matching criteria, first using target
       LOG then DROP (or REJECT).

       --log-level level
              Level of logging, which can be (system-specific) numeric or a mnemonic.  Possible values are (in
              decreasing order of priority): emerg, alert, crit, error, warning, notice, info or debug.
上面几段,就已经说的够清楚了。只要你把LOG作为目标,也就是写了-j LOG,内核就会把符合条件的包记录下来。 --log-level参数的值,是由你自己随意指定的记录级别。你写上--log-level 4,表示你认为如果出现了符合条件的包,就应当把生成的记录归类到“错误”级别。
上面还提到了dmesg(1)和syslog,你也可以去查查dmesg和syslog的手册,看看它们是怎么处理记录的
回复