I’ve been trying to log iptables to a file. from my understanding its suppose to log to kern.log or messages but that doesn’t seem to be happening. when using the Digital Ocean console when inputting ‘iptables -A INPUT -j LOG’ it’ll start logging the NIC but outputs it to the console not to kern.log or messages. even adding ‘kern.warning /var/log/iptables.log’ to rsyslog yields the same results. What am I doing wrong or how can I monitor traffic and log to file as this is how I was monitoring traffic and rejecting IPs via fail2ban and log files with regular expressions but that doesn’t seem to work anymore. any help would be appreciated. Thanks.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @ace31585,
Usually you should be able to see all messages in your journal:
journalctl
Having said that, as far as I know this is not something that can be reviewed anytime except real time.
As mentioned you’ve added kern.warning /var/log/iptables.log to rsyslog. Can you by any chance try and add it at /etc/syslog.conf and see if that would work for you?
Additionally, most probably you’ve tried this but can you give the bellow a try
iptables -N LOGGING
iptables -A OUTPUT -j LOGGING
iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "IPTables-Rules Dropped: " --log-level 4
iptables -A LOGGING -j DROP
This will output messages to /var/log/messages (unless you’ve specified it somewhere else from your syslog conf) with the prefix "IPTables-Rules Dropped: "
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.