Fli
04-24-2023, 12:46 PM
How to enable logging in iptables.
If the last line in chain is to drop everything that does not match previous rules, then I assume one should add logging rule before this line in order to log only blocked requests.
sudo iptables -L --line-numbers
sudo iptables -I CHAIN(INPUT,OUTPUT,FORWARD) NUMBER(number of the chain line where is last drop rule shown using above command) -j LOG
sudo tail -f /var/log/messages
If the last line in chain is to drop everything that does not match previous rules, then I assume one should add logging rule before this line in order to log only blocked requests.
sudo iptables -L --line-numbers
sudo iptables -I CHAIN(INPUT,OUTPUT,FORWARD) NUMBER(number of the chain line where is last drop rule shown using above command) -j LOG
sudo tail -f /var/log/messages