30 มิ.ย. 2557

เก็บ Log IPtable ให้ Ubuntu server

#nano /etc/rsyslog.d/50-default.conf
add the following lines: :msg, contains, “iptables”      -/var/log/iptables.log
& ~

เพิ่ม Code นี้ต่อท้ายในไฟล์ iptables.firewall
# cleanup rule to send all other traffic to the logdrop chain
-A INPUT -j logdrop


# allow all outbound loopback traffic
-A OUTPUT -o lo -j ACCEPT

# forward all outbound traffic to the logaccept chain
-A OUTPUT -j logaccept

# create your logaccept chain. this appends “iptables accept ” to the front of the log entry and then allows the traffic to pass through
-A logaccept -j LOG –log-prefix “iptables accept ”
-A logaccept -j ACCEPT

# create your logdrop chain. this appends “iptables drop ” to the front of every packet and the drops the packets
-A logdrop -j LOG –log-prefix “iptables drop ”
-A logdrop -j DROP
สร้างไฟล์
nano /etc/logrotate.d/iptables
ใส่ Code
/var/log/iptables.log
{
rotate 3
daily
missingok
notifempty
delaycompress
compress
postrotate
/usr/sbin/service rsyslog restart > /dev/null
endscript
}
รันคำสั่ง
Cat /var/log/iptables.log
กรองด้วย | grep ตามด้วยเงื่อนไข

ไม่มีความคิดเห็น:

แสดงความคิดเห็น