I have set up a simple iptable that should log all dropped packages to a file. When I check my log file it is empty.
My iptables:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere #Allow loopback
LOGGING all -- anywhere anywhere
DROP all -- anywhere anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain LOGGING (1 references)
target prot opt source destination
LOG all -- anywhere anywhere LOG level warning prefix "IPTables-Dropped: "
DROP all -- anywhere anywhere
And in /etc/rsyslog.d/90-iptables.conf
I redirect the messages to another file:
:msg,contains,"IPTables-Dropped: " /var/log/iptables.log"
Now changed into
kern.warning /var/log/iptables.log
Output from sudo iptables -v -x -n -L
yields:
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
58254 11751250 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
3937 232480 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
52 2824 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
68 3696 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
114 9187 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
1636 154417 LOGGING all -- * * 0.0.0.0/0 0.0.0.0/0
16 668 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 70233 packets, 16508738 bytes)
pkts bytes target prot opt in out source destination
Chain LOGGING (1 references)
pkts bytes target prot opt in out source destination
1641 154653 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 4 prefix "IPTables-Dropped: "
1640 154613 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
sudo iptables -v -x -n -L
instead? That would give us a more complete picture, and also show the packets counters, so that we can see if the LOGGING chain was actually traversed and how many times./var/log/syslog
and/var/log/kern.log
, as is the default?