/etc/sysconfig/iptables
-A INPUT -p tcp --dport 80 -j LOG --log-level 5 --log-prefix "PORT_80:" -A INPUT -p tcp --dport 22022 -j LOG --log-level 5 --log-prefix "PORT_22" 查看日志输出: Jul 9 15:34:55 ServerName kernel: PORT_80:IN=eth1 OUT= MAC=00:16:3e:12:12:bb:a6:67:d8:74:ae:41:08:00 SRC=110.184.36.60 DST=113.137.79.10 LEN=64 TOS=0x14 PREC=0x00 TTL=50 ID=16726 DF PROTO=TCP SPT=44864 DPT=80 WINDOW=65535 RES=0x00 SYN URGP=0 Jul 9 15:35:06 ServerName kernel: PORT_22IN=eth1 OUT= MAC=00:16:3e:12:12:bb:a6:67:d8:74:ae:41:08:00 SRC=115.33.32.160 DST=113.137.79.10 LEN=60 TOS=0x14 PREC=0x00 TTL=53 ID=60994 DF PROTO=TCP SPT=39879 DPT=22022 WINDOW=29200 RES=0x00 SYN URGP=0 只要有80或22端口的请求,就会计录在/var/log/firewall.log 中 这一切的实现除了IPTABLES上面的两条配置外,还要对RSYSLOG的配置做以下配置 : /etc/rsyslog.conf #kern.* /dev/console kern.=notice /var/log/firewall.log 最后重启IPTABLES和RSYSLOG