Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this set of iptables rules ...

$ sudo iptables -n -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
LOG        all  --             limit: avg 5/min bu
REJECT     tcp  --           tcp dpt:22 reject-w

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

... the above blocks but it does not log attempts from Instead connections from other clients are logged. I just want to log the dropped packets. What I want to do is log all dropped packets.

share|improve this question
up vote 2 down vote accepted

Remove the existing LOG rule and replace it with a rule to only log packets matching --dport 22. That will match the same packets that will be rejected by the REJECT rule

iptables -D INPUT 1  # Deletes rule 1 on INPUT chain
iptables -I INPUT 1 -p tcp -s --dport 22 -j LOG
share|improve this answer
Thanks Creek! That works. Next I would want to figure out how to log all dropped packets. Is there a simple catch all iptables command I could issue or would I have to understand the rules that are already defined? – Red Cricket Jun 26 '14 at 16:20
@RedCricket there's a couple ways you can do it. Start a new question for it so the answer doesn't get lost in these comments – Creek Jun 26 '14 at 18:14
Will do. Thanks for your help Creek. – Red Cricket Jun 26 '14 at 21:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.