Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have this set of iptables rules ...

$ sudo iptables -n -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
LOG        all  --  0.0.0.0/0            0.0.0.0/0           limit: avg 5/min bu
REJECT     tcp  --  192.168.1.134        0.0.0.0/0           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 192.168.1.134 but it does not log attempts from 192.168.1.134. 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

1 Answer 1

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 192.168.1.134 --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 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 at 18:14
    
Will do. Thanks for your help Creek. –  Red Cricket Jun 26 at 21:55

Your Answer

 
discard

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.